ridiculous 2 Posted October 24, 2012 Report Share Posted October 24, 2012 How can I create a container in ubot so it's easier to organize different parts of the bot. Say I have 5 commands that are used to sign into an account. How can I group them in a container so that I can collapse/expand/move them all as one unit? Thanks! Quote Link to post Share on other sites
rocket976 62 Posted October 24, 2012 Report Share Posted October 24, 2012 Looks like your looking for the "define" command Quote Link to post Share on other sites
UBotBuddy 331 Posted October 24, 2012 Report Share Posted October 24, 2012 You can also use a Loop set to one cycle. I do that a lot. Buddy Quote Link to post Share on other sites
ridiculous 2 Posted October 24, 2012 Author Report Share Posted October 24, 2012 Thanks!! Quote Link to post Share on other sites
UBotBuddy 331 Posted October 24, 2012 Report Share Posted October 24, 2012 The cool thing is that they can be copied and pasted easier than doing individual nodes. Good luck! Quote Link to post Share on other sites
Twitter Dominator 125 Posted November 21, 2012 Report Share Posted November 21, 2012 now on the define command whats the difference between ( Command or Function ) anyone explain that feature a bit? Quote Link to post Share on other sites
Legend 181 Posted November 21, 2012 Report Share Posted November 21, 2012 Basically, Commands are used to perform specific tasks (does something) while Functions are used for calculating stuff (returns a value)... http://learnubot.com/video-ubot-tutorials/v4-ubot-tutorials-using-the-define-command-2/ Quote Link to post Share on other sites
VaultBoss 310 Posted November 21, 2012 Report Share Posted November 21, 2012 When you set the custom command to function, the resulting function may be called and would actually return the result per se, not just perform the set of commands within, like the regular commands would do. For instance, if you would write some code to get some data from a variable as its input, then perform a set of operations/calculations within, math or string related, for example... then calling that function would actually pass the result of the operations to a set command on the main program. Like this - say you write a define to calculate the Round number of a decimal number, that will get an input variable: set(#My_Rounded_Result, $Round(123.257), "Global") If that were the case, your #My_Rounded_Result variable would have now gotten the value returned by your custom function, which would be 123.26 Don't hold your imagination, it is not supposed to work only math.You can write functions to apply various operations to strings, for example... and so forth... HTH... Quote Link to post Share on other sites
VaultBoss 310 Posted November 21, 2012 Report Share Posted November 21, 2012 Beware, when you program it, apart from selecting it to be a 'Function' not a 'Command' in the DEFINE node, you will also have to add an extra command at the end, specifically the RETURN command, that will instruct the function WHAT exactly to return when called... Inside the RETURN command you will set the 'Local' variable (from within the DEFINE code) that will be passed outside, to the calling program: RETURN(#Rounded_Value) ....for example. Quote Link to post Share on other sites
Twitter Dominator 125 Posted November 21, 2012 Report Share Posted November 21, 2012 thank you both very helpful explanation :-) Quote Link to post Share on other sites
Twitter Dominator 125 Posted November 21, 2012 Report Share Posted November 21, 2012 one follow up: can you explain the parameters also shown on the define tab? Quote Link to post Share on other sites
Twitter Dominator 125 Posted November 21, 2012 Report Share Posted November 21, 2012 Basically, Commands are used to perform specific tasks (does something) while Functions are used for calculating stuff (returns a value)... http://learnubot.com...fine-command-2/sorry didn't see you added a video had to scroll up the thread, watching it now thanks Quote Link to post Share on other sites
Twitter Dominator 125 Posted November 21, 2012 Report Share Posted November 21, 2012 thanks Duane for the video however it didnt explain the parameter part can you guys? is it required or optional or is it defining something Quote Link to post Share on other sites
VaultBoss 310 Posted November 21, 2012 Report Share Posted November 21, 2012 They are the input variables that are passed into the DEFINE from the main program that is calling it... Quote Link to post Share on other sites
Twitter Dominator 125 Posted November 21, 2012 Report Share Posted November 21, 2012 ah ok i see so optional if i run as command but used if used as a function eval correct? Quote Link to post Share on other sites
Legend 181 Posted November 21, 2012 Report Share Posted November 21, 2012 you got it... Quote Link to post Share on other sites
HarryPotter 9 Posted November 29, 2012 Report Share Posted November 29, 2012 just tried using the define > command to replace my multiple duplicate loops set to one cycle You can also use a Loop set to one cycle. I do that a lot. Buddy hahaha... want cleaner code i guess... since i was using command (don't want it to return anything), i simply added the "define > command" node, with no variables, and dragged my 1 cycle loop in the function didn't execute though even though it works fine as a 1 cycle loop any ideas? Quote Link to post Share on other sites
VaultBoss 310 Posted November 29, 2012 Report Share Posted November 29, 2012 The DEFINE command will not execute if you don't CALL it... Basically it is just a subroutine, a piece of code that needs to be told to run in order to run. The fact that you have written it and it sits in your bot in between other commands, still doesn't count. It will be skipped at run time. The only way to make it work is to call it from the main program. Quote Link to post Share on other sites
HarryPotter 9 Posted November 29, 2012 Report Share Posted November 29, 2012 yup yup under custom commands... i pulled the node to make sure it runs where i need it to i remember to add the "run sub"! but no go still... Quote Link to post Share on other sites
VaultBoss 310 Posted November 29, 2012 Report Share Posted November 29, 2012 Paste the code here and let's take a look, then... Quote Link to post Share on other sites
HarryPotter 9 Posted November 29, 2012 Report Share Posted November 29, 2012 got it... define cannot be within another node... (just like ui nodes) Quote Link to post Share on other sites
VaultBoss 310 Posted November 29, 2012 Report Share Posted November 29, 2012 Yeah, best thing is to put your DEFINEs in separate TABs or at least, at the end of the code. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.