Creating Script Setups
The Right Way
Index
What's a Setup?
The Setup is where the user who downloads your script, or even yourself, will be able to configure the script, to make it suit his needs. You could add options to enable or disable specific hunting areas, specify custom behavior and much more; there are endless possibilities.
How it was done
If you come from previous bots, you are probably used to this kind of setup. If you don't, no worries, we won't be using it. Well, this has always been used, since NeoBot times, and it worked since then, but it put unnecessary stress on the end user and often caused unintended typing mistakes that would compromise the whole script.
![]()
Image taken from the internet.
How we are doing it
So, we thought of a way to make things easier, even more. And this is what we came up with:
![]()
Example built based on the image above.
How to build a Setup?
To build the setup, we'll have to work with a markup language called JSON. If you're not familiar with it, that's cool, take it easy, it's not that hard. Take a look at the code I used to build example above:
JSON Code:{ "type" : "group", "name" : "generalInfo", "text" : "General Information", "children" : [ { "type" : "lineedit", "name" : "account", "text" : "Account:", "description" : "Your account name.", "value" : "myaccount" }, { "type" : "lineedit", "name" : "password", "text" : "Password:", "description" : "Your account's password.", "value" : "mysecretpassword" }, { "type" : "lineedit", "name" : "charList", "text" : "Chars. List:", "description" : "The name of your characters, comma separated.", "value" : "John, Bob, Ann, Joe, Mary" }, { "type" : "checkbox", "name" : "relog", "text" : "Log on the next char", "description" : "Should the bot log on the next character once the current one finishes?", "value" : true } ] }, { "type" : "group", "name" : "otherOptions", "text" : "Other Options", "column" : 2, "children" : [ { "type" : "combobox", "name" : "vocation", "text" : "Vocation", "description" : "Which vocation should be chosen?", "items" : ["Knight", "Paladin", "Sorcerer", "Druid"] }, { "type" : "combobox", "name" : "weapon", "text" : "Knight Weapon", "description" : "If you chose Knight as vocation, which weapon type should be chosen?", "items" : ["Axe", "Sword", "Club"] }, { "type" : "combobox", "name" : "city", "text" : "City", "description" : "What city should be chosen?", "items" : ["Ankrahmun", "Edron", "Darashia", "Liberty Bay", "Port Hope", "Ab'Dendriel", "Carlin", "Thais", "Venore"] } ] }I believe it has a fairly simple syntax, so I won't take long describing it. Just remember to use " and not '.
OK, but where to I put that J
ASON thing?You put the JSON inside a place we call User Options, which is just stylish way to say setup. You can find it under Cavebot\Settings tab, on the bottom right corner. It's a button named Edit User Options.
![]()
OK, but how do I build that JSON thing?
Well, I'm glad you finally learned how to spell it correctly. We shall move on then: the Setup is based on widgets. A widget can be thought of as a setting in the setup. It's a text field, a checkbox, etc... Each widget has its functionality and we'll be going over every single one of them in this tutorial.
Group Widget
This is our main widget. It's inside it that we place all the other widgets.
Properties:
- type: The widget type; "group" in this case.
- name: The name of the widget. It's used to retrieve its current value.
- text: The title of the group box; if none is provided, name is used.
- description: The description to be displayed on info box; if none is provided, text is used.
- checkable: Whether the widget should be checkable; a checkbox will appear beside it and checking/unchecking enables/disables the groupbox and its children.
- column: The column the group box should be place on; 1 for first column, 2 for second.
- children: The widgets the group box will contain.
Examples:
![]()
JSON Code:{ "type" : "group", "name" : "groupName", "text" : "Title", "children" : [] }![]()
JSON Code:{ "type" : "group", "name" : "General Information", "checkable" : true, "children" : [ { "type" : "lineedit", "name" : "account", "text" : "Account:", "description" : "Your account name.", "value" : "myaccount" }, { "type" : "lineedit", "name" : "password", "text" : "Password:", "description" : "Your account's password.", "value" : "mysecretpassword" }, { "type" : "lineedit", "name" : "charList", "text" : "Chars. List:", "description" : "The name of your characters, comma separated.", "value" : "John, Bob, Ann, Joe, Mary" }, { "type" : "checkbox", "name" : "relog", "text" : "Log on the next char", "description" : "Should the bot log on the next character once the current one finishes?", "value" : true } ] }Line Edit Widget
This is one of the simplest widgets. It's basically a text field, in which you can input any text. It could be used to get the name of a special character, some backpacks for the setup or even a safelist, if handled correctly.
Properties:
- type: The widget type; "lineedit" in this case.
- name: The name of the widget. It's used to retrieve its current value.
- text: The label to be displayed beside the text field; if none is provided, name is used.
- description: The description to be displayed on info box; if none is provided, text is used.
- placeholder: The placeholder for the widget.
- value: The default value for the field.
Examples:
![]()
JSON Code:{ "type" : "group", "name" : "General Information", "children" : [ { "type" : "lineedit", "name" : "account", "text" : "Account:", "description" : "Your account name.", "value" : "myaccount" } ] }![]()
JSON Code:{ "type" : "group", "name" : "Cool Title", "children" : [ { "type" : "lineedit", "name" : "safelist", "text" : "Safe List:" } ] }Checkbox Widget
This one is pretty simple too. You're probably used to it in most websites/softwares, like on that "remember me" thing. It's useful for simple yes/no questions, like specifying if a special path to the hunt should be taken or if the bot should use a specific hunting strategy.
Properties:
- type: The widget type; "checkbox" in this case.
- name: The name of the widget. It's used to retrieve its current value.
- text: The label to be displayed beside the checkbox; if none is provided, name is used.
- description: The description to be displayed on info box; if none is provided, text is used.
- value: The default value for the field; true or false.
Examples:
![]()
JSON Code:{ "type" : "group", "name" : "General Information", "children" : [ { "type" : "checkbox", "name" : "dostuff", "text" : "Do some stuff?" } ] }![]()
JSON Code:{ "type" : "group", "name" : "Waddup", "children" : [ { "type" : "checkbox", "name" : "raphael", "text" : "Does Raphael rock?", "value" : true } ] }Combobox Widget
This is lets you choose an option from a few pre-specified options. This is good to let the user choose, let's say, a city as destination, a tool to be used as rope or even the backpack used.
Properties:
- type: The widget type; "combobox" in this case.
- name: The name of the widget. It's used to retrieve its current value.
- text: The label to be displayed beside the spinbox; if none is provided, name is used.
- description: The description to be displayed on info box; if none is provided, text is used.
- items: The list of the pre-specified options.
Examples:
![]()
JSON Code:{ "type" : "group", "name" : "General Information", "children" : [ { "type" : "combobox", "name" : "city", "text" : "City", "description" : "What city should be chosen?", "items" : ["Ankrahmun", "Edron", "Darashia", "Liberty Bay", "Port Hope", "Ab'Dendriel", "Carlin", "Thais", "Venore"] } ] }![]()
JSON Code:{ "type" : "group", "name" : "General Stuff", "children" : [ { "type" : "combobox", "name" : "vocation", "text" : "Vocation", "description" : "Which vocation should be chosen?", "items" : ["Knight", "Paladin", "Sorcerer", "Druid"] } ] }Spinbox Widget
This is the Line Edit Widget, but for integers. It's good for those situations were you only want to get numbers, like when asking for the amount of supplies to buy or with how much cap the script should leave the cave.
Properties:
- type: The widget type; "spinbox" in this case.
- name: The name of the widget. It's used to retrieve its current value.
- text: The label to be displayed beside the spinbox; if none is provided, name is used.
- description: The description to be displayed on info box; if none is provided, text is used.
- value: The default value for the field.
- prefix: The string to be prepended to the number.
- suffix: The string to be appended to the number.
- max: The maximum value that should be accepted; if none is provided, 100 is assumed.
- min: The minimum value that should be accepted; if none is provided, 0 is assumed.
- step: The step by which the up/down arrow should increase/descrease the value; if none is provided, 1 is assumed.
Examples:
![]()
JSON Code:{ "type" : "group", "name" : "General Information", "children" : [ { "type" : "spinbox", "name" : "age", "text" : "Age:", "suffix" : " years", "min" : 16, "value" : 18 } ] }![]()
JSON Code:{ "type" : "group", "name" : "Survey", "children" : [ { "type" : "spinbox", "name" : "grade", "text" : "Tutorial's Grade", "description" : "It's over nine thousand!", "min" : 9000, "max" : 10000, "value" : 9001 } ] }DoubleSpinbox Widget
This is exactly like Spinbox Widget, but for doubles; that is, numbers that have a fractional part. It's probably good for lots of stuff, but I really can't think of anything right now.
Properties:
- type: The widget type; "doublespinbox" in this case.
- name: The name of the widget. It's used to retrieve its current value.
- text: The label to be displayed beside the spinbox; if none is provided, name is used.
- description: The description to be displayed on info box; if none is provided, text is used.
- value: The default value for the field.
- prefix: The string to be prepended to the number.
- suffix: The string to be appended to the number.
- max: The maximum value that should be accepted; if none is provided, 100 is assumed.
- min: The minimum value that should be accepted; if none is provided, 0 is assumed.
- step: The step by which the up/down arrow should increase/descrease the value; if none is provided, 1 is assumed.
Examples:
![]()
JSON Code:{ "type" : "group", "name" : "General Math", "children" : [ { "type" : "doublespinbox", "name" : "pi", "text" : "PI", "description" : "Ya hungry?", "min" : 3.14, "max" : 3.14, "value" : 3.14 } ] }![]()
JSON Code:{ "type" : "group", "name" : "More Math", "children" : [ { "type" : "doublespinbox", "name" : "numbah", "text" : "Some Numbah", "min" : 0, "value" : 2.71 } ] }RangeSpinbox Widget
You're probably tired of this already, but this is exactly like Spinbox Widget, works for ranges; that is, it asks for two numbers instead of one. It's good for those situations where you need a maximum and minimum value, so you can make it random, like some waiting time before taking some action.
Properties:
- type: The widget type; "rangespinbox" in this case.
- name: The name of the widget. It's used to retrieve its current value.
- text: The label to be displayed beside the spinbox; if none is provided, name is used.
- description: The description to be displayed on info box; if none is provided, text is used.
- value: The default value for the field.
- prefix: The string to be prepended to the number.
- suffix: The string to be appended to the number.
- max: The maximum value that should be accepted; if none is provided, 100 is assumed.
- min: The minimum value that should be accepted; if none is provided, 0 is assumed.
- step: The step by which the up/down arrow should increase/descrease the value; if none is provided, 1 is assumed.
Examples:
![]()
JSON Code:{ "type" : "group", "name" : "General Information", "children" : [ { "type" : "rangespinbox", "name" : "waitSpawn", "text" : "Spawn Wait Time:", "description" : "How long should the bot stand still to wait for the creatures to respawn? It's a random value in the selected range.", "suffix" : " ms", "min" : 1000, "max" : 30000, "value" : 10000 } ] }![]()
JSON Code:{ "type" : "group", "name" : "Moar Info", "children" : [ { "type" : "rangespinbox", "name" : "ammoRefill", "text" : "Min. Ammo to Refill", "min" : 0, "max" : 100, "value" : 5 } ] }OK, but how do I read those values?
To read the widgets' values, we'll be using the getuseroption function. Simply use the name property you set for your widget to get the value. Something like this:
local raphaelRocks = getuseroption('raphael') if raphaelRocks then -- We know this is true print('Raphael, you rock!') else print('That\'s impossible!') end