Jump to content
UBot Underground

[Help] Simple javasript math and return result in to variable


Recommended Posts

Hi, I need someone help , I setup a variable and use it on $eval command for simple math command, it appear that it has a bug ( its works when I click run node, but fail when I play the bot ) reported as instructed but no answer yet,

 

My situation is urgent, and if anyone knows how to setup a code for just simple to return a result from example ( 1+2=#var ) I will be greatfully thanks.. :D

Link to post
Share on other sites

Here is an example:

divider
define $integerNumJS(#var_INP_Number) {
    divider
    if($comparison(#var_INP_Number, "<", 0)) {
        then {
            set(#var_LOC_IntegerNum, $subtract(0, #var_INP_Number), "Local")
        }
        else {
            set(#var_LOC_IntegerNum, #var_INP_Number, "Local")
        }
    }
    divider
    set(#var_LOC_IntegerNum, $eval("var locworknum = {#var_LOC_IntegerNum};
locworknumint = ~~locworknum;"), "Local")
    divider
    if($comparison(#var_INP_Number, "<", 0)) {
        then {
            set(#var_OUT_Result, $subtract(0, #var_LOC_IntegerNum), "Local")
        }
        else {
            set(#var_OUT_Result, #var_LOC_IntegerNum, "Local")
        }
    }
    divider
    return(#var_OUT_Result)
}
divider

... that returns the INTEGER of a number to use in UBot Studio.


Change it to suit your needs.

  • Like 1
Link to post
Share on other sites

You're welcome

 

I created a whole library of JavaScript functions for UBS, to supplement what existed already natively.  :)  Helps a LOT!

Link to post
Share on other sites

 

set(#var_LOC_IntegerNum, $eval("var locworknum = {#var_LOC_IntegerNum};

 

Now this is the trouble man :). When I Click "RUN NODE" its working and shows the result, but when I play the Bot, its has empty result...its strange but its also happen to my main bot.

 

Do you know other command to avaoid of using $eval command ..?

Link to post
Share on other sites

If you used my code, that is normal to happen, as the variables within the function are "Local" so you won't see their values in the DEBUGGER, but only the variable returned by the RETURN command (the result of the function, basically)

 

If you want to see how the variables inside the custom function work, turn them to "Global", watch the DEBUGGER... then in working environment, turn them back to "Local"

  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...