Pandemic 2714 Share Posted December 5, 2023 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: stepone.mp4 Let's break down what we just did: 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 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 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: steptwo.mp4 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): stepthree.mp4 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 If we successfully Mine a Copper rock, we should update a Variable called "Rock Tile" to our player's current position: stepfour.mp4 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: stepfive.mp4 Let's break it down: 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 We then checked if we were further than 10 tiles away from our tile with an If distance to tile is action 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 var(Variable Name) is a field command that will be replaced with the current value of a variable with the name There are a number of field commands (like expGain that we used in the last part), you can find them all in our Discord 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! MaximusPrimo 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now