• My Pages
  • Comments
  • Add Link
  • Subscribe
  • Subscribe User
  • Edit (Text)
  • Rename Page
  • Copy Page
  • Load Page
  • Save Page
  • Delete Page
  • Attachments
  • Check Spelling
  • Diffs
  • Info
  • Revert to this revision
  • XML
  • Render as Docbook
  • Print View
  • Raw Text
  • Delete Cache
  • Like Pages
  • Local Site Map
  • Remove Spam
  • Package Pages
  • Sync Pages
    • Diff for "Scr1ptingForDummies"
    Differences between revisions 10 and 25 (spanning 15 versions)
    Revision 10 as of 2012-09-18 17:21:09
    Size: 5398
    Editor: Inanna
    Comment:
    Revision 25 as of 2013-06-02 18:13:41
    Size: 7614
    Editor: Inanna
    Comment:
    Deletions are marked like this. Additions are marked like this.
    Line 1: Line 1:
    All of the following can be found individually in the various script description pages, but for those that need it more in a flowing.. do this.. then that.. then some of this.. layout, this page is for you. Note that the text in blue are links to the script command page to explain it in better detail. ## page was renamed from ScriptingForDummies
    Scripting allows you to enter commands to the bot that will be performed immediately line by line, as opposed to goals which are gradually worked towards. For instance, the directive'' troop a:5000'' in the goals window tells the bot to build archers until you have 5000 then move to the next goal. If you already have 5000 or more archers, it is disregarded. The script command'' train a:5000'' will immediately queue 5000 archers in your barracks regardless of how many you have already, provided of course you have the population and resources needed.
    Line 3: Line 4:
    To begin, a script in !NeatBot is just a command to tell the bot to do something "now" as opposed to goals which tell the bot to "work towards this finish line". A script can be as simple as: The Script window is similar to the Goals window, and is found by selecting the Script tab on the upper left hand window. There are 10 individual script 'saves' per city, allowing you to build up to 10 command sets per city, that will be saved (provided you select the save button) along with your goals. Each script save is selected by way of the Load button. Scripts are executed from the top down, beginning at the line number specified in the Run box. If no number is entered, or the number is greater than the number of lines in the script, you can make the script begin at line #1 by checking ''Always start scripts line 1'' in Global Settings.
    Line 5: Line 6:
     {{{ The commands available give you the ability to perform all of the the same functions the bot works towards in the goals window, as well as add to or alter those goals. Any goal can be used in the script window, for example "config npc:5" typed in the script window will set your bot to farm npcs up to lvl 5 just as it would in the goals window. Note that goals modified or added in the script window will not be reflected in the goals window, or saved with them. Scripts, however, give you the ability to do so much more than goals are capable of.

    All of the following can be found individually in the various script description pages, but for those that need it more in a flowing.. do this.. then that.. then some of this.. layout, this page is for you. Note that the text in blue are links to the script command page to explain that particular script command in better detail.

    To begin, a script can be as simple as:

     . {{{
    Line 11: Line 18:
     {{{  . {{{
    Line 18: Line 25:
     {{{  . {{{
    Line 26: Line 33:
     {{{  . {{{
    Line 28: Line 35:
    1. sleep @:10:00:00 1: sleep @:10:00:00
    Line 31: Line 38:
    2. ifgoto ( m_city.cityManager.troop.scouter >= 1000000 ) scoutem  2: ifgoto ( city.troop.scouter >= 1m ) scoutem
    Line 33: Line 40:
    3. goto warnbuddy 3: goto warnbuddy
    Line 36: Line 43:
    4. label scoutem
    5. attack 111,222 any,!Goliath s:100k
    6. repeat 8
    7. stop
    4: label scoutem
    5: attack 111,222 any,!Goliath s:100k
    6: repeat 8
    7: stop
    Line 42: Line 49:
    8. label warnbuddy
    9. whisper Buddy I don't have enough scouts, I'm not sending the attacks!
    10. stop
    8: label warnbuddy
    9: whisper Buddy I don't have enough scouts, I'm not sending the attacks!
    Line 47: Line 53:
    Still with me? Brain explode yet? :) The //Blah blah blah lines are called [[Comments]]. That means I'm just sticking notes for you to read in there. The bot will ignore them completely. The [[Label]] lines are just little street signs in the bot to tell it where a certain group or section of lines starts, so that you can tell it to jump to them back and forth as needed. The [[Whisper]] line is just that, it whispers buddy your message. You hopefully already know what [[Attack]] and [[Sleep]] and [[Repeat]] are doing. Let's discuss the rest. Still with me? Brain explode yet? :) The //Blah blah blah lines are called [[Comments]]. That means I'm just sticking notes for you to read in there. The bot will ignore them completely. The [[Label]] lines are just little street signs in the bot to tell it where a certain group or section of lines starts, so that you can tell it to jump to them back and forth as needed. The [[Whisper]] line is just that, it whispers buddy your message. You hopefully already know what [[Attack]] and [[Sleep]] and [[Repeat]] are doing. [[Stop]] is pretty self-explanitory. It tells the script to stop right there and don't run anymore lines.
    Line 49: Line 55:
    In the above script you see [[Goto]] lines. These tell the bot to jump to a label. Remember I just said labels are like street signs? Well consider the goto command is driving directions. You also see an [[IfGoto]] line. This is exactly the same thing as goto, except it checks something first. Line 2 above reads something like this: "if (this stuff is true) then go to thislabelhere", or in this case, if you have at least 1mil scouts, then go to label scoutem. If an [[IfGoto]] or [[IfGosub]] line are not true, then they're skipped and the bot hops down to the next line. In our example above, if line 2 is not true (you have under 1mil scouts) then it will drop down to line 3 which tells it to go to label warnbuddy (so we can whisper Buddy instead). Let's discuss the rest...
    Line 51: Line 57:
    Now.. that big ole m_city.cityManager.troop.scouter thing probably looks pretty scary doesn't it? That's ok, it does to me too. Maybe after I write 10 more wiki's and use the bot another 2 years I'll memorize a couple of them. Until then, I'll use the [[References]] page like you should too. All those things do is check something on your account or in your city in a language the bot can understand. You don't have to remember them all, you can reference the list like I do. In the above script you see [[Goto]] lines. These tell the bot to jump to a label. Remember I just said labels are like street signs? Well consider the goto command as driving directions. You also see an IfGoto line. This is exactly the same thing as goto, except it checks if something is true first. Line 2 above reads something like this: "if (this stuff is true) then go to thislabelhere", or in this case, if you have at least 1mil scouts, then go to label scoutem. If an IfGoto or IfGosub line are not true, then they're skipped and the bot hops down to the next line. In our example above, if line 2 is not true (you have under 1mil scouts) then it will drop down to line 3 which tells it to go to label warnbuddy (so we can whisper Buddy instead). You can find all these helpful type commands in the [[ScriptControlStructures|Control Structures]] section.
    Line 53: Line 59:
    Ok.. so you have the above script but now Buddy tells you that he wants to do this same thing every day with a different target each day. Normally you would just scroll down and change 111,222 in the coordinates to a new target, but for the sake of teaching you, we're gonna do it using a variable. A variable is just temporary storage for some value, that you can use somewhere else. In this example at the very top of our script we're gonna set the variable. Now.. that big ole city.troop.scouter thing probably looks pretty scary doesn't it? That's ok, it did to me too for a very long time. Maybe after I write 10 more wiki's and use the bot another 2 years I'll memorize all of them. Until then, I'll use this wiki to find them like you should too. All those things ("[[ScriptObjects|Objects]]") do is check something on your account or in your city in a language the bot can understand. You don't have to remember them all, you can reference the list like I do.
    Line 55: Line 61:
     {{{ Ok.. so you have the above script but now Buddy tells you that he wants to do this same thing every day with a different target each day. Normally you would just scroll down and change 111,222 in the coordinates to a new target, but for the sake of teaching you, we're gonna do it using a simple replacement variable. This is just temporary storage for some value, that you can use somewhere else. In this example at the very top of our script we're gonna set it:

     . {{{
    Line 61: Line 69:
     {{{  . {{{
    Line 65: Line 73:
    Not so brain exploding, right? Replace the 111,222 in your attack line in the example script to %target% and you're all set. Now instead of scrolling down to the attack line each day you change targets, you can change it right up at the top nice and easily. Not so brain exploding, right? Replace the 111,222 in your attack line in the example script to %target% and you're all set. Now instead of scrolling down to the attack line each day you change targets, you can change it right up at the top nice and easily. Your bot still reads it as ''attack 111,222 any,!Goliath s:100k'' because it replaces %target% with the value as it reads it. The bot can do true variables as well, but since this is an intro to scripting, I won't scare you off with more than necessary ;)
    Line 67: Line 75:
    Ok so, you now know how to write a simple script and even one with complicated references and conditional statements in it. It's up to you to go from here and figure out how to write out that ultimate script you've been longing for.  Ok so, you now know how to write a simple script and even one with [[ScriptObjects|object references]] and [[ScriptControlStructures|conditional statements]] in it. It's up to you to go from here and figure out how to write out that ultimate script you've been longing for.

    Scripting allows you to enter commands to the bot that will be performed immediately line by line, as opposed to goals which are gradually worked towards. For instance, the directive troop a:5000 in the goals window tells the bot to build archers until you have 5000 then move to the next goal. If you already have 5000 or more archers, it is disregarded. The script command train a:5000 will immediately queue 5000 archers in your barracks regardless of how many you have already, provided of course you have the population and resources needed.

    The Script window is similar to the Goals window, and is found by selecting the Script tab on the upper left hand window. There are 10 individual script 'saves' per city, allowing you to build up to 10 command sets per city, that will be saved (provided you select the save button) along with your goals. Each script save is selected by way of the Load button. Scripts are executed from the top down, beginning at the line number specified in the Run box. If no number is entered, or the number is greater than the number of lines in the script, you can make the script begin at line #1 by checking Always start scripts line 1 in Global Settings.

    The commands available give you the ability to perform all of the the same functions the bot works towards in the goals window, as well as add to or alter those goals. Any goal can be used in the script window, for example "config npc:5" typed in the script window will set your bot to farm npcs up to lvl 5 just as it would in the goals window. Note that goals modified or added in the script window will not be reflected in the goals window, or saved with them. Scripts, however, give you the ability to do so much more than goals are capable of.

    All of the following can be found individually in the various script description pages, but for those that need it more in a flowing.. do this.. then that.. then some of this.. layout, this page is for you. Note that the text in blue are links to the script command page to explain that particular script command in better detail.

    To begin, a script can be as simple as:

    • attack 111,222 any,!Goliath s:100k

    This tells the bot to Attack 111,222 with any hero other than Goliath using 100k scouts. But let's say you want to attack it 8 times. Rather than typing the same line eight times, you can tell it to Repeat 8 times:

    • attack 111,222 any,!Goliath s:100k
      repeat 8

    Now let's say you want to plan this attack with your buddy, so you want the bot to wait till 10AM your time to begin executing the script. Rather than sitting around waiting to hit start, you could tell the bot to Sleep until a certain time:

    • sleep @:10:00:00
      attack 111,222 any,!Goliath s:100k
      repeat 8

    Of course, in the example above it would be better to use the landing time in the attack line itself so that the scouts arrive at 10 rather than get sent at 10.. but I'm just giving examples of how to use different types of script commands here. Now, let's say you want to make sure you have at least 1mil scouts on hand before your bot suicides 800k of them with your script, but since you won't be home when it launches at 10AM you need the bot to check and warn your buddy if it's not gonna attack. You can do all of this like so:

    • // First let's wait till it's 10AM before we check or do anything
      1: sleep @:10:00:00
      
      // This line is checking to see if you have 1mil+ scouts and if so goes to label scoutem
      2: ifgoto ( city.troop.scouter >= 1m ) scoutem
      // If you didn't go to label scoutem, then this next line will run instead
      3: goto warnbuddy
      
      // Here is label scoutem, you'll go here if you have 1mil+ scouts
      4: label scoutem
      5: attack 111,222 any,!Goliath s:100k
      6: repeat 8
      7: stop
      
      // Here is label warnbuddy, you'll go here if you don't have 1mil+ scouts
      8: label warnbuddy
      9: whisper Buddy I don't have enough scouts, I'm not sending the attacks!

    Still with me? Brain explode yet? :) The //Blah blah blah lines are called Comments. That means I'm just sticking notes for you to read in there. The bot will ignore them completely. The Label lines are just little street signs in the bot to tell it where a certain group or section of lines starts, so that you can tell it to jump to them back and forth as needed. The Whisper line is just that, it whispers buddy your message. You hopefully already know what Attack and Sleep and Repeat are doing. Stop is pretty self-explanitory. It tells the script to stop right there and don't run anymore lines.

    Let's discuss the rest...

    In the above script you see Goto lines. These tell the bot to jump to a label. Remember I just said labels are like street signs? Well consider the goto command as driving directions. You also see an IfGoto line. This is exactly the same thing as goto, except it checks if something is true first. Line 2 above reads something like this: "if (this stuff is true) then go to thislabelhere", or in this case, if you have at least 1mil scouts, then go to label scoutem. If an IfGoto or IfGosub line are not true, then they're skipped and the bot hops down to the next line. In our example above, if line 2 is not true (you have under 1mil scouts) then it will drop down to line 3 which tells it to go to label warnbuddy (so we can whisper Buddy instead). You can find all these helpful type commands in the Control Structures section.

    Now.. that big ole city.troop.scouter thing probably looks pretty scary doesn't it? That's ok, it did to me too for a very long time. Maybe after I write 10 more wiki's and use the bot another 2 years I'll memorize all of them. Until then, I'll use this wiki to find them like you should too. All those things ("Objects") do is check something on your account or in your city in a language the bot can understand. You don't have to remember them all, you can reference the list like I do.

    Ok.. so you have the above script but now Buddy tells you that he wants to do this same thing every day with a different target each day. Normally you would just scroll down and change 111,222 in the coordinates to a new target, but for the sake of teaching you, we're gonna do it using a simple replacement variable. This is just temporary storage for some value, that you can use somewhere else. In this example at the very top of our script we're gonna set it:

    • set target 111,222

    That's all, now "target" is a variable who's value is set to 111,222. Later in the script we can reference it by adding % in front and behind it, like so:

    • attack %target% any,!Goliath s:100k

    Not so brain exploding, right? Replace the 111,222 in your attack line in the example script to %target% and you're all set. Now instead of scrolling down to the attack line each day you change targets, you can change it right up at the top nice and easily. Your bot still reads it as attack 111,222 any,!Goliath s:100k because it replaces %target% with the value as it reads it. The bot can do true variables as well, but since this is an intro to scripting, I won't scare you off with more than necessary ;)

    Ok so, you now know how to write a simple script and even one with object references and conditional statements in it. It's up to you to go from here and figure out how to write out that ultimate script you've been longing for.


    CategoryHowTo

    Scr1ptingForDummies (last edited 2014-02-10 18:36:36 by Inanna)