ProjectPact Posted April 6, 2021 Share Posted April 6, 2021 (edited) Script Writing Guide & FAQ: By: ProjectPact Checkout Script Factory 2.0 to gain access to tools and resources to save you time on developing and debugging scripts What is a Method Number? When you add a new Check or Action to the script, you may notice something that says ‘[x]:’ (where ‘x’ could be any number) at the beginning of the description. The number inside the brackets refers to the ‘Method Number’. The Method Number is unique because it connects Checks (anything that contains ‘->’ in the description) to an Action (anything that does NOT contain ‘->’ in the description). You may combine multiple Checks to a single Method Number. Checks control the function of the Action(s). If any of the Checks fail for a specific Method Number, the Action(s) for that Method Number will not be performed. You may put multiple Actions within a single Method Number, however the script will loop through ALL Checks prior to running any Actions, so you may not do something like: Check, Check, Action, Check, Action in a single Method Number, because it would actually read as: Check, Check, Check, Action, Action. A simple example may be seen below on the proper way to setup a script with Checks and Actions. Example: [0]: -> If inventory is not full [0] -> If RS20bject exists - [Tree] [0]: Interact With RS2Object - [Tree, Chop down] In the example there are two checks present, and a single action. Notice all three lines contain ‘[0]’, which states that the Method number for the following example is 0. The script makes sure that the inventory is not full, and that the RS2Object (a Tree in this case) exists before trying to interact with it. The script should automatically make the next line following the Action a new Method Number, 1. How may I edit a script with Method Numbers? When editing a script, make sure you are setting the Method Number accordingly. The script will automatically try to guess the Method Number, but this is not always accurate. You may edit a line's Method Number by right clicking and selecting, "Edit Method Number [X]". All you need to do is remember that every Action needs its own unique Method Number. When adding a method, you don't have to worry about Method Numbers going in exact chronological order ([1], [2], [3]...etc) even though it is good practice to make them... but you still have to ensure that Method Numbers go in ascending order. If not, the script will not save properly. Remember, you may always add/edit/delete a line in case you need to. How do I edit scripts? To edit a script, make sure you select the “Rearrange” checkbox on the bottom left corner of the GUI. If you do not check this box, you will not be able to drag and drop Checks or Actions. If you right click anywhere on your code, you will see a menu appear that has a lot more options for you to use. Alternatively, you make access another option menu that contains different options by selecting “Script” on the top left corner of the GUI, then going to “Edit”. How do you use OR statements? OR statements are a type of check that allows you to check for multiple possibilities for an Action to run. It reduces the need to create multiple separate methods for Checks that would use the same Action. You may use multiple OR statements within a single Method Number. Below, you will find an example of how to properly use an OR statement. How do you use ELSE statements? ELSE statements are considered a type of Action that will run an alternate action if a Check fails. You should only use one ELSE statement per Method Number. Below, you will find an example of how to properly use an ELSE statement. What is a Boolean variable? A boolean is simply a true or false statement. They are very powerful in your scripts to keep up with information if you use them correctly. Using one can reduce the amount of checks required in your script, as well as make it easier to call in multiple methods. Download Example Here How do #containsPartialText methods work? The text you search for should either be at the beginning, or the end of an item. You may not search for something in the middle of an item's name. Sort by: When you search for an item, you may sort the item to either get the highest, or lowest value. In this example, lets say in my inventory I have a "Stamina potion(4)" and a "Stamina potion(1)". Sort by Highest: If I search for text containing "Stamina potion", and sort by "Highest", the bot will find "Stamina potion(4)". Sort by Lowest: If I search for text containing "Stamina potion", and sort by "Lowest", the bot will find "Stamina potion(1)". Text placement: Depending on where you select the text placement, either "Starts with" or "Ends with", the script will find item(s) with the desired text. Starts with: "Stamina potion" will find all "Stamina potion(4)", "Stamina potion(3)", "Stamina potion(2)", "Stamina potion(1)" Ends with:"ore" will find all "Copper ore", "Iron ore", "Gold ore"...etc How do I debug issues with my script? Script Factory has a built in debugging system that helps let you know what is failing so you can find issues much faster. On Script Factory, go to Script->Settings->Print to logger. What this will do is print lines to OSBot's debugger to display what is passing, or failing. Now, you need to open up OSBot's debugger to see the printed information. To do that, go to OSBot's client and hit Settings->Toggle logger. A new window should appear where you can see the printed information from Script Factory. If the logger is going too fast, you may always stop your script in Script Factory from running so you can look through the logs. REMEMBER: When you are not debugging a script, disable the 'Print to logger' option in Script Factory! This wastes a lot of resources and slows down script performance/load times. Where are my local scripts saved? Windows: "C:\User\OSBot\Data\ProjectPact\OSRS Script Factory\Local Scripts" Mac: "User\OSBot\Data\ProjectPact\OSRS Script Factory\Local Scripts" How do you run scripts via CLI? Script ID's: Script Factory 2.0: 1214 *Script Factory 1.0: 1097 *Script Factory Expansion: 1144 *Script Factory Pro Edition: 1163 Script Factory Encryptor: 1164 (anything with a '*' is no longer available for purchase) New CLI args: name=SCRIPT_NAME popups=TRUE_OR_FALSE editor=TRUE_OR_FALSE queue=TRUE_OR_FALSE * after each arg, place a underscore "_" Example: -script 1097:name=script1_popups=false_editor=true_queue=false Script Factory has a built in args generator within that can automatically create all your options, as well as more options that aren't represented above! If there is something in particular you would like to see added to the list, please let me know down below! Edited October 3, 2023 by ProjectPact 2 Quote Link to comment Share on other sites More sharing options...
bd009923 Posted December 11, 2022 Share Posted December 11, 2022 plese help me in osbot account making Quote Link to comment Share on other sites More sharing options...
acethareaper Posted December 28, 2022 Share Posted December 28, 2022 so i have 0 coding knowledge and have been fairly successful creating multiple script for anything from buying runes and automatically selling them on ge to fishing scripts that swap equipment and areas on certain unlocks etc.. there are a few things i dont understand what exactly they do one of which is thread eating. i see it mentioned by others and in verified scripts that ive downloaded to take a peek at and learn from but i have no clue what it does or how to use it. also im curious as to how i can read the state of a particular object. such as if a certain door is open or shut, or if a lever has been flipped, the water wheel in motherlode mine if it is turning or broken, etc. thank you in advance for taking the time to answer these questions im sure they would help alot of newbies like myself become better script creators through script factory and it is an absolutely amazing script hands down best one ive got i can do nearly anything with it. Quote Link to comment Share on other sites More sharing options...
ProjectPact Posted January 30, 2023 Author Share Posted January 30, 2023 Images have been added to the OP Quote Link to comment Share on other sites More sharing options...
Minara Posted February 1, 2023 Share Posted February 1, 2023 (edited) An example for user-input would be neat! How do we utilize script states? What does "thread" mean for things like thread eating & hopping? edit: (can we make our own thread arguments? Such as thread teleport at low hp?) Could we also have some example uses for strings & integers? Thank you! This is a very helpful tool ^.^ Edited February 1, 2023 by Crthrt Quote Link to comment Share on other sites More sharing options...
afasio77 Posted November 3, 2023 Share Posted November 3, 2023 how do i get the coomunity scripts? is there a repository? Quote Link to comment Share on other sites More sharing options...
ProjectPact Posted November 3, 2023 Author Share Posted November 3, 2023 51 minutes ago, afasio77 said: how do i get the coomunity scripts? is there a repository? Hi there! Yes! So once you load into Script Factory from the OSBot client, on the top right corner of the Script Factory GUI, you will see something called, "Script Network". If you click that, you will be able to download, save, and edit any scripts you would like to that are on the Script Network. They are all free and open source, built by the community. Quote Link to comment Share on other sites More sharing options...