Skip to main content

Lists

Lists are a special type of Variable that allow you store any amount of items inside of it. These items can be anything: text, objects like NPCs or Items, other Lists, Maps, etc.

You can view and learn more about all List actions here.

Example Script

Looping over all items in a given List can be done with the For each in list action.

Like most Loop actions, you can retrieve the current item inside the loop via Last action's output.

Take a look at this example script which adds together all numbers in a List:

A list in action

// Copy and paste this into your Pandemic's Script Creator editor!

[{"id":"COMMENT","properties":{"Comment":"Setup"}},{"id":"ADD_ALL_TO_LIST","properties":{"List name":"Numbers","Value":"1, 2, 3, 4, 5"}},{"id":"COMMENT","properties":{"Comment":"Our loop"}},{"id":"FOR_EACH_IN_LIST","properties":{"List name":"Numbers"},"children":[{"id":"SET_VARIABLE_TO_LAST_OUTPUT","properties":{"Variable name":"Current Number"}},{"id":"ADD_TO_VARIABLE","properties":{"Variable name":"Sum","By":"var(Current Number)"}}]},{"id":"COMMENT","properties":{"Comment":"Show results"}},{"id":"SHOW_DIALOG_MESSAGE","properties":{"Message":"The sum is var(Sum)!"}},{"id":"STOP_SCRIPT"}]