Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Pandemic's Script Creator: Miner Tutorial, Part 2


    Pandemic

    Recommended Posts

    Hello everyone, this is the second of a short series of tutorials for Pandemic's Script Creator (PSC), a tool for making your own scripts without any programming.

    You find part one here, which should be followed before starting with Part 2 as we'll be building directly on the script we've started in the previous part.

    Prerequisites

    • You'll need access to Pandemic's Script Creator, which you can get a free 8 hour trial from the SDN.
    • Have the same script we worked on in Part 1 loaded up

    The Script

    Let's start with what the script should be able to do by the end of Part 2:

    • We want to show a GUI to let the user choose if they want to power mine or bank at the nearest bank
      • Since all great scripts support QuickStart, we also want to support QuickStart parameters to avoid needing manual input from the GUI
    • We'll need to add some logic to handling banking, and extend our mining task to let it walk back once it's done banking

    Getting Started

    To begin, we'll need to load the previous script, which you can download here and load into the editor:

    TutorialPart1.json

    Asking for User Input

    We're wanting to make the script to be able to run in one of two modes, a bank mode which will bank the ore or a powermine mode which would drop them.

    To figure out what the user wants, we're going to ask them on the very first loop of our script:

    Let's break down what we just did:

    1. We added a If never fired before action, which will only run the inside actions once per script run, which is what we want when asking for user input
    2. We then set a Variable "Mode" to the user's input of the choice of options (Bank or Powermine), which we'll use later to control how our script runs
    3. After that, we started the script and chose an option, which then sets that Variable while the script is running, which we show by checking the Variable Panel by selecting our script's main action.

    Variables are just a way of storing just about anything and being able to retrieve and/or update it later by name. They are extremely useful for controlling the flow of our script, which is what we need to do :)

    Here are a few examples of Variables and how you might use them (this is a very limited list, you can do much, much more with Variables):

    • A Variable called Count which you could use to track how many times you've banked, increasing it each time and drawing it on your paint
    • A Variable called Enemy which you could set to a specific NPC in game to make sure you're attacking the same one between eating, or check their health periodically
    • A Variable called Username that you could generate from a big list of words to make up a username to use on tutorial island

    QuickStart Support

    Now that we have our Variable "Mode" set via a GUI, we'll want to make sure we support QuickStart also in case you want to automate that.

    PSC already supports QuickStart by turning all params into Variables automatically, so we're half way done already. For example, when we QuickStart this script, our params section of the CLI command would look like this to set the Variable "Mode" to "Bank":

    -params "full/path/to/our/script.json" Mode Bank

    But if we did that now, it would set the Variable correctly, but still ask for the user's input, which isn't ideal.

    To fix this, we'll replace our If never fired before action with a If variable is not set action to make sure the Mode variable doesn't exist:

    As you can see, after replacing the action it still works as expected, with the bonus of it not asking if we set the Mode variable via QuickStart like mentioned above.

    Banking and Powermining

    Now that we have the Mode variable set, we need to change what we do when our inventory is full. To do that, we'll use the If variable matches action inside the If inventory is full action to check if it's set to "Bank", and if it is we'll open the nearest bank and deposit everything except our pickaxe. We'll also use the Else action at the same level that we have our If variable matches action on, which will only run the inner actions (drop all matching items in this case) when the last action isn't true (so if our variable isn't "Bank", those actions will run instead):

    Now there's only one problem: when our inventory gets full we'll walk to the bank and deposit everything, and then be stuck because we can't find any Copper rocks. We need a way to walk back to where we were mining, but how could we do it considering we could have started the script anywhere? Hopefully you said we could use a Variable, because you'd be right :D

    If we successfully Mine a Copper rock, we should update a Variable called "Rock Tile" to our player's current position:

    As you can see, after we click on the Rocks, we set the Variable "Rock Tile" to our player's tile, which we'll use to walk to if we're ever far away from it:

    Let's break it down:

    1. At the start of our script, we added a If variable is set action to make sure we've set our Rock Tile variable before trying see if we're far from it
    2. We then checked if we were further than 10 tiles away from our tile with an If distance to tile is action
      1. For the Tile the action asked for, notice how we're inserting the value of our Rock Tile variable with the "var(Rock Tile)" instead of using a hardcoded Tile from the game
      2. var(Variable Name) is a field command that will be replaced with the current value of a variable with the name
      3. There are a number of field commands (like expGain that we used in the last part), you can find them all in our Discord
    3. Then we just walk towards the tile with a Walk towards a tile action, and finally we added a bit of sleeping for 1.5 to 2.5 seconds to avoid spam clicking too often

    and that's it!

    We're Done!

    If you've followed along, the final script should look something like this:

    TutorialPart2.json

    I hope you found this tutorial helpful, and if not, thanks for reading it anyways :)

    If you have any questions or comments, feel free to ask below or join our helpful community Discord server:

    https://discord.gg/6JMkwvYrA2

    And again, you can get a trial of Pandemic's Script Creator here or purchase it on the store here (lifetime version can be found here instead).

    Thanks!

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.