PawScript
PawScript is both an expression language and a scripting language introduced to IW on 14th July 2026.
Official Documentation[edit]
- https://infiniteworlds.app/pawscript-script-guide
- https://infiniteworlds.app/pawscript-reference
- https://infiniteworlds.app/pawscript-expressions-guide
- https://infiniteworlds.app/pawscript-sandbox
- https://infiniteworlds.app/yaml-guide
Common PawScript Tricks[edit]
Player Guide
This page is a player-created guide. Information may reflect personal opinions or playstyles; instruction snippets are examples only. See all guides for more advice.
Whilst the official PawScript guide offers many good use cases for PawScript, here are some additional tricks for specific use cases.
Inserting Instructions[edit]
Triggerless conditional instructions[edit]
<<if(condition, "Instruction set 1", "Instruction set 2")>>
A trigger (or, most likely, set of triggers) can be used to modify an extra instruction block to produce conditional instructions, typically based upon a tracked item's value. For example, provide instructions to remind the AI to consider injuries when a "health" tracked item is low, and don't otherwise. For simple/short instructions, the above construction may be preferable to adding additional tracked items and triggers.
Select instructions from YAML[edit]
We can use
<<choose($value_to_switch_on, 1, "Instructions 1", 2, "Instructions 2", "Default instructions")>>
to expand the above to a greater number of choices - but this is liable to become unwieldy quickly. Alternatively, a hidden YAML tracked item
- "Instructions 1" - "Instructions 2"
Can be selected from using
<<$tracked_item.item($value_to_switch_on)>>
Use a more complex expression in place of the value to switch on in order to do computation first, or combine with if or try to include a default value.
Randomly Chosen Examples[edit]
<<$tracked_item.random(n).join(", ", " or ")>>
We may want the AI to pick from a list (or have a list of examples) but do not need to provide the whole thing every turn - we can pick one or more randomly to send. Join with commas or use .bulleted_list()
Collecting Location-Based Data[edit]
Sometimes you want to track multiple items which might be in different, mutually-exclusive locations (or equivalent) - for example, items which can be "equipped" to different slots.
There are two approaches: one is to have separate tracked items or separate parts of a YAML for each location:
Hat: - name: "Magic Feathered Hat" Armour: - name: "Leather Jerkin" Backpack: - name: "Potion of Healing" - name: "Small rock"
However the AI may prove less reliable in moving items around. An alternative is to include the location as an additional field:
- name: "Magic Feathered Hat" location: "Hat" - name: "Leather Jerkin" location: "Armour" - name: "Potion of Healing" location: "Backpack" - name: "Small rock" location: "Backpack"
Then the item or items in a given location can easily be selected using
$inventory.all().where(location = "Backpack")
This is particularly appropriate if there are no restrictions on locations; if only one item can be in any given "slot" for example, there is a small risk of the AI putting two in the same place, and you will have to use .first() or similar to select a single item.
To display this nicely to the player, create a separate tracked item which is player-visible but not AI-visible, and update it with the data from the YAML tracked item (which can be hidden, but AI-visible). This can be done with expressions, or with a trigger which each turn fires a script (allowing more complex logic, if necessary), for example:
$inventory = "Hat: " & $hidden_inventory.all().where(location = "Hat").first().name $inventory &= "\nArmour: " & $hidden_inventory.all().where(location = "Hat").first().name $inventory &= "\nBackpack:\n" & $hidden_inventory.all().where(location = "Backpack").name.bulleted_list()
(Script split across multiple lines for readability; you could simply concatenate all these elements in one go)