Sebastian Rooks 3 Posted March 8, 2016 Report Share Posted March 8, 2016 I've got 7 script tabs in one wildly unruly bot, with 7 different unruly interfaces. I want to bring it all together neatly and efficiently, and then conquer the internet. I gather that using defines, along with include, is the way to achieve this. My problem is that I don't understand what parameters are and or how they work in regards to this situation. I've been googling for the last couple of hours, and I'm coming up a little short. I've broken my code down into Defines, I can call the Defines as long as they're in the same bot. But trying to include them in another bot doesn't work. It seems that anything that uses variables (most of my defines have several which will be set from the ui) doesn't work like this. As always, any guidance will be appreciated. Your buddy,Sebastian Rooks Quote Link to post Share on other sites
pash 504 Posted March 8, 2016 Report Share Posted March 8, 2016 Definehttp://wiki.ubotstudio.com/wiki/Define http://wiki.ubotstudio.com/wiki/Return Includehttp://wiki.ubotstudio.com/wiki/Include Quote Link to post Share on other sites
Sebastian Rooks 3 Posted March 8, 2016 Author Report Share Posted March 8, 2016 Thank you Pash. That's a great answer, and it should be enough.My problem is that I've already read those, watched that excellent video, and worked through TJ's example. I can make that work, but I can't quite apply it to my own scripts. Also, most of my defines involve lists and tables. Surely that's part of my problem.Here's an example of the shortest, cleanest define that I haven't yet make work via include (but it works fine when it's in the bot together) I feel like if someone can help me figure out how to get this one running, I can apply those lessons to the bigger ones that I have. define count hashtag duplications(#URLS Count) { set(#URLS Count,#URLS Count,"Global") clear list(%hashtags Original) add list to list(%hashtags Original,%hashtags,"Don\'t Delete","Global") clear list(%hashtags Unique) add list to list(%hashtags Unique,%hashtags Original,"Delete","Global") clear table(&Hashtags Count) set(#URLS Count,0,"Global") loop($list total(%hashtags Unique)) { set table cell(&hashtags Count,#URLS Count,0,$COUNT DUPLICATES($list item(%hashtags Unique,#URLS Count))) set table cell(&hashtags Count,#URLS Count,1,$list item(%hashtags Unique,#URLS Count)) increment(#URLS Count) } } comment("used by hashtag searcher") define $COUNT DUPLICATES(#DEF URL) { set(#URL Count,0,"Global") set(#URLS Original,0,"Global") loop($list total(%hashtags Original)) { if($comparison($list item(%hashtags Original,#URLS Original),"=",#DEF URL)) { then { increment(#URL Count) } else { } } increment(#URLS Original) } return(#URL Count) } I found this somewhere on this forum, and works perfectly for my needs. (I wish I could remember who to credit). It's also the shortest and cleanest example of what I don't understand how to make work via include. If someone can explain this, it'd give me a pretty big boost. I've learned a lot if my first two months, and I feel like learning to effectively incorporate defines into my bots will allow me to de-spaghetify my sprawling code and take me to another level. So I'll spend as much time and energy trying to understand as it takes. Thanks again, everyone. Quote Link to post Share on other sites
jason 101 Posted March 8, 2016 Report Share Posted March 8, 2016 Just to clarify - Is the problem that you don't know the best method for organizing, or that one of the methods you're using isn't functioning properly? Quote Link to post Share on other sites
Sebastian Rooks 3 Posted March 8, 2016 Author Report Share Posted March 8, 2016 Hi Jason, I think the problem is that I don't understand the best method of organizing, or how to apply it to my multi tabbed bot that's sprawling out of control. I like the idea of using Include and Define, but my Defines use lists and tables. I don't know how to make that work. Can that work? Thanks Quote Link to post Share on other sites
Bot-Factory 602 Posted March 9, 2016 Report Share Posted March 9, 2016 Hi Jason, I think the problem is that I don't understand the best method of organizing, or how to apply it to my multi tabbed bot that's sprawling out of control. I like the idea of using Include and Define, but my Defines use lists and tables. I don't know how to make that work. Can that work? Thanks Hello. It depends on where you want to handle your lists and tables.If you store data there that is needed in multiple places of your bot, you can use global lists and tables. There is no problem of changing and altering a list or a table from within a define. You can have one define to create the data, one to update it and one to save it to a file for example. The only thing where you have to be careful is when you work with multithreading. I also recommend that you take a look at the free "Large Data" plugin. This is an awesome and must have plugin. It helps you to handle tables and lists on a much bigger scale. And gives you more flexibility. And you can use it much easier with multithreading as well. Kindest regardsDan 1 Quote Link to post Share on other sites
Brutal 164 Posted March 9, 2016 Report Share Posted March 9, 2016 Sebastian The problems come from plugins in your defines. Some 3rd party plugins simply break the INCLUDE feature. There really isn't any work around unless the plugin dev. will fix his stuff to work properly with the Include command. You can isolate the offending plugin by systematically removing the defines that use the plugins ... It's a bit trail and error but you can isolate each one. 1 Quote Link to post Share on other sites
Sebastian Rooks 3 Posted March 12, 2016 Author Report Share Posted March 12, 2016 Thank you guys for your help! My problem ended up being that I made erroneous assumptions about what my problem was. I couldn't get my defines to work, I assumed it was a problem with parameters, because that's the part I though I didn't understand. The problem in my case (in case any newcomer makes a mistake like this) is that because I worked backwards...creating unruly monster bots and then trying to clean them up by exporting defines to a new .ubot file I have to change every occurrence of a custom command to reflect it's new path.(completely obvious to most of you, I'm sure) But I didn't realize it because the nodes look the same even though the code changes. So, for example: random wait time(2, 5) becomes run command("define - random wait time - find table cell - add data to table","random wait time",2, 5) Looks like I've got a long day ahead of me... Quote Link to post Share on other sites
sbm128 12 Posted December 9, 2017 Report Share Posted December 9, 2017 sorry to dredge up an old thread - I understand the difference between function and commands, but I'm still kind of unclear on parameters. Not sure if i can/should use them to send or receive data, when the proper time to use them might be (as opposed to just using a "Set" value within a simple command define to retrieve data) and so on.. The documentation on it is pretty miserable, and this is only one of a few threads that even approach define parameters (great video btw, cleared up the difference between command and function defines very simply and quickly!), so any help, advice, best practices or examples would be greatly appreciated. 1 Quote Link to post Share on other sites
HelloInsomnia 1103 Posted December 11, 2017 Report Share Posted December 11, 2017 sorry to dredge up an old thread - I understand the difference between function and commands, but I'm still kind of unclear on parameters. Not sure if i can/should use them to send or receive data, when the proper time to use them might be (as opposed to just using a "Set" value within a simple command define to retrieve data) and so on.. The documentation on it is pretty miserable, and this is only one of a few threads that even approach define parameters (great video btw, cleared up the difference between command and function defines very simply and quickly!), so any help, advice, best practices or examples would be greatly appreciated. I really like this question, and I'm going to try and make a video about it later to answer it because I think seeing some examples would be a big help. 1 Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted December 11, 2017 Report Share Posted December 11, 2017 sorry to dredge up an old thread - I understand the difference between function and commands, but I'm still kind of unclear on parameters. Not sure if i can/should use them to send or receive data, when the proper time to use them might be (as opposed to just using a "Set" value within a simple command define to retrieve data) and so on.. The documentation on it is pretty miserable, and this is only one of a few threads that even approach define parameters (great video btw, cleared up the difference between command and function defines very simply and quickly!), so any help, advice, best practices or examples would be greatly appreciated. on the second row is "Advanced Defines" http://network.ubotstudio.com/store/product-category/sources/ Could be useful to you. Regards,CD 1 Quote Link to post Share on other sites
HelloInsomnia 1103 Posted December 12, 2017 Report Share Posted December 12, 2017 sorry to dredge up an old thread - I understand the difference between function and commands, but I'm still kind of unclear on parameters. Not sure if i can/should use them to send or receive data, when the proper time to use them might be (as opposed to just using a "Set" value within a simple command define to retrieve data) and so on.. The documentation on it is pretty miserable, and this is only one of a few threads that even approach define parameters (great video btw, cleared up the difference between command and function defines very simply and quickly!), so any help, advice, best practices or examples would be greatly appreciated. Here is the video which hopefully will answer your questions, if you have any more feel free to ask: http://network.ubotstudio.com/forum/index.php/topic/21602-why-use-parameters-ubot-studio-parameters-tutorial/ Quote Link to post Share on other sites
doblej 0 Posted January 25, 2018 Report Share Posted January 25, 2018 Sorry, my english is very bad.... I found error problems when a include load a define and this define call another define. Ubot show me " The given key was not present in the dictionary. Source: resources -> define -> run command " Quote Link to post Share on other sites
HelloInsomnia 1103 Posted January 25, 2018 Report Share Posted January 25, 2018 Sorry, my english is very bad.... I found error problems when a include load a define and this define call another define. Ubot show me " The given key was not present in the dictionary. Source: resources -> define -> run command " Open a new thread and post your code and somebody may be able to help. 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.