-
Notifications
You must be signed in to change notification settings - Fork 0
Input Conditions
Input conditions tell the TASBot when to move from one input instruction to the next. Input conditions have the following structure:
{condition [args...]}
Each condition function accepts zero or more arguments. condition
may be a number, a string, a function, or a list of conditions. How each of these is interpreted is defined below:
Condition Type | Interpretation |
---|---|
number |
Passes after that number of ticks have elapsed |
string |
Passes on the tick when the built-in condition with that name has passed |
function |
Passes on the tick when the given function returns a truthy value. This function takes a table for its single argument. The first element will be the function itself, and the rest will be any additional arguments passed |
list of condition
|
Checks the first condition until it passes, then checks the next condition until it passes, and so on, until the last condition passes. At this point, this condition will pass. Note that this allows for multiple levels of nesting if you're in to that. |
In some cases, you may wish for the TASBot to continue making inputs while the game is paused, such as during an NPC dialogue or while the pause menu is open. It is possible to manipulate inputs in these conditions thanks to the bot's ability to override rawKeys
. However, normally, conditions aren't checked while the game is paused. This is to allow the user to navigate the pause menu during a run if needed.
If you want to manipulate inputs while paused, add a key named ignorePause
to the condition table that is set to true
. This setting is stateful; it will persist until you turn it off by setting it to false
in a later condition check. You should not enable this flag except when it is needed, as it prevents normal usage of pause menus while enabled.
For example, consider the following input instruction table:
return {
[0] = {
"run",{"mb",ignorePause=true},
"j",{1},
"rn",{64,ignorePause=false},
},
}
This instructs the TASBot to do the following in Section 0:
- Run right while holding up until triggering an NPC dialogue message (this message will pause the game, so
ignorePause
needs to be set). - Jump to immediately close the message (this unpauses the game).
- Run to the right for 64 ticks, then release control to the user (at this point, the game will no longer be paused, so
ignorePause
should be cleared).
The built-in conditions provided by this library are explained below.
These conditions are the simplest of checks. They do not take any arguments.
Condition | Meaning | Description |
---|---|---|
{"mu"} |
Moving Up | Passes when the player begins to have a y-speed less than 0 |
{"md"} |
Moving Down | Passes when the player begins to have a y-speed greater than or equal to 0 and is not on the ground (this is so walking down a slope doesn't count as passing) |
{"ml"} |
Moving Left | Passes when the player begins to have an x-speed less than or equal to 0 |
{"mr"} |
Moving Right | Passes when the player begins to have an x-speed greater than or equal to 0 |
{"tg"} |
Touching Ground | Passes when the player begins touching the ground. Standing on an NPC does not count as passing. Use snpc for that |
{"ntg"} |
Not Touching Ground | Passes when the player stops touching the ground |
{"snpc"} |
Standing on NPC | Passes when the player is standing on an NPC |
{"hnpc"} |
Holding NPC | Passes when the player is holding an NPC |
{"mb"} |
Message Box | Passes when a message box is displayed |
{"cl"} |
Climbing | Passes when the player is climbing |
{"fs"} |
Forced State | Passes when the player's forcedState field is not equal to FORCEDSTATE_NONE |
{"nfs"} |
No Forced State | Passes when the player's forcedState field is equal to FORCEDSTATE_NONE |
{"iw"} |
In Water | Passes when the player is in water |
{"niw"} |
Not in Water | Passes when the player is not in water |
{"dead"} |
Dead | Passes when the player dies |
These conditions compare a field in the player object to a given value. For each of these, the comparator
argument may be a string containing one of the following; <
, <=
, ==
, ~=
, >=
, >
. Each works as you might expect. For example, the condition {"x",">=",-200000}
would pass if the player's x-position was -200,000 or greater.
Condition | Meaning | Description |
---|---|---|
{"x", comparator, value} |
X | Passes when player.x <comparator> <value> evaluates to true |
{"y", comparator, value} |
Y | Passes when player.y <comparator> <value> evaluates to true |
{"sx", comparator, value} |
Speed X | Passes when player.speedX <comparator> <value> evaluates to true |
{"sy", comparator, value} |
Speed X | Passes when player.speedY <comparator> <value> evaluates to true |
These conditions allow you to combine other conditions in various ways.
Condition | Description |
---|---|
{"or", condition, ...} |
Takes any number of arguments. Passes when at least one of the given conditions passes |
{"and", condition, ...} |
Takes any number of arguments. Passes when all of the given conditions pass. You should use a list of conditions instead if the order in which the conditions will be passed is known. |