3425
Comment:
|
3286
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
||<tablestyle="margin: 1em 1em 1em 0px; background-color: rgb(249, 249, 249); border-style: solid; border-color: rgb(170, 170, 170); color: rgb(0, 0, 0); font-family: sans-serif; font-size: 13px; line-height: 19.5px; text-align: start; " tableclass="wikitable"style="border-style: solid; border-color: rgb(170, 170, 170); padding: 0.2em; background-color: rgb(242, 242, 242); ">Usage:||<style="border-style: solid; border-color: rgb(170, 170, 170); padding: 0.2em; ">ifgosub ( reference {operator} value ) label|| ||<style="border-style: solid; border-color: rgb(170, 170, 170); padding: 0.2em; background-color: rgb(242, 242, 242); ">Example:||<style="border-style: solid; border-color: rgb(170, 170, 170); padding: 0.2em; ">ifgosub ( m_city.cityManager.resource.stone.amount > 250000 ) CheckATT|| |
||<tablebgcolor="#F9F9F9" tablestyle="margin:1em 1em 1em 0px;border-style:solid;border-color:rgb(170, 170, 170);color:rgb(0, 0, 0);font-family:sans-serif;font-size:13px;line-height:19.5px;text-align:start; " tableclass="wikitable"#F2F2F2 style="border-style:solid;border-color:rgb(170, 170, 170);padding:0.2em; ">Usage: ||<style="border-style:solid;border-color:rgb(170, 170, 170);padding:0.2em;">ifgosub ( reference {operator} value ) label || ||<#F2F2F2 style="border-style:solid;border-color:rgb(170, 170, 170);padding:0.2em; ">Example: ||<style="border-style:solid;border-color:rgb(170, 170, 170);padding:0.2em;">ifgosub ( m_city.cityManager.resource.stone.amount > 250000 ) CheckATT || |
Line 6: | Line 7: |
Using [[Variables]], this script command allows you powerful access to manage your account, cities, heroes, and armies with precision. | Using [[References]], this script command allows you powerful access to manage your account, cities, heroes, and armies with precision. |
Line 8: | Line 9: |
In the following example, the bot will first check if your stone in the city is over 250k, and if so jump to label CheckATT. In label CheckATT the bot will further check if you have over 250k wood in the city, and if so jump to label UpATT. In label UpATT, the bot will build 250 archer towers and return to the label that called it (CheckATT). Once back in CheckATT it has nothing else to check or perform, so it returns back to the original start of the script and moves to the next line. | In the following example, the bot will first check if your stone in the city is over 250k, and if so jump to label CheckATT. In label CheckATT the bot will further check if you have over 250k wood in the city, and if so jump to label UpATT. In label UpATT, the bot will build 250 archer towers and return to the label that called it (CheckATT). Once back in CheckATT it has nothing else to check or perform, so it returns back to the original start of the script and moves to the next line. |
Line 10: | Line 11: |
This next line is going to check if your city has over 150k iron, and if so jump to label !CheckTrain. Once in !CheckTrain it will check if your city has over 150k wood, and if so jump to label !TrainTroops. In label !TrainTroops the bot will queue 250 archers with hero Bubba, 4 times, then return to label !CheckTrain. With nothing more to do in !CheckTrain, it will return back to your original script and move to the next line, which will tell the bot to sleep randomly from 0 to 3000 seconds and then loop back to line 1. | This next line is going to check if your city has over 150k iron, and if so jump to label !CheckTrain. Once in !CheckTrain it will check if your city has over 150k wood, and if so jump to label !TrainTroops. In label !TrainTroops the bot will queue 250 archers with hero Bubba, 4 times, then return to label !CheckTrain. With nothing more to do in !CheckTrain, it will return back to your original script and move to the next line, which will tell the bot to sleep randomly from 0 to 3000 seconds and then loop back to line 1. |
Line 14: | Line 15: |
{{{ | . {{{ |
Line 22: | Line 23: |
gosubreturn | return |
Line 26: | Line 27: |
gosubreturn | return |
Line 31: | Line 32: |
gosubreturn | return |
Line 35: | Line 36: |
gosubreturn | return |
Line 38: | Line 39: |
As with [[Gosub]], do not forget the GosubReturn at the end of each subroutine. | As with [[Gosub]], do not forget the [[Return]] at the end of each subroutine. |
Line 40: | Line 42: |
CategoryAllScripts CategoryGeneralScripts | ---- ScriptControlStructures |
Usage: |
ifgosub ( reference {operator} value ) label |
Example: |
ifgosub ( m_city.cityManager.resource.stone.amount > 250000 ) CheckATT |
Like it's counterpart Gosub, IfGosub allows you to jump to a label subroutine elsewhere in the script, perform the actions there, and then return to where it left off in the current script. The difference is that this one allows you to check a conditional statement before deciding whether to jump to the subroutine or move on to the next line.
Using References, this script command allows you powerful access to manage your account, cities, heroes, and armies with precision.
In the following example, the bot will first check if your stone in the city is over 250k, and if so jump to label CheckATT. In label CheckATT the bot will further check if you have over 250k wood in the city, and if so jump to label UpATT. In label UpATT, the bot will build 250 archer towers and return to the label that called it (CheckATT). Once back in CheckATT it has nothing else to check or perform, so it returns back to the original start of the script and moves to the next line.
This next line is going to check if your city has over 150k iron, and if so jump to label CheckTrain. Once in CheckTrain it will check if your city has over 150k wood, and if so jump to label TrainTroops. In label TrainTroops the bot will queue 250 archers with hero Bubba, 4 times, then return to label CheckTrain. With nothing more to do in CheckTrain, it will return back to your original script and move to the next line, which will tell the bot to sleep randomly from 0 to 3000 seconds and then loop back to line 1.
If at any point in the script or any subroutine, one of the checks had failed then the bot would not jump to that subroutine, and would instead move to the next line. For example, if at the very first line you did not have 250k+ stone, the bot would have not jumped to label CheckATT but would instead have moved to line 2 and checked for 150k+ iron. If that failed also, then the bot would have slept until it was time to check again for resources.
ifgosub ( m_city.cityManager.resource.stone.amount > 250000 ) CheckATT ifgosub ( m_city.cityManager.resource.iron.amount > 150000 ) CheckTrain sleep rnd:3000 loop 0 // label CheckTrain ifgosub ( m_city.cityManager.resource.wood.amount > 150000 ) TrainTroops return // label CheckATT ifgosub ( m_city.cityManager.resource.wood.amount > 250000 ) UpATT return // label TrainTroops train arch:250 Bubba repeat 4 return // label UpATT walldefense archertowers 250 return
As with Gosub, do not forget the Return at the end of each subroutine.