johnwalton 12 Posted August 25, 2018 Report Share Posted August 25, 2018 Hello,i'm making data driven, decision making bots and sometimes i find myself nesting tons of 'Qualifiers' and it looks messy and there's got to be a better way. For example i just nested 8 '$boths' in an 'IF', each with it's own '$comparison'. Is there an advanced qualifier or advanced data processing plugin out there? If someone knows a plugin with this that'd be great =)Thanks, Quote Link to post Share on other sites
AtmoPress 14 Posted August 25, 2018 Report Share Posted August 25, 2018 (edited) Perhaps you could use $eval or run python ($run python with results) to execute some of that logic in Javascript or Python, respectively? Edit: Just noticed you're on Professional. Python is in developer edition only (I believe). Edited August 25, 2018 by SEO 1 Quote Link to post Share on other sites
UBotBuddy 331 Posted August 25, 2018 Report Share Posted August 25, 2018 As long as you properly and thoroughly test your logic you should not have any issues. Buddy Quote Link to post Share on other sites
johnwalton 12 Posted August 26, 2018 Author Report Share Posted August 26, 2018 Thank you for the responses. Just got Dev version it's great.Will check out your recommendation. Quote Link to post Share on other sites
AtmoPress 14 Posted August 26, 2018 Report Share Posted August 26, 2018 Thank you for the responses. Just got Dev version it's great. Will check out your recommendation.You're welcome. Good luck! Quote Link to post Share on other sites
Sanjeev 46 Posted August 28, 2018 Report Share Posted August 28, 2018 i find myself nesting tons of 'Qualifiers' and it looks messy and there's got to be a better way. For example i just nested 8 '$boths' in an 'IF', Ubot supports using 'OR' 'AND' as qualifiers too. You can add as many as you wish on a single if statement. check out this video -http://www.screencast.com/t/L7UR89vJQaSV 1 Quote Link to post Share on other sites
HelloInsomnia 1103 Posted September 1, 2018 Report Share Posted September 1, 2018 Here's a basic example of some code that could quickly get out of control. You have the first option with the nested both statements which is something that is easy to edit and see visually but quickly gets out of control and in the end is probably not that readable. Then there is option #2 which is not as easy to edit but is much more readable and so in small cases this is probably the best option. Then there is option #3 which is most cases is the best option. Create a function that is named well and have it return true or false. That way when you read the code you don't have to figure out what it's doing instead you read the name and the name tells you what it's doing. This kind of thing will help to avoid spaghetti code. And if you ever have to modify that function you can go in and see its pretty straightforward and easy to understand because everything is separated out. set(#x,$rand(1,100),"Global") set(#y,$rand(1,100),"Global") set(#z,$rand(1,100),"Global") comment("Option #1") if($both($both($comparison(#x,">",50),$comparison(#y,">",50)),$comparison(#z,">",50))) { then { alert("yes {#x}, {#y}, {#z}") } else { alert("no {#x}, {#y}, {#z}") } } comment("Option #2") if($comparison(#x,">",50) AND $comparison(#y,">",50) AND $comparison(#z,">",50)) { then { alert("yes {#x}, {#y}, {#z}") } else { alert("no {#x}, {#y}, {#z}") } } comment("Option #3") if($ArePointsOverFifty(#x, #y, #z)) { then { alert("yes {#x}, {#y}, {#z}") } else { alert("no {#x}, {#y}, {#z}") } } define $ArePointsOverFifty(#x, #y, #z) { if($comparison(#x,">",50)) { then { } else { return("false") } } if($comparison(#y,">",50)) { then { } else { return("false") } } if($comparison(#z,">",50)) { then { } else { return("false") } } return("true") } 1 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.