Skip to content

ON

source

The callback of every value is on the ON events page.

NameValueDescription
ON.ARENA_INTRO25

Runs when entering the arena VS intro screen.

ON.ARENA_ITEMS23

Runs when entering the arena item config screen.

ON.ARENA_MATCH26

Runs when entering the arena level screen, after all entities have spawned, on the first level frame, before the get ready go scene.

ON.ARENA_MENU21

Runs when entering the main arena rules menu screen.

ON.ARENA_SCORE27

Runs when entering the arena scores screen.

ON.ARENA_SELECT24
ON.ARENA_STAGES22

Runs when entering the arena stage selection screen.

ON.BLOCKED_GAME_LOOP162

Runs instead of POST_GAME_LOOP when anything blocks a PRE_GAME_LOOP. Even runs in Playlunky when Overlunky blocks a PRE_GAME_LOOP.

ON.BLOCKED_PROCESS_INPUT163

Runs instead of POST_PROCESS_INPUT when anything blocks a PRE_PROCESS_INPUT. Even runs in Playlunky when Overlunky blocks a PRE_PROCESS_INPUT.

ON.BLOCKED_UPDATE161

Runs instead of POST_UPDATE when anything blocks a PRE_UPDATE. Even runs in Playlunky when Overlunky blocks a PRE_UPDATE.

ON.CAMP11

Runs when entering the camp, after all entities have spawned, on the first level frame.

ON.CHARACTER_SELECT9

Runs when entering the character select screen.

ON.CONSTELLATION19

Runs when entering the turning into constellation cutscene after cosmic ocean.

ON.CREDITS17

Runs when entering the credits screen.

ON.DEATH14

Runs when entering the death screen.

ON.DEATH_MESSAGE137

Params: STRINGID id Runs once after death when the death message journal page is shown. The parameter is the STRINGID of the title, like 1221 for BLOWN UP.

ON.FRAME101

Runs while playing the game while the player is controllable, not in the base camp or the arena mode

ON.GAMEFRAME108

Runs whenever the game engine is actively running. This includes base camp, arena, level transition and death screen

ON.GUIFRAME100

Params: GuiDrawContext draw_ctx Runs every frame the game is rendered, thus runs at selected framerate. Drawing functions are only available during this callback through a GuiDrawContext

ON.INTRO1

Runs when entering the intro cutscene.

ON.LEADERBOARD7

Runs when entering the leaderboard screen.

ON.LEVEL12

Runs when entering any level, after all entities have spawned, on the first level frame.

ON.LOAD107

Params: LoadContext load_ctx Runs as soon as your script is loaded, including reloads, then never again

ON.LOADING104

Runs whenever state.loading changes and is > 0. Prefer PRE/POST_LOAD_SCREEN instead though.

ON.ONLINE_LOADING28

Runs when entering the online loading screen.

ON.ONLINE_LOBBY29

Runs when entering the online lobby screen.

ON.OPTIONS5

Runs when entering the options menu.

ON.PLAYER_PROFILE6

Runs when entering the player profile screen.

ON.POST_GAME_LOOP156

Runs right after the main engine loop.

ON.POST_LAYER_CREATION148

Params: LAYER layer Runs right after a layer has been created and you can start spawning entities in it. Runs in all screens that usually have entities, or when creating a layer manually.

ON.POST_LAYER_DESTRUCTION152

Params: LAYER layer Runs right after a layer has been unloaded and any entities there destroyed. Runs in pretty much all screens, even ones without entities. The screen has already changed at this point, meaning the screen being destroyed is in state.screen_last.

ON.POST_LEVEL_CREATION146

Runs right after the back layer has been created and you can start spawning entities in it. Runs in all screens that usually have entities, or when creating a layer manually.

ON.POST_LEVEL_DESTRUCTION150

Runs right after the current level has been unloaded and all entities destroyed. Runs in pretty much all screens, even ones without entities. The screen has already changed at this point, meaning the screen being destroyed is in state.screen_last.

ON.POST_LEVEL_GENERATION112

Runs right after level generation is done, i.e. after all level gen entities are spawned, before any entities are updated. You can spawn your own entities here, like extra enemies, give items to players etc.

ON.POST_LOAD_JOURNAL_CHAPTER139

Params: JOURNALUI_PAGE_SHOWN chapter, array:int pages Runs after the pages for the journal are prepared, but not yet displayed, pages is a list of page numbers that the game loaded, if you want to change it, do the changes (remove pages, add new ones, change order) and return it All new pages will be created as JournalPageStory, any custom with page number above 9 will be empty, I recommend using above 99 to be sure not to get the game page, you can later use this to recognise and render your own stuff on that page in the RENDER_POST_JOURNAL_PAGE Return: return new page array to modify the journal, returning empty array or not returning anything will load the journal normally, any page number that was already loaded will result in the standard game page When changing the order of game pages make sure that the page that normally is rendered on the left side is on the left in the new order, otherwise you get some messed up result, custom pages don't have this problem. The order is: left, right, left, right ...

ON.POST_LOAD_SCREEN136

Runs right after a screen is loaded, before rendering anything

ON.POST_LOAD_STATE160

Runs right after the main StateMemory is manually loaded from a slot or a custom SaveState. Slot is 1..4 or -1 on custom SaveState. Params: int slot, StateMemory loaded

ON.POST_PROCESS_INPUT154

Runs right after the game gets input from various devices and writes to a bunch of buttons-variables. Probably the first chance you have to capture or edit buttons_gameplay or buttons_menu sort of things.

ON.POST_ROOM_GENERATION111

Params: PostRoomGenerationContext room_gen_ctx Runs right after all rooms are generated before entities are spawned

ON.POST_SAVE_STATE158

Runs right after the main StateMemory is manually saved to a slot or a custom SaveState. Slot is 1..4 or -1 on custom SaveState. Params: int slot, StateMemory saved

ON.POST_UPDATE143

Runs right after the State is updated, runs always (menu, settings, camp, game, arena, online etc.) with the game engine, typically 60FPS

ON.PRE_GAME_LOOP155

Runs right before the main engine loop. Return true to block state updates and menu updates, i.e. to pause inside menus.

ON.PRE_GET_FEAT140

Runs before getting performed status for a FEAT when rendering the Feats page in journal. Return: true to override the vanilla feat with your own. Defaults to Steam GetAchievement.

ON.PRE_GET_RANDOM_ROOM113

Params: int x, int y, LAYER layer, ROOM_TEMPLATE room_template Return: string room_data Called when the game wants to get a random room for a given template. Return a string that represents a room template to make the game use that. If the size of the string returned does not match with the room templates expected size the room is discarded. White spaces at the beginning and end of the string are stripped, not at the beginning and end of each line.

ON.PRE_HANDLE_ROOM_TILES114

Params: int x, int y, ROOM_TEMPLATE room_template, PreHandleRoomTilesContext room_ctx Return: bool last_callback to determine whether callbacks of the same type should be executed after this Runs after a random room was selected and right before it would spawn entities for each tile code Allows you to modify the rooms content in the front and back layer as well as add a back layer if not yet existant

ON.PRE_LAYER_CREATION147

Params: LAYER layer Runs right before a layer is created. Runs in all screens that usually have entities, or when creating a layer manually.

ON.PRE_LAYER_DESTRUCTION151

Params: LAYER layer Runs right before a layer is unloaded and any entities there destroyed. Runs in pretty much all screens, even ones without entities. The screen has already changed at this point, meaning the screen being destroyed is in state.screen_last.

ON.PRE_LEVEL_CREATION145

Runs right before the front layer is created. Runs in all screens that usually have entities, or when creating a layer manually.

ON.PRE_LEVEL_DESTRUCTION149

Runs right before the current level is unloaded and any entities destroyed. Runs in pretty much all screens, even ones without entities. The screen has already changed at this point, meaning the screen being destroyed is in state.screen_last.

ON.PRE_LEVEL_GENERATION110

Runs before any level generation, no entities exist at this point. Runs in most screens that have entities. Return true to block normal level generation, i.e. stop any entities from being spawned by ThemeInfo functions. Does not block other ThemeInfo functions, like spawn_effects though. POST_LEVEL_GENERATION will still run if this callback is blocked.

ON.PRE_LOAD_JOURNAL_CHAPTER138

Params: JOURNALUI_PAGE_SHOWN chapter Runs before the journal or any of it's chapter is opened Return: return true to not load the chapter (or journal as a whole)

ON.PRE_LOAD_LEVEL_FILES109

Params: PreLoadLevelFilesContext load_level_ctx Runs right before level files would be loaded

ON.PRE_LOAD_SCREEN135

Runs right before loading a new screen based on screen_next. Return true from callback to block the screen from loading.

ON.PRE_LOAD_STATE159

Runs right before the main StateMemory is manually loaded from a slot or a custom SaveState. Slot is 1..4 or -1 on custom SaveState. Return true to block load. Params: int slot, StateMemory loaded

ON.PRE_PROCESS_INPUT153

Runs right before the game gets input from various devices and writes to a bunch of buttons-variables. Return true to disable all game input completely.

ON.PRE_SAVE_STATE157

Runs right before the main StateMemory is manually saved to a slot or a custom SaveState. Slot is 1..4 or -1 on custom SaveState. Return true to block save. Params: int slot, StateMemory saved

ON.PRE_SET_FEAT141

Runs before the game sets a vanilla feat performed. Return: true to block the default behaviour of calling Steam SetAchievement.

ON.PRE_UPDATE142

Runs before the State is updated, runs always (menu, settings, camp, game, arena, online etc.) with the game engine, typically 60FPS Return behavior: return true to stop further PRE_UPDATE callbacks from executing and don't update the state (this will essentially freeze the game engine)

ON.PROLOGUE2

Runs when entering the prologue / poem.

ON.RECAP20

Runs when entering the Dear Journal screen after final scores.

ON.RENDER_POST_BLURRED_BACKGROUND122

Params: VanillaRenderContext render_ctx, float blur Runs after the blurred background is drawn on screen, behind pause menu or journal book. In this event, you can draw textures with the draw_screen_texture function of the render_ctx. (blur amount is probably the same as journal opacity)

ON.RENDER_POST_DRAW_DEPTH124

Params: VanillaRenderContext render_ctx, int draw_depth Runs right after the entities of the specified draw_depth are drawn on screen. In this event, you can draw textures with the draw_world_texture function of the render_ctx

ON.RENDER_POST_GAME132

Params: VanillaRenderContext render_ctx Runs after the level and HUD are rendered, before pause menus and blur effects

ON.RENDER_POST_HUD118

Params: VanillaRenderContext render_ctx, Hud hud Runs after the HUD is drawn on screen. In this event, you can draw textures with the draw_screen_texture function of the render_ctx

ON.RENDER_POST_JOURNAL_PAGE126

Params: VanillaRenderContext render_ctx, JOURNAL_PAGE_TYPE page_type, JournalPage page Runs after the journal page is drawn on screen. In this event, you can draw textures with the draw_screen_texture function of the VanillaRenderContext The JournalPage parameter gives you access to the specific fields of the page. Be sure to cast it to the correct type, the following functions are available to do that: page:as_journal_page_progress() page:as_journal_page_journalmenu() page:as_journal_page_places() page:as_journal_page_people() page:as_journal_page_bestiary() page:as_journal_page_items() page:as_journal_page_traps() page:as_journal_page_feats() page:as_journal_page_deathcause() page:as_journal_page_deathmenu() page:as_journal_page_playerprofile() page:as_journal_page_lastgameplayed()

ON.RENDER_POST_LAYER128

Params: VanillaRenderContext render_ctx, int rendered_layer Runs after a layer is rendered, runs for both layers during layer door transitions. Things drawn here will be part of the layer transition animation

ON.RENDER_POST_LEVEL130

Params: VanillaRenderContext render_ctx, int camera_layer Runs after the level is rendered, before hud

ON.RENDER_POST_PAUSE_MENU120

Params: VanillaRenderContext render_ctx Runs after the pause menu is drawn on screen. In this event, you can draw textures with the draw_screen_texture function of the render_ctx

ON.RENDER_PRE_BLURRED_BACKGROUND121

Params: VanillaRenderContext render_ctx, float blur Runs before the blurred background is drawn on screen, behind pause menu or journal book. In this event, you can't really draw textures, because the blurred background is drawn on top of them. Return true to skip rendering.

ON.RENDER_PRE_DRAW_DEPTH123

Params: VanillaRenderContext render_ctx, int draw_depth Runs before the entities of the specified draw_depth are drawn on screen. In this event, you can draw textures with the draw_world_texture function of the render_ctx. Return true to skip rendering.

ON.RENDER_PRE_GAME131

Params: VanillaRenderContext render_ctx Runs before the in-game part of the game is rendered. Return true to skip rendering.

ON.RENDER_PRE_HUD117

Params: VanillaRenderContext render_ctx, Hud hud Runs before the HUD is drawn on screen. In this event, you can draw textures with the draw_screen_texture function of the render_ctx or edit the Hud values. Return true to skip rendering.

ON.RENDER_PRE_JOURNAL_PAGE125

Params: VanillaRenderContext render_ctx, JOURNAL_PAGE_TYPE page_type, JournalPage page Runs before the journal page is drawn on screen. Return true to skip rendering.

ON.RENDER_PRE_LAYER127

Params: VanillaRenderContext render_ctx, int rendered_layer Runs before a layer is rendered, runs for both layers during layer door transitions. Return true to skip rendering.

ON.RENDER_PRE_LEVEL129

Params: VanillaRenderContext render_ctx, int camera_layer Runs before the level is rendered. Return true to skip rendering.

ON.RENDER_PRE_PAUSE_MENU119

Params: VanillaRenderContext render_ctx Runs before the pause menu is drawn on screen. In this event, you can't really draw textures, because the blurred background is drawn on top of them. Return true to skip rendering.

ON.RESET105

Runs when resetting a run

ON.SAVE106

Params: SaveContext save_ctx Runs at the same times as ON.SCREEN, but receives the save_ctx

ON.SCORES18

Runs when entering the final score celebration screen of a normal or hard ending.

ON.SCREEN102

Runs whenever state.screen changes

ON.SCRIPT_DISABLE116

Runs when the script is disabled from the UI and also right before unloading/reloading.

ON.SCRIPT_ENABLE115

Runs when the script is enabled from the UI or when imported by another script while disabled, but not on load.

ON.SEED_INPUT8

Runs when entering the seed input screen of a seeded run.

ON.SPACESHIP15

Runs when entering the olmecship cutscene after Tiamat.

ON.SPEECH_BUBBLE133

Params: Entity speaking_entity, string text Runs before any speech bubble is created, even the one using say function Return: if you don't return anything it will execute the speech bubble function normally with default message if you return empty string, it will not create the speech bubble at all, if you return string, it will use that instead of the original The first script to return string (empty or not) will take priority, the rest will receive callback call but the return behavior won't matter

ON.START103

Runs on the first ON.SCREEN of a run

ON.TEAM_SELECT10

Runs when entering the team select screen of arena mode.

ON.TITLE3

Runs when entering the title screen.

ON.TOAST134

Params: string text Runs before any toast is created, even the one using toast function Return: if you don't return anything it will execute the toast function normally with default message if you return empty string, it will not create the toast at all, if you return string, it will use that instead of the original message The first script to return string (empty or not) will take priority, the rest will receive callback call but the return behavior won't matter

ON.TRANSITION13

Runs when entering the transition screen, after all entities have spawned.

ON.USER_DATA144

Params: Entity ent Runs on all changes to Entity.user_data, including after loading saved user_data in the next level and transition. Also runs the first time user_data is set back to nil, but nil won't be saved to bother you on future levels.

ON.WIN16

Runs when entering any winning cutscene, including the constellation.