Skip to content

StateMemory

State typessource

Can be accessed via global state

Fields

camera

Camera?

Camera bounds and position

source

camera_layer

integer

source

cause_of_death

CAUSE_OF_DEATH

source

cause_of_death_entity_type

ENT_TYPE

source

coffin_contents

ENT_TYPE

the contents of the special coffin that will be spawned during levelgen

source

correct_ushabti

integer

See get_correct_ushabti. == anim_frame - (2 * floor(anim_frame/12))

source

current_theme

ThemeInfo?

Points to the current ThemeInfo

source

damage_taken

integer

Total amount of damage taken, excluding cause of death

source

end_spaceship_character

ENT_TYPE

Who pops out the spaceship for a tiamat/hundun win, this is set upon the spaceship door open

source

fade_circle

boolean

Makes loading use circle iris effect instead of fade on FADE.IN

source

fade_delay

integer

Additional delay after fade_timer reaches 0, before moving to the next fading state. Used after Ouroboros, in credits etc. for longer black screens, but also works after FADE.IN.

source

fade_enabled

boolean

Enables the fade effect on FADE.IN, setting to false makes loading skip FADE.IN state instantly

source

fade_length

integer

Total frames for fade-in/fade-out when loading.

source

fade_timer

integer

Remaining frames for fade-in/fade-out when loading. Counts down to 0.

source

fade_value

number

Current fade-to-black amount (0.0 = all visible; 1.0 = all black). Manipulated by the loading routine when loading > 0.

source

first_damage_cause

ENT_TYPE

source

first_damage_level

integer

source

first_damage_world

integer

source

height

integer

level height in rooms (number of rooms vertically)

source

illumination

Illumination?

The global level illumination, very big and bright.

source

items

Items?

Has the current player count, player inventories and character selections

source

journal_flags

JOURNAL_FLAG

source

journal_progress_stain_count

integer

source

journal_progress_stain_slots

JournalProgressStainSlot[]

blood splats and paw prints in journal progress page

source

journal_progress_sticker_count

integer

source

journal_progress_sticker_slots

JournalProgressStickerSlot[]

stickers for notable items and entities in journal progress page

source

journal_progress_theme_count

integer

source

journal_progress_theme_slots

THEME[]

visited themes in journal progress page

source

kali_altars_destroyed

integer

Also affects if the player has punish ball, if the punish ball is destroyed it is set to -1

source

kali_favor

integer

source

kali_gifts

integer

0 - none, 1 - item, 3 - kapala

source

kali_status

integer

source

kills_npc

integer

source

layer_transition_timer

integer

source

level

integer

Current level number, shown in hud and used by some game logic like choosing the next level on transition

source

level_count

integer

Current zero-based level count, or number of levels completed

source

level_flags

integer

source

level_gen

LevelGenSystem?

Entrance and exit coordinates, shop types and all themes

source

level_next

integer

Next level number, used when loading a new level or transition

source

level_start

integer

Level number to start new runs in

source

loading

FADE

Current loading/fade state. Pauses all updates if > FADE.NONE. Writing FADE.OUT or FADE.LOAD will trigger a screen load to screen_next.

source

logic

LogicList?

Level logic like dice game and cutscenes

source

merchant_aggro

integer

Tun aggro

source

money_last_levels

integer

source

money_shop_total

integer

Total amount spent in shops and sold idols during the run
The total money currently available is loop (players[].inventory.money + players[].inventory.collected_money_total) + state.money_shop_total

source

next_entity_uid

integer

Next entity spawned will have this uid

source

outposts_spawned

integer

source

pause

PAUSE

8bit flags, multiple might be active at the same time 1: Menu: Pauses the level timer and engine. Can't set, controlled by the menu. 2: Fade/Loading: Pauses all timers and engine. 4: Cutscene: Pauses total/level time but not engine. Used by boss cutscenes. 8: Unknown: Pauses total/level time and engine. Does not pause the global counter so set_global_interval still runs. 16: Unknown: Pauses total/level time and engine. Does not pause the global counter so set_global_interval still runs. 32: Ankh: Pauses all timers, engine, but not camera. Used by the ankh cutscene.

source

player_inputs

PlayerInputs?

Access the player inputs even when no player entities are available

source

presence_flags

PRESENCE_FLAG

source

quest_flags

QUEST_FLAG

32bit flags, can be written to trigger a run reset on next level load etc.

source

quests

QuestsInfo?

NPC quest states

source

room_owners

RoomOwnersInfo

Holds info about owned rooms and items (shops, challenge rooms, vault etc.)

source

saved_cats

integer

source

saved_dogs

integer

Run totals

source

saved_hamsters

integer

source

screen

SCREEN

Current SCREEN, generally read-only or weird things will happen

source

screen_arena_intro

ScreenArenaIntro?

source

screen_arena_items

ScreenArenaItems?

source

screen_arena_level

ScreenArenaLevel?

source

screen_arena_menu

ScreenArenaMenu?

source

screen_arena_score

ScreenArenaScore?

source

screen_arena_stages_select

ScreenArenaStagesSelect?

source

screen_change_counter

integer

source

screen_character_select

ScreenCharacterSelect?

source

screen_constellation

ScreenConstellation?

source

screen_credits

ScreenCredits?

The spaceship minigame

source

screen_death

ScreenDeath?

source

screen_last

SCREEN

Previous SCREEN, used to check where we're coming from when loading another SCREEN

source

screen_next

SCREEN

Next SCREEN, used to load the right screen when loading. Can be changed in PRE_LOAD_SCREEN to go somewhere else instead. Also see state.loading.

source

screen_recap

ScreenRecap?

Journal after CO win

source

screen_scores

ScreenScores?

Landing on the moon after win

source

screen_team_select

ScreenTeamSelect?

For the arena

source

screen_transition

ScreenTransition?

source

screen_win

ScreenWin?

source

seed

integer

Current seed in seeded mode, just set to a funny value and does nothing in adventure mode

source

shoppie_aggro

integer

Current shoppie aggro

source

shoppie_aggro_next

integer

Shoppie aggro to use in the next level

source

special_visibility_flags

integer

source

speechbubble_owner

integer

source

speechbubble_timer

integer

source

speedrun_activation_trigger

boolean

must transition from true to false to activate it

source

speedrun_character

ENT_TYPE

Who administers the tutorial speedrun in base camp

source

storage_uid

integer

entity uid of the first floor_storage entity

source

theme

THEME

Current THEME number, used to pick the music and by some game logic like choosing the next level on transition

source

theme_info

ThemeInfo?

Points to the current ThemeInfo

source

theme_next

THEME

Next THEME number, used when loading a new level or transition

source

theme_start

THEME

THEME to start new runs in

source

time_last_level

integer

Level time of previous level in frames, used by game logic to decide dark levels etc

source

time_level

integer

Level time of current level in frames, show on the hud

source

time_speedrun

integer

source

time_startup

integer

Number of frames since the game was launched

source

time_total

integer

Total frames of current run, equal to the final game time on win

source

toast_timer

integer

source

transition_to_layer

integer

source

user_data

anyproperty

You can store a table (or lua primitive) here and it will store data correctly in online multiplayer, by having a different copy on each state and being copied over when the game does. Doesn't support recursive tables / cyclic references. Metatables will be transferred by reference instead of being copied

source

waddler_metadata

integer[]

source

waddler_storage

ENT_TYPE[]

source

width

integer

level width in rooms (number of rooms horizontally)

source

win_state

integer

0 = no win 1 = tiamat win 2 = hundun win 3 = CO win; set this and next doorway leads to victory scene

source

world

integer

Current world number, shown in hud and used by some game logic like choosing the next level on transition

source

world2_coffin_spawned

boolean

source

world4_coffin_spawned

boolean

source

world6_coffin_spawned

boolean

source

world_next

integer

Next world number, used when loading a new level or transition

source

world_start

integer

World number to start new runs in

source

Methods

force_current_theme

function StateMemory:force_current_theme(t: THEME)
t: THEME
source

get_correct_ushabti

function StateMemory:get_correct_ushabti(): integer

Returns integer

source

set_correct_ushabti

function StateMemory:set_correct_ushabti(animation_frame: integer)
animation_frame: integer
source