Difference between revisions of "Create scripts"

From StealthBot Wiki Backup
Jump to: navigation, search
(Created page with 'Scripts are standard Visual Basic Scripting Edition ("VBScript") files, which are loaded by the bot. In this tutorial, we will explore how to begin creating a [[…')
 
m (1 revision imported)
 
(No difference)

Latest revision as of 08:20, 1 December 2017

Scripts are standard Visual Basic Scripting Edition ("VBScript") files, which are loaded by the bot. In this tutorial, we will explore how to begin creating a StealthBot script.

Script header

For StealthBot to know what to do with them, you store information about your script in the following way, placed at the top of your script (you may put comments above these lines):

Script("Name") = "MyScript"
Script("Author") = "MyName"
Script("Major") = 1
Script("Minor") = 0
Script("Revision") = 0

If you load this code (as is) by placing it in the Scripts\ folder under your StealthBot folder, your StealthBot will load it! You will now see a menu item under the Scripting menu called "MyScript" with the sub-items "Enabled" and "View Script". You can now use the sdetail internal command like so:

/sdetail MyScript
    MyScript v1.0 Revision 0 by MyName

Breakdown:

  • Script("Name") stores the name of your script. It can be anything that you can put in the string.
  • Script("Author") should store your name, the author of the script.
  • Script("Major") is the major version number. It should be incremented on major changes to your script.
  • Script("Minor") is the minor version number. It should be incremented on minor changes to your script.
  • Script("Revision") is the revision number. It should be incremented on even smaller changes.

More information on how to use the Script header: the Script object.

Script events and functions

Now, place events in your script and use script functions to make the bot do things when events occur!

For example, the standard Hello World script:

Script("Name") = "HelloWorld"
Script("Author") = "Ribose"
Script("Major") = 1
Script("Minor") = 0
Script("Revision") = 0

Sub Event_Load()
    AddChat vbGreen, "Hello, world!"
End Sub

Sub Event_LoggedOn(Username, Product)
    AddQ "Version " & GetBotVersionNumber() & " at your service!"
End Sub

Breakdown:

  • Sub Event_Load() begins the event load subroutine, which is called when the script loads.
  • AddChat vbGreen, "Hello, world!" calls the SSC function AddChat() to print the string "Hello, world!" to your chat window in green.
  • End Sub ends the subroutine.
  • Sub Event_LoggedOn(Username, Product) begins the event logged on subroutine, which is called when you log on to Battle.net, with your username and product provided in the arguments.
  • AddQ "Version " & GetBotVersionNumber() & " at your service!"

This line combines three strings together: the string "Version ", the result of the SSC function GetBotVersionNumber(), and the string " at your service!", then it calls the SSC function AddQ() to add the string to the chat queue.

  • End Sub ends the subroutine.

See also