NAV

Switch to Dark Mode

Overlunky/Playlunky Lua API

Read this first

External Function Library

If you use a text editor/IDE that has a Lua linter available you can download spel2.lua, place it in a folder of your choice and specify that folder as a "external function library". For example VSCode with the Lua Extension offers this feature. This will allow you to get auto-completion of API functions along with linting

Lua libraries

The following Lua libraries and their functions are available. You can read more about them in the Lua documentation. We're using Lua 5.4 with the Sol C++ binding.

io

-- Write a data file
-- Data will be written to Mods/Data/[scriptname.lua or Mod Name]/timestamp.txt
local f = io.open_data(tostring(os.time()) .. ".txt", "w")
if f then
    f:write("hello world at " .. os.date())
    f:close()
end

-- List all files in data dir and read them out
for _, v in pairs(list_data_dir()) do
    local f = io.open_data(v)
    if f then
        print(v .. ": " .. f:read("a"))
    end
end

meta.unsafe exposes all standard library functions and removes basedir restrictions from the custom functions.

In safe mode (default) the following standard and custom functions are available:

Safely opened files can be used normally through the file: handle. Files and folders opened in write mode are automatically created.

Also see list_dir and list_data_dir.

os

meta.unsafe exposes all standard library functions and removes basedir restrictions from the custom functions.

In safe mode (default) the following standard and custom functions are available:

math

base

string

table

coroutine

package

json

To save data in your mod it makes a lot of sense to use json to encode a table into a string and decode strings to table. For example this code that saves table and loads it back:

local some_mod_data_that_should_be_saved = {{
    kills = 0,
    unlocked = false
}}
set_callback(function(save_ctx)
    local save_data_str = json.encode(some_mod_data_that_should_be_saved)
    save_ctx:save(save_data_str)
end, ON.SAVE)

set_callback(function(load_ctx)
    local load_data_str = load_ctx:load()
    if load_data_str ~= "" then
        some_mod_data_that_should_be_saved = json.decode(load_data_str)
    end
end, ON.LOAD)

inspect

This module is a great substitute for tostring because it can convert any type to a string and thus helps a lot with debugging. Use for example like this:

local look_ma_no_tostring = {
    number = 15,
    nested_table = {
        array = {
            1,
            2,
            4
        }
    }
}
message(inspect(look_ma_no_tostring))
--[[prints:
{
    number = 15,
    nested_table = {
        array = { 1, 2, 4 }
    }
}
]]

format

This allows you to make strings without having to do a lot of tostring and .. by placing your variables directly inside of the string. Use F in front of your string and wrap variables you want to print in {}, for example like this:

for _, player in players do
    local royal_title = nil
    if player:is_female() then
        royal_title = 'Queen'
    else
        royal_title = 'King'
    end
    local name = F'{player:get_name()} aka {royal_title} {player:get_short_name()}'
    message(name)
end

Unsafe mode

Setting meta.unsafe = true enables the rest of the standard Lua libraries like unrestricted io, os, ffi and debug, loading dlls with require, package.loadlib, the network functions and some debug functions. Using unsafe scripts requires users to enable the option in the overlunky.ini file which is found in the Spelunky 2 installation directory.

Modules

You can load modules with require "mymod" or require "mydir.mymod", just put mymod.lua in the same directory the script is, or in mydir/ to keep things organized.

Check the Lua tutorial or examples how to actually make modules.

You can also import other loaded script mods to your own mod if they have exports.

Aliases

Used to clarify what kind of values can be passed and returned from a function, even if the underlying type is really just an integer or a string. This should help to avoid bugs where one would for example just pass a random integer to a function expecting a callback id.

Name Type
CallbackId int;
Flags int;
uColor int;
SHORT_TILE_CODE int;
STRINGID int;
FEAT int;

Global variables

These variables are always there to use.

meta

meta.name = "Awesome Mod"
meta.version = "1.0"
meta.author = "You"
meta.description = [[
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut at nulla porttitor, lobortis magna at, tempus dolor. Cras non ligula tellus. Duis tincidunt sodales velit et ornare. Mauris eu sapien finibus dolor dictum malesuada in non elit.

    Aenean luctus leo ut diam ornare viverra. Nunc condimentum interdum elit, quis porttitor quam finibus ac. Nam mattis, lectus commodo placerat tristique, justo justo congue dui, sed sodales nunc sem ut neque.
]]
-- set this to enable unsafe mode
--meta.unsafe = true

-- rest of your mod goes here

array<mixed> meta

Search script examples for meta

Table of strings where you should set some script metadata shown in the UI and used by other scripts to find your script.

state

if state.time_level > 300 and state.theme == THEME.DWELLING then
    toast("Congratulations for lasting 5 seconds in Dwelling")
end

StateMemory state

Search script examples for state

A bunch of game state variables. Your ticket to almost anything that is not an Entity.

game_manager

if game_manager.game_props.game_has_focus == false then
    message("Come back soon!")
end

GameManager game_manager

Search script examples for game_manager

The GameManager gives access to a couple of Screens as well as the pause and journal UI elements

online

message = "Currently playing: "
for _, p in pairs(online.online_players) do
    if p.ready_state ~= 0 then
        message = message .. p.player_name .. " "
    end
end
print(message)

Online online

Search script examples for online

The Online object has information about the online lobby and its players

players

-- Make the player invisible, use only in single player only mods

players[1].flags = set_flag(players[1].flags, 1)

array<Player> players

Search script examples for players

An array of Player of the current players. This is just a list of existing Player entities in order, i.e., players[1] is not guaranteed to be P1 if they have been gibbed for example. See get_player.

savegame

Print best time from savegame

prinspect(savegame.time_best)

SaveData savegame

Search script examples for savegame

Provides access to the save data, updated as soon as something changes (i.e. before it's written to savegame.sav.) Use save_progress to save to savegame.sav.

options

register_option_bool("bomb_bag", "BombBag", "Spawn bomb bag at the start of every level", false)

set_callback(function()
    if options.bomb_bag then
        -- Spawn the bomb bag at player location thanks to the LAYER.PLAYER1
        spawn_entity_snapped_to_floor(ENT_TYPE.ITEM_PICKUP_BOMBBAG, 0, 0, LAYER.PLAYER1)
    end
end, ON.LEVEL)

optional<array<mixed>> options

Search script examples for options

Table of options set in the UI, added with the register_option_functions, but nil before any options are registered. You can also write your own options in here or override values defined in the register functions/UI before or after they are registered. Check the examples for many different use cases and saving options to disk.

prng

--Make it so there is 50% chance that the Ankh will be destroyed

set_callback(function ()
    -- more or less 50% chance
    if prng:random(2) == 1 then
        -- get all Ankh's in a level
        ankhs = get_entities_by(ENT_TYPE.ITEM_PICKUP_ANKH, MASK.ITEM, LAYER.BOTH)
        for _, uid in pairs(ankhs) do
            get_entity(uid):destroy()
        end
    end
end, ON.LEVEL)

PRNG prng

Search script examples for prng

The global prng state, calling any function on it will advance the prng state, thus desynchronizing clients if it does not happen on both clients.

STD Library Containers

Sometimes game variables and return of some functions will be of type map, set, vector etc. from the C++ Standard Library.

You don't really need to know much of this as they will behave similar to a lua table, even accept some table functions from the table library and support looping thru using pair function. You can also use them as parameter for functions that take array, Sol will happily convert them for you.

They come with some extra functionality:

Type Name Description
bool all:empty() Returns true if container is empty, false otherwise
int all:size() Same as #container
any vector:at(int index) Same as vector[index]
any span:at(int index) Same as span[index]
any set:at(int order) Returns elements in order, it's not an index as sets don't have one
any map:at(int order) Returns elements in order, it's not an index as maps don't have one
int vector:find(any value) Searches for the value in vector, returns index of the item in vector or nil if not found, only available for simple values that are comparable
int span:find(any value) Searches for the value in span, returns index of the item in span or nil if not found, only available for simple values that are comparable
any set:find(any key) Searches for the value in set, returns the value itself or nil if not found, only available for simple values that are comparable
any map:find(any key) Searches for the key in map, returns the value itself or nil if not found, only available for simple keys that are comparable
nil vector:erase(int index) Removes element at given index, the rest of elements shift down so that the vector stays contiguous
nil set:erase(any key) Removes element from set
nil map:erase(any key) Removes element from map
nil vector:clear() Removes all elements from vector
nil set:clear() Removes all elements from set
nil map:clear() Removes all elements from map
nil vector:insert(int index, any element) Inserts element at given index, the rest of elements shift up in index
nil set:insert(int order, any key) The order param doesn't acutally matter and can be set to nil
nil map:insert(any key, any value)? unsure, probably easier to just use map[key] = value

Functions

The game functions like spawn use level coordinates. Draw functions use normalized screen coordinates from -1.0 .. 1.0 where 0.0, 0.0 is the center of the screen.

Callback functions

clear_callback

Create three explosions and then clear the interval

local count = 0 -- this upvalues to the interval
set_interval(function()
  count = count + 1
  spawn(ENT_TYPE.FX_EXPLOSION, 0, 0, LAYER.FRONT, 0, 0)
  if count >= 3 then
    -- calling this without parameters clears the callback that's calling it
    clear_callback()
  end
end, 60)

Search script examples for clear_callback

nil clear_callback(optional<CallbackId> id)

Clear previously added callback id or call without arguments inside any callback to clear that callback after it returns.

clear_screen_callback

Search script examples for clear_screen_callback

nil clear_screen_callback(int screen_id, CallbackId cb_id)

Clears a callback that is specific to a screen.

clear_vanilla_sound_callback

Search script examples for clear_vanilla_sound_callback

nil clear_vanilla_sound_callback(CallbackId id)

Clears a previously set callback

set_callback

Search script examples for set_callback

CallbackId set_callback(function cb, ON event)

Returns unique id for the callback to be used in clear_callback. Add global callback function to be called on an event.

set_global_interval

Search script examples for set_global_interval

CallbackId set_global_interval(function cb, int frames)

Returns unique id for the callback to be used in clear_callback. You can also return false from your function to clear the callback. Add global callback function to be called every frames engine frames. This timer is never paused or cleared.

set_global_timeout

Search script examples for set_global_timeout

CallbackId set_global_timeout(function cb, int frames)

Returns unique id for the callback to be used in clear_callback. Add global callback function to be called after frames engine frames. This timer is never paused or cleared.

set_interval

Create three explosions and then clear the interval

local count = 0 -- this upvalues to the interval
set_interval(function()
  count = count + 1
  spawn(ENT_TYPE.FX_EXPLOSION, 0, 0, LAYER.FRONT, 0, 0)
  if count >= 3 then
    -- calling this without parameters clears the fallback that's calling it
    clear_callback()
  end
end, 60)

Search script examples for set_interval

CallbackId set_interval(function cb, int frames)

Returns unique id for the callback to be used in clear_callback. You can also return false from your function to clear the callback. Add per level callback function to be called every frames engine frames Ex. frames = 100 - will call the function on 100th frame from this point. This might differ in the exact timing of first frame depending as in what part of the frame you call this function or even be one frame off if called right before the time_level variable is updated If you require precise timing, choose the start of your interval in one of those safe callbacks: The SCREEN callbacks: from ON.LOGO to ON.ONLINE_LOBBY or custom callbacks ON.FRAME, ON.SCREEN, ON.START, ON.LOADING, ON.RESET, ON.POST_UPDATE Timer is paused on pause and cleared on level transition.

set_on_player_instagib

Search script examples for set_on_player_instagib

optional<CallbackId> set_on_player_instagib(int uid, function fun)

Returns unique id for the callback to be used in clear_callback or nil if uid is not valid. Sets a callback that is called right when an player/hired hand is crushed/insta-gibbed, return true to skip the game's crush handling. The game's instagib function will be forcibly executed (regardless of whatever you return in the callback) when the entity's health is zero. This is so that when the entity dies (from other causes), the death screen still gets shown. Use this only when no other approach works, this call can be expensive if overused.
The callback signature is bool on_player_instagib(Entity self)

set_post_entity_spawn

Search script examples for set_post_entity_spawn

CallbackId set_post_entity_spawn(function cb, SPAWN_TYPE flags, int mask, variadic_args entity_types)

Add a callback for a spawn of specific entity types or mask. Set mask to MASK.ANY to ignore that. This is run right after the entity is spawned but before and particular properties are changed, e.g. owner or velocity.
The callback signature is nil post_entity_spawn(Entity ent, SPAWN_TYPE spawn_flags)

set_post_render_screen

Search script examples for set_post_render_screen

optional<CallbackId> set_post_render_screen(int screen_id, function fun)

Returns unique id for the callback to be used in clear_screen_callback or nil if screen_id is not valid. Sets a callback that is called right after the screen is drawn.
The callback signature is nil render_screen(Screen self, VanillaRenderContext render_ctx)

set_pre_entity_spawn

Search script examples for set_pre_entity_spawn

CallbackId set_pre_entity_spawn(function cb, SPAWN_TYPE flags, int mask, variadic_args entity_types)

Add a callback for a spawn of specific entity types or mask. Set mask to MASK.ANY to ignore that. This is run before the entity is spawned, spawn your own entity and return its uid to replace the intended spawn. In many cases replacing the intended entity won't have the intended effect or will even break the game, so use only if you really know what you're doing.
The callback signature is optional pre_entity_spawn(ENT_TYPE entity_type, float x, float y, int layer, Entity overlay_entity, SPAWN_TYPE spawn_flags)

set_pre_render_screen

Search script examples for set_pre_render_screen

optional<CallbackId> set_pre_render_screen(int screen_id, function fun)

Returns unique id for the callback to be used in clear_screen_callback or nil if screen_id is not valid. Sets a callback that is called right before the screen is drawn, return true to skip the default rendering.
The callback signature is bool render_screen(Screen self, VanillaRenderContext render_ctx)

set_timeout

Search script examples for set_timeout

CallbackId set_timeout(function cb, int frames)

Returns unique id for the callback to be used in clear_callback. Add per level callback function to be called after frames engine frames. Timer is paused on pause and cleared on level transition.

set_vanilla_sound_callback

Search script examples for set_vanilla_sound_callback

CallbackId set_vanilla_sound_callback(VANILLA_SOUND name, VANILLA_SOUND_CALLBACK_TYPE types, function cb)

Returns unique id for the callback to be used in clear_vanilla_sound_callback. Sets a callback for a vanilla sound which lets you hook creation or playing events of that sound Callbacks are executed on another thread, so avoid touching any global state, only the local Lua state is protected If you set such a callback and then play the same sound yourself you have to wait until receiving the STARTED event before changing any properties on the sound. Otherwise you may cause a deadlock.
The callback signature is nil on_vanilla_sound(PlayingSound sound)

Debug functions

dump

Search script examples for dump

table dump(any object, optional depth)

Dump the object (table, container, class) as a recursive table, for pretty printing in console. Don't use this for anything except debug printing. Unsafe.

dump_network

Search script examples for dump_network

nil dump_network()

Hook the sendto and recvfrom functions and start dumping network data to terminal

get_address

Search script examples for get_address

nil get_address(any o)

Get memory address from a lua object

get_rva

Search script examples for get_rva

string get_rva(string address_name)

Get the rva for a pattern name, used for debugging.

get_virtual_rva

Search script examples for get_virtual_rva

string get_virtual_rva(VTABLE_OFFSET offset, int index)

Get the rva for a vtable offset and index, used for debugging.

raise

Search script examples for raise

nil raise()

Raise a signal and probably crash the game

Entity functions

activate_sparktraps_hack

activate_sparktraps_hack(true);

-- set random speed, direction and distance for the spark
set_post_entity_spawn(function(ent)

    direction = 1
    if prng:random_chance(2, PRNG_CLASS.ENTITY_VARIATION) then
        direction = -1
    end

    ent.speed = prng:random_float(PRNG_CLASS.ENTITY_VARIATION) * 0.1 * direction
    ent.distance = prng:random_float(PRNG_CLASS.ENTITY_VARIATION) * 10

end, SPAWN_TYPE.ANY, 0, ENT_TYPE.ITEM_SPARK)

Search script examples for activate_sparktraps_hack

nil activate_sparktraps_hack(bool activate)

Activate custom variables for speed and distance in the ITEM_SPARK note: because those the variables are custom and game does not initiate them, you need to do it yourself for each spark, recommending set_post_entity_spawn default game values are: speed = -0.015, distance = 3.0

add_entity_to_liquid_collision

Search script examples for add_entity_to_liquid_collision

nil add_entity_to_liquid_collision(int uid, bool add)

Attach liquid collision to entity by uid (this is what the push blocks use) Collision is based on the entity's hitbox, collision is removed when the entity is destroyed (bodies of killed entities will still have the collision) Use only for entities that can move around, (for static prefer update_liquid_collision_at ) If entity is in back layer and liquid in the front, there will be no collision created, also collision is not destroyed when entity changes layers, so you have to handle that yourself

apply_entity_db

Search script examples for apply_entity_db

nil apply_entity_db(int uid)

Apply changes made in get_type() to entity instance by uid.

attach_ball_and_chain

Search script examples for attach_ball_and_chain

int attach_ball_and_chain(int uid, float off_x, float off_y)

Spawns and attaches ball and chain to uid, the initial position of the ball is at the entity position plus off_x, off_y

attach_entity

Search script examples for attach_entity

nil attach_entity(int overlay_uid, int attachee_uid)

Attaches attachee to overlay, similar to setting get_entity(attachee).overlay = get_entity(overlay). However this function offsets attachee (so you don't have to) and inserts it into overlay's inventory.

carry

Search script examples for carry

nil carry(int mount_uid, int rider_uid)

Make mount_uid carry rider_uid on their back. Only use this with actual mounts and living things.

change_waddler_drop

Search script examples for change_waddler_drop

nil change_waddler_drop(array<ENT_TYPE> ent_types)

Change ENT_TYPE's spawned when Waddler dies, by default there are 3:
{ITEM_PICKUP_COMPASS, ITEM_CHEST, ITEM_KEY}
Max 255 types. Use empty table as argument to reset to the game default

drop

Search script examples for drop

nil drop(int who_uid, int what_uid)

Drop an entity by uid

enter_door

Search script examples for enter_door

nil enter_door(int player_uid, int door_uid)

Calls the enter door function, position doesn't matter, can also enter closed doors (like COG, EW) without unlocking them

entity_get_items_by

Search script examples for entity_get_items_by

vector<int> entity_get_items_by(int uid, array<ENT_TYPE> entity_types, int mask)

vector<int> entity_get_items_by(int uid, ENT_TYPE entity_type, int mask)

Gets uids of entities attached to given entity uid. Use entity_type and mask (MASK) to filter, set them to 0 to return all attached entities.

entity_has_item_type

Search script examples for entity_has_item_type

bool entity_has_item_type(int uid, array<ENT_TYPE> entity_types)

bool entity_has_item_type(int uid, ENT_TYPE entity_type)

Check if the entity uid has some ENT_TYPE entity_type in their inventory, can also use table of entity_types

entity_has_item_uid

Search script examples for entity_has_item_uid

bool entity_has_item_uid(int uid, int item_uid)

Check if the entity uid has some specific item_uid by uid in their inventory

entity_remove_item

Search script examples for entity_remove_item

nil entity_remove_item(int uid, int item_uid)

Remove item by uid from entity

filter_entities

Search script examples for filter_entities

vector<int> filter_entities(vector entities, function predicate)

Returns a list of all uids in entities for which predicate(get_entity(uid)) returns true

flip_entity

Search script examples for flip_entity

nil flip_entity(int uid)

Flip entity around by uid. All new entities face right by default.

force_olmec_phase_0

Search script examples for force_olmec_phase_0

nil force_olmec_phase_0(bool b)

Forces Olmec to stay on phase 0 (stomping)

get_door_target

Search script examples for get_door_target

tuple<int, int, int> get_door_target(int uid)

Get door target world, level, theme

get_entities_at

Search script examples for get_entities_at

vector<int> get_entities_at(array<ENT_TYPE> entity_types, int mask, float x, float y, LAYER layer, float radius)

vector<int> get_entities_at(ENT_TYPE entity_type, int mask, float x, float y, LAYER layer, float radius)

Get uids of matching entities inside some radius (ENT_TYPE, MASK). Set entity_type or mask to 0 to ignore that, can also use table of entity_types Recommended to always set the mask, even if you look for one entity type

get_entities_by

-- find all cavemen and give them bombs
-- using a type and mask in get_entities_by speeds up the search, cause the api knows which bucket to search in
for i,uid in ipairs(get_entities_by(ENT_TYPE.MONS_CAVEMAN, MASK.MONSTER, LAYER.BOTH)) do
    local x, y, l = get_position(uid)
    spawn_entity_snapped_to_floor(ENT_TYPE.ITEM_BOMB, x, y, l)
end

Search script examples for get_entities_by

vector<int> get_entities_by(array<ENT_TYPE> entity_types, int mask, LAYER layer)

vector<int> get_entities_by(ENT_TYPE entity_type, int mask, LAYER layer)

Get uids of entities by some conditions (ENT_TYPE, MASK). Set entity_type or mask to 0 to ignore that, can also use table of entity_types. Recommended to always set the mask, even if you look for one entity type

get_entities_by_draw_depth

Search script examples for get_entities_by_draw_depth

vector<int> get_entities_by_draw_depth(array draw_depths, LAYER l)

vector<int> get_entities_by_draw_depth(int draw_depth, LAYER l)

Get uids of entities by draw_depth. Can also use table of draw_depths. You can later use filter_entities if you want specific entity

get_entities_by_type

local types = {ENT_TYPE.MONS_SNAKE, ENT_TYPE.MONS_BAT}
set_callback(function()
    local uids = get_entities_by_type(ENT_TYPE.MONS_SNAKE, ENT_TYPE.MONS_BAT)
    -- is not the same thing as this, but also works
    local uids2 = get_entities_by_type(types)
    print(tostring(#uids).." == "..tostring(#uids2))
end, ON.LEVEL)

Search script examples for get_entities_by_type

vector<int> get_entities_by_type(ENT_TYPE, ENT_TYPE...)

Get uids of entities matching id. This function is variadic, meaning it accepts any number of id's. You can even pass a table! This function can be slower than the get_entities_by with the mask parameter filled

get_entities_overlapping_grid

Search script examples for get_entities_overlapping_grid

vector<int> get_entities_overlapping_grid(float x, float y, LAYER layer)

Get uids of static entities overlapping this grid position (decorations, backgrounds etc.)

get_entities_overlapping_hitbox

Search script examples for get_entities_overlapping_hitbox

vector<int> get_entities_overlapping_hitbox(array<ENT_TYPE> entity_types, int mask, AABB hitbox, LAYER layer)

vector<int> get_entities_overlapping_hitbox(ENT_TYPE entity_type, int mask, AABB hitbox, LAYER layer)

Get uids of matching entities overlapping with the given hitbox. Set entity_type or mask to 0 to ignore that, can also use table of entity_types

get_entity

Search script examples for get_entity

Entity get_entity(int uid)

Get the Entity behind an uid, converted to the correct type. To see what type you will get, consult the entity hierarchy list

get_entity_name

Search script examples for get_entity_name

string get_entity_name(ENT_TYPE type, optional fallback_strategy)

Get localized name of an entity from the journal, pass fallback_strategy as true to fall back to the ENT_TYPE.* enum name if the entity has no localized name

get_entity_type

Search script examples for get_entity_type

ENT_TYPE get_entity_type(int uid)

Get the ENT_TYPE... of the entity by uid

get_grid_entity_at

Search script examples for get_grid_entity_at

int get_grid_entity_at(float x, float y, LAYER layer)

Gets a grid entity, such as floor or spikes, at the given position and layer.

get_local_players

Search script examples for get_local_players

nil get_local_players()

Get the thread-local version of players

get_player

Search script examples for get_player

Player get_player(int slot, bool or_ghost = false)

Returns Player (or PlayerGhost if get_player(1, true)) with this player slot

get_playerghost

Search script examples for get_playerghost

PlayerGhost get_playerghost(int slot)

Returns PlayerGhost with this player slot 1..4

get_type

Search script examples for get_type

EntityDB get_type(int id)

Get the EntityDB behind an ENT_TYPE...

kill_entity

Search script examples for kill_entity

nil kill_entity(int uid, optional destroy_corpse = nullopt)

Kills an entity by uid. destroy_corpse defaults to true, if you are killing for example a caveman and want the corpse to stay make sure to pass false.

lock_door_at

Search script examples for lock_door_at

nil lock_door_at(float x, float y)

Try to lock the exit at coordinates

modify_ankh_health_gain

Search script examples for modify_ankh_health_gain

nil modify_ankh_health_gain(int max_health, int beat_add_health)

Change how much health the ankh gives you after death, with every beat (the heart beat effect) it will add beat_add_health to your health, beat_add_health has to be divisor of health and can't be 0, otherwise the function does nothing. Set health to 0 to return to the game defaults If you set health above the game max health it will be forced down to the game max

modify_sparktraps

Search script examples for modify_sparktraps

nil modify_sparktraps(float angle_increment = 0.015, float distance = 3.0)

Changes characteristics of (all) sparktraps: speed, rotation direction and distance from center Speed: expressed as the amount that should be added to the angle every frame (use a negative number to go in the other direction) Distance from center: if you go above 3.0 the game might crash because a spark may go out of bounds!

move_entity

Search script examples for move_entity

nil move_entity(int uid, float x, float y, float vx, float vy)

nil move_entity(int uid, float x, float y, float vx, float vy, LAYER layer)

Teleport entity to coordinates with optional velocity

move_grid_entity

Search script examples for move_grid_entity

nil move_grid_entity(int uid, float x, float y, LAYER layer)

Teleport grid entity, the destination should be whole number, this ensures that the collisions will work properly

pick_up

-- spawn and equip a jetpack on the player
pick_up(players[1].uid, spawn(ENT_TYPE.ITEM_JETPACK, 0, 0, LAYER.PLAYER, 0, 0))

Search script examples for pick_up

nil pick_up(int who_uid, int what_uid)

Pick up another entity by uid. Make sure you're not already holding something, or weird stuff will happen.

poison_entity

Search script examples for poison_entity

nil poison_entity(int entity_uid)

Poisons entity, to cure poison set Movable.poison_tick_timer to -1

replace_drop

Search script examples for replace_drop

nil replace_drop(int drop_id, ENT_TYPE new_drop_entity_type)

Changes a particular drop, e.g. what Van Horsing throws at you (use e.g. replace_drop(DROP.VAN_HORSING_DIAMOND, ENT_TYPE.ITEM_PLASMACANNON)) Use 0 as type to reset this drop to default, use -1 as drop_id to reset all to default

set_boss_door_control_enabled

Search script examples for set_boss_door_control_enabled

nil set_boss_door_control_enabled(bool enable)

Allows you to disable the control over the door for Hundun and Tiamat This will also prevent game crashing when there is no exit door when they are in level

set_contents

Search script examples for set_contents

nil set_contents(int uid, ENT_TYPE item_entity_type)

Set the contents of Coffin, Present, Pot, Container Check the entity hierarchy list for what the exact ENT_TYPE's can this function affect

set_cursepot_ghost_enabled

Search script examples for set_cursepot_ghost_enabled

nil set_cursepot_ghost_enabled(bool enable)

Determines whether the ghost appears when breaking the ghost pot

set_door

Search script examples for set_door

nil set_door(int uid, int w, int l, int t)

Short for set_door_target.

set_door_target

Search script examples for set_door_target

nil set_door_target(int uid, int w, int l, int t)

Make an ENT_TYPE.FLOOR_DOOR_EXIT go to world w, level l, theme t

set_drop_chance

Search script examples for set_drop_chance

nil set_drop_chance(int dropchance_id, int new_drop_chance)

Alters the drop chance for the provided monster-item combination (use e.g. set_drop_chance(DROPCHANCE.MOLE_MATTOCK, 10) for a 1 in 10 chance) Use -1 as dropchance_id to reset all to default

set_explosion_mask

Search script examples for set_explosion_mask

nil set_explosion_mask(int mask)

Sets which entities are affected by a bomb explosion. Default = MASK.PLAYER | MASK.MOUNT | MASK.MONSTER | MASK.ITEM | MASK.ACTIVEFLOOR | MASK.FLOOR

set_kapala_blood_threshold

Search script examples for set_kapala_blood_threshold

nil set_kapala_blood_threshold(int threshold)

Sets the amount of blood drops in the Kapala needed to trigger a health increase (default = 7).

set_kapala_hud_icon

Search script examples for set_kapala_hud_icon

nil set_kapala_hud_icon(int icon_index)

Sets the hud icon for the Kapala (0-6 ; -1 for default behaviour). If you set a Kapala treshold greater than 7, make sure to set the hud icon in the range 0-6, or other icons will appear in the hud!

set_max_rope_length

Search script examples for set_max_rope_length

nil set_max_rope_length(int length)

Sets the maximum length of a thrown rope (anchor segment not included). Unfortunately, setting this higher than default (6) creates visual glitches in the rope, even though it is fully functional.

set_olmec_cutscene_enabled

Search script examples for set_olmec_cutscene_enabled

nil set_olmec_cutscene_enabled(bool enable)

Olmec cutscene moves Olmec and destroys the four floor tiles, so those things never happen if the cutscene is disabled, and Olmec will spawn on even ground. More useful for level gen mods, where the cutscene doesn't make sense. You can also set olmec_cutscene.timer to the last frame (809) to skip to the end, with Olmec in the hole.

set_olmec_phase_y_level

Search script examples for set_olmec_phase_y_level

nil set_olmec_phase_y_level(int phase, float y)

Sets the Y-level at which Olmec changes phases

set_time_ghost_enabled

Search script examples for set_time_ghost_enabled

nil set_time_ghost_enabled(bool b)

Determines whether the time ghost appears, including the showing of the ghost toast

set_time_jelly_enabled

Search script examples for set_time_jelly_enabled

nil set_time_jelly_enabled(bool b)

Determines whether the time jelly appears in cosmic ocean

unequip_backitem

Search script examples for unequip_backitem

nil unequip_backitem(int who_uid)

Unequips the currently worn backitem

unlock_door_at

Search script examples for unlock_door_at

nil unlock_door_at(float x, float y)

Try to unlock the exit at coordinates

waddler_count_entity

Search script examples for waddler_count_entity

int waddler_count_entity(ENT_TYPE entity_type)

Returns how many of a specific entity type Waddler has stored

waddler_entity_type_in_slot

Search script examples for waddler_entity_type_in_slot

int waddler_entity_type_in_slot(int slot)

Gets the entity type of the item in the provided slot

waddler_get_entity_meta

Search script examples for waddler_get_entity_meta

int waddler_get_entity_meta(int slot)

Gets the 16-bit meta-value associated with the entity type in the associated slot

waddler_remove_entity

Search script examples for waddler_remove_entity

nil waddler_remove_entity(ENT_TYPE entity_type, int amount_to_remove = 99)

Removes an entity type from Waddler's storage. Second param determines how many of the item to remove (default = remove all)

waddler_set_entity_meta

Search script examples for waddler_set_entity_meta

nil waddler_set_entity_meta(int slot, int meta)

Sets the 16-bit meta-value associated with the entity type in the associated slot

waddler_store_entity

Search script examples for waddler_store_entity

int waddler_store_entity(ENT_TYPE entity_type)

Store an entity type in Waddler's storage. Returns the slot number the item was stored in or -1 when storage is full and the item couldn't be stored.

worn_backitem

Search script examples for worn_backitem

int worn_backitem(int who_uid)

Returns the uid of the currently worn backitem, or -1 if wearing nothing

Feat functions

change_feat

Search script examples for change_feat

nil change_feat(FEAT feat, bool hidden, string name, string description)

Helper function to set the title and description strings for a FEAT with change_string, as well as the hidden state.

get_feat

Search script examples for get_feat

tuple<bool, bool, string, string> get_feat(FEAT feat)

Check if the user has performed a feat (Real Steam achievement or a hooked one). Returns: bool unlocked, bool hidden, string name, string description

get_feat_hidden

Search script examples for get_feat_hidden

bool get_feat_hidden(FEAT feat)

Get the visibility of a feat

set_feat_hidden

Search script examples for set_feat_hidden

nil set_feat_hidden(FEAT feat, bool hidden)

Set the visibility of a feat

Flag functions

clr_flag

Search script examples for clr_flag

Flags clr_flag(Flags flags, int bit)

Clears the nth bit in a number. This doesn't actually change the variable you pass, it just returns the new value you can use.

clr_mask

Search script examples for clr_mask

Flags clr_mask(Flags flags, Flags mask)

Clears a bitmask in a number. This doesn't actually change the variable you pass, it just returns the new value you can use.

flip_flag

Search script examples for flip_flag

Flags flip_flag(Flags flags, int bit)

Flips the nth bit in a number. This doesn't actually change the variable you pass, it just returns the new value you can use.

flip_mask

Search script examples for flip_mask

Flags flip_mask(Flags flags, Flags mask)

Flips the nth bit in a number. This doesn't actually change the variable you pass, it just returns the new value you can use.

get_entity_flags

Search script examples for get_entity_flags

int get_entity_flags(int uid)

Get the flags field from entity by uid

get_entity_flags2

Search script examples for get_entity_flags2

int get_entity_flags2(int uid)

Get the more_flags field from entity by uid

get_level_flags

Search script examples for get_level_flags

int get_level_flags()

Get state.level_flags

set_entity_flags

Search script examples for set_entity_flags

nil set_entity_flags(int uid, int flags)

Set the flags field from entity by uid

set_entity_flags2

Search script examples for set_entity_flags2

nil set_entity_flags2(int uid, int flags)

Set the more_flags field from entity by uid

set_flag

Search script examples for set_flag

Flags set_flag(Flags flags, int bit)

Set the nth bit in a number. This doesn't actually change the variable you pass, it just returns the new value you can use.

set_level_flags

Search script examples for set_level_flags

nil set_level_flags(int flags)

Set state.level_flags

set_mask

Search script examples for set_mask

Flags set_mask(Flags flags, Flags mask)

Set a bitmask in a number. This doesn't actually change the variable you pass, it just returns the new value you can use.

test_flag

Search script examples for test_flag

bool test_flag(Flags flags, int bit)

Returns true if the nth bit is set in the number.

test_mask

Search script examples for test_mask

bool test_mask(Flags flags, Flags mask)

Returns true if a bitmask is set in the number.

Generic functions

activate_crush_elevator_hack

Search script examples for activate_crush_elevator_hack

nil activate_crush_elevator_hack(bool activate)

Activate custom variables for speed and y coordinate limit for crushing elevator note: because those variables are custom and game does not initiate them, you need to do it yourself for each CrushElevator entity, recommending set_post_entity_spawn default game values are: speed = 0.0125, y_limit = 98.5

activate_hundun_hack

Search script examples for activate_hundun_hack

nil activate_hundun_hack(bool activate)

Activate custom variables for y coordinate limit for hundun and spawn of it's heads note: because those variables are custom and game does not initiate them, you need to do it yourself for each Hundun entity, recommending set_post_entity_spawn default game value are: y_limit = 98.5, rising_speed_x = 0, rising_speed_y = 0.0125, bird_head_spawn_y = 55, snake_head_spawn_y = 71

add_custom_type

Search script examples for add_custom_type

ENT_TYPE add_custom_type(array<ENT_TYPE> types)

ENT_TYPE add_custom_type()

Adds new custom type (group of ENT_TYPE) that can be later used in functions like get_entities_by or set_(pre/post)_entity_spawn Use empty array or no parameter to get new unique ENT_TYPE that can be used for custom EntityDB

add_money

Search script examples for add_money

int add_money(int amount, optional display_time)

Adds money to the state.money_shop_total and displays the effect on the HUD for money change Can be negative, default display_time = 60 (about 2s). Returns the current money after the transaction

add_money_slot

Search script examples for add_money_slot

int add_money_slot(int amount, int player_slot, optional display_time)

Adds money to the state.items.player_inventory[player_slot].money and displays the effect on the HUD for money change Can be negative, default display_time = 60 (about 2s). Returns the current money after the transaction

change_poison_timer

Search script examples for change_poison_timer

nil change_poison_timer(int frames)

Change the amount of frames after the damage from poison is applied

clear_cache

Search script examples for clear_cache

nil clear_cache()

Clear cache for a file path or the whole directory

clear_state

Search script examples for clear_state

nil clear_state(int slot)

Clear save state from slot 1..4.

create_image

Search script examples for create_image

tuple<IMAGE, int, int> create_image(string path)

Create image from file. Returns a tuple containing id, width and height. Depending on the image size, this can take a moment, preferably don't create them dynamically, rather create all you need in global scope so it will load them as soon as the game starts

create_image_crop

Search script examples for create_image_crop

tuple<IMAGE, int, int> create_image_crop(string path, int x, int y, int w, int h)

Create image from file, cropped to the geometry provided. Returns a tuple containing id, width and height. Depending on the image size, this can take a moment, preferably don't create them dynamically, rather create all you need in global scope so it will load them as soon as the game starts

create_layer

Search script examples for create_layer

nil create_layer(int layer)

Initializes an empty layer that doesn't currently exist.

create_level

Search script examples for create_level

nil create_level()

Initializes an empty front and back layer that don't currently exist. Does nothing(?) if layers already exist.

destroy_grid

Search script examples for destroy_grid

nil destroy_grid(int uid)

nil destroy_grid(float x, float y, LAYER layer)

Destroy the grid entity (by uid or position), and its item entities, removing them from the grid without dropping particles or gold. Will also destroy monsters or items that are standing on a linked activefloor or chain, though excludes MASK.PLAYER to prevent crashes

destroy_layer

Search script examples for destroy_layer

nil destroy_layer(int layer)

Destroys a layer and all entities in it.

destroy_level

Search script examples for destroy_level

nil destroy_level()

Destroys all layers and all entities in the level. Usually a bad idea, unless you also call create_level and spawn the player back in.

disable_floor_embeds

Search script examples for disable_floor_embeds

bool disable_floor_embeds(bool disable)

Disable all crust item spawns, returns whether they were already disabled before the call

force_journal

Search script examples for force_journal

nil force_journal(int chapter, int entry)

Force the journal to open on a chapter and entry# when pressing the journal button. Only use even entry numbers. Set chapter to JOURNALUI_PAGE_SHOWN.JOURNAL to reset. (This forces the journal toggle to always read from game_manager.save_related.journal_popup_ui.entry_to_show etc.)

get_adventure_seed

Search script examples for get_adventure_seed

tuple<int, int> get_adventure_seed(optional run_start)

Get the current adventure seed pair, or optionally what it was at the start of this run, because it changes every level.

get_bucket

Search script examples for get_bucket

Bucket get_bucket()

Returns the Bucket of data stored in shared memory between Overlunky and Playlunky

get_character_heart_color

Search script examples for get_character_heart_color

Color get_character_heart_color(ENT_TYPE type_id)

Same as Player.get_heart_color

get_color

Search script examples for get_color

uColor get_color(string color_name, optional alpha = nullopt)

Convert a string to a color, you can use the HTML color names, or even HTML color codes, just prefix them with '#' symbol You can also convert hex string into a color, prefix it with '0x', but use it only if you need to since lua allows for hex values directly too. Default alpha value will be 0xFF, unless it's specified Format: [name], #RRGGBB, #RRGGBBAA, 0xBBGGRR, 0xAABBGGRR

get_current_money

Search script examples for get_current_money

int get_current_money()

Just convenient way of getting the current amount of money short for state->money_shop_total + loop[inventory.money + inventory.collected_money_total]

get_frame

Search script examples for get_frame

int get_frame()

Get the current frame count since the game was started. You can use this to make some timers yourself, the engine runs at 60fps. This counter is paused if you block PRE_UPDATE from running, and also doesn't increment during some loading screens, even though state update still runs.

get_frametime

Search script examples for get_frametime

double get_frametime()

Get engine target frametime (1/framerate, default 1/60).

get_frametime_unfocused

Search script examples for get_frametime_unfocused

double get_frametime_unfocused()

Get engine target frametime when game is unfocused (1/framerate, default 1/33).

get_global_frame

Search script examples for get_global_frame

int get_global_frame()

Get the current global frame count since the game was started. You can use this to make some timers yourself, the engine runs at 60fps. This counter keeps incrementing when state is updated, even during loading screens.

get_hud

Search script examples for get_hud

HudData get_hud()

get_id

Search script examples for get_id

string get_id()

Get your sanitized script id to be used in import.

get_level_config

Search script examples for get_level_config

int get_level_config(LEVEL_CONFIG config)

Gets the value for the specified config

get_liquid_layer

Search script examples for get_liquid_layer

int get_liquid_layer()

Get the current layer that the liquid is spawn in. Related function set_liquid_layer

get_local_prng

Search script examples for get_local_prng

nil get_local_prng()

Get the thread-local version of prng

get_local_state

Search script examples for get_local_state

nil get_local_state()

Get the thread-local version of state

get_ms

Search script examples for get_ms

nil get_ms()

Get the current timestamp in milliseconds since the Unix Epoch.

get_performance_counter

Search script examples for get_performance_counter

int get_performance_counter()

Retrieves the current value of the performance counter, which is a high resolution (<1us) time stamp that can be used for time-interval measurements.

get_performance_frequency

Search script examples for get_performance_frequency

int get_performance_frequency()

Retrieves the frequency of the performance counter. The frequency of the performance counter is fixed at system boot and is consistent across all processors. Therefore, the frequency need only be queried upon application initialization, and the result can be cached.

get_save_state

Search script examples for get_save_state

StateMemory get_save_state(int slot)

Get StateMemory from a save_state slot.

get_setting

Search script examples for get_setting

optional<int> get_setting(GAME_SETTING setting)

Gets the specified setting, values might need to be interpreted differently per setting

get_speedhack

Search script examples for get_speedhack

float get_speedhack()

Get the current speedhack multiplier

get_start_level_paused

Search script examples for get_start_level_paused

bool get_start_level_paused()

Returns true if the level pause hack is enabled

god

Search script examples for god

nil god(bool g)

Enable/disable godmode for players.

god_companions

Search script examples for god_companions

nil god_companions(bool g)

Enable/disable godmode for companions.

grow_chainandblocks

Search script examples for grow_chainandblocks

bool grow_chainandblocks()

bool grow_chainandblocks(int x, int y)

Grow chains from ENT_TYPE_FLOOR_CHAIN_CEILING and chain with blocks on it from ENT_TYPE_FLOOR_CHAINANDBLOCKS_CEILING, it starts looking for the ceilings from the top left corner of a level. To limit it use the parameters, so x = 10 will only grow chains from ceilings with x < 10, with y = 10 it's ceilings that have y > (level bound top - 10)

grow_poles

Search script examples for grow_poles

nil grow_poles(LAYER l, int max_length, AABB area, bool destroy_broken)

nil grow_poles(LAYER l, int max_length)

Grow pole from GROWABLE_CLIMBING_POLE entities in a level, area default is whole level, destroy_broken default is false

grow_vines

Search script examples for grow_vines

nil grow_vines(LAYER l, int max_length, AABB area, bool destroy_broken)

nil grow_vines(LAYER l, int max_length)

Grow vines from GROWABLE_VINE and VINE_TREE_TOP entities in a level, area default is whole level, destroy_broken default is false

import

Search script examples for import

table import(string id, optional version, optional optional)

Load another script by id "author/name" and import its exports table. Returns:

inputs_to_buttons

Search script examples for inputs_to_buttons

tuple<float, float, BUTTON> inputs_to_buttons(INPUTS inputs)

Converts INPUTS to (x, y, BUTTON)

intersection

Search script examples for intersection

Vec2 intersection(Vec2 A, Vec2 B, Vec2 C, Vec2 D)

Find intersection point of two lines [A, B] and [C, D], returns INFINITY if the lines don't intersect each other [parallel]

is_character_female

Search script examples for is_character_female

bool is_character_female(ENT_TYPE type_id)

Same as Player.is_female

list_char_mods

Search script examples for list_char_mods

nil list_char_mods()

List all char_*.png files recursively from Mods/Packs. Returns table of file paths.

list_data_dir

Search script examples for list_data_dir

nil list_data_dir(optional dir)

List files in directory relative to the mods data directory (Mods/Data/...). Returns table of file/directory names or nil if not found.

list_dir

Search script examples for list_dir

nil list_dir(optional dir)

List files in directory relative to the script root. Returns table of file/directory names or nil if not found.

load_death_screen

Search script examples for load_death_screen

nil load_death_screen()

Immediately ends the run with the death screen, also calls the save_progress

load_screen

Search script examples for load_screen

nil load_screen()

Immediately load a screen based on state.screen_next and stuff

load_state

Search script examples for load_state

nil load_state(int slot)

Load level state from slot 1..4, if a save_state was made in this level.

lowbias32

Search script examples for lowbias32

int lowbias32(int x)

Some random hash function

lowbias32_r

Search script examples for lowbias32_r

int lowbias32_r(int x)

Reverse of some random hash function

pause

Search script examples for pause

nil pause()

Access the PauseAPI, or directly call pause(true) to enable current pause.pause_type

play_adventure

Search script examples for play_adventure

nil play_adventure()

Initializes some adventure run related values and loads the character select screen, as if starting a new adventure run from the Play menu. Character select can be skipped by changing state.screen_next right after calling this function, maybe with warp(). If player isn't already selected, make sure to set state.items.player_select and state.items.player_count appropriately too.

play_seeded

Search script examples for play_seeded

nil play_seeded(optional seed)

Initializes some seedeed run related values and loads the character select screen, as if starting a new seeded run after entering the seed.

register_console_command

Search script examples for register_console_command

nil register_console_command(string name, function cmd)

Adds a command that can be used in the console.

rgba

Search script examples for rgba

uColor rgba(int r, int g, int b, int a)

Converts a color to int to be used in drawing functions. Use values from 0..255.

save_progress

Search script examples for save_progress

bool save_progress()

Saves the game to savegame.sav, unless game saves are blocked in the settings. Also runs the ON.SAVE callback. Fails and returns false, if you're trying to save too often (2s).

save_script

Search script examples for save_script

bool save_script()

Runs the ON.SAVE callback. Fails and returns false, if you're trying to save too often (2s).

save_state

Search script examples for save_state

nil save_state(int slot)

Save current level state to slot 1..4. These save states are invalid and cleared after you exit the current level, but can be used to rollback to an earlier state in the same level. You probably definitely shouldn't use save state functions during an update, and sync them to the same event outside an update (i.e. GUIFRAME, POST_UPDATE). These slots are already allocated by the game, actually used for online rollback, and use no additional memory. Also see SaveState if you need more.

script_enabled

Search script examples for script_enabled

bool script_enabled(string id, string version = "")

Check if another script is enabled by id "author/name". You should probably check this after all the other scripts have had a chance to load.

seed_prng

Search script examples for seed_prng

nil seed_prng(int seed)

Seed the game prng.

set_adventure_seed

Search script examples for set_adventure_seed

nil set_adventure_seed(int first, int second)

Set the current adventure seed pair. Use just before resetting a run to recreate an adventure run.

set_camera_layer_control_enabled

set_camera_layer_control_enabled(false)

g_current_timer = nil
-- default load_time 36
function change_layer(layer_to, load_time)

    if state.camera_layer == layer_to then
        return
    end
    if g_current_timer ~= nil then
        clear_callback(g_current_timer)
        g_current_timer = nil
    end
    -- if we don't want the load time, we can just change the actual layer
    if load_time == nil or load_time == 0 then
        state.camera_layer = layer_to
        return
    end

    state.layer_transition_timer = load_time
    state.transition_to_layer = layer_to
    state.camera_layer = layer_to
end

Search script examples for set_camera_layer_control_enabled

nil set_camera_layer_control_enabled(bool enable)

This disables the state.camera_layer to be forced to the (leader player).layer and setting of the state.layer_transition_timer & state.transition_to_layer when player enters layer door. Letting you control those manually. Look at the example on how to mimic game layer switching behavior

set_character_heart_color

Search script examples for set_character_heart_color

nil set_character_heart_color(ENT_TYPE type_id, Color color)

Same as Player.set_heart_color

set_ending_unlock

-- change character unlocked by endings to pilot
set_ending_unlock(ENT_TYPE.CHAR_PILOT)

-- change texture of the actual savior in endings to pilot
set_callback(function()
    set_post_entity_spawn(function(ent)
        if state.screen == SCREEN.WIN then
            ent:set_texture(TEXTURE.DATA_TEXTURES_CHAR_PINK_0)
        end
        clear_callback()
    end, SPAWN_TYPE.SYSTEMIC, MASK.PLAYER)
end, ON.WIN)

Search script examples for set_ending_unlock

nil set_ending_unlock(ENT_TYPE type)

Force the character unlocked in either ending to ENT_TYPE. Set to 0 to reset to the default guys. Does not affect the texture of the actual savior. (See example)

set_frametime

Search script examples for set_frametime

nil set_frametime(optional frametime)

Set engine target frametime (1/framerate, default 1/60). Always capped by your GPU max FPS / VSync. To run the engine faster than rendered FPS, try update_state. Set to 0 to go as fast as possible. Call without arguments to reset. Also see set_speedhack

set_frametime_unfocused

Search script examples for set_frametime_unfocused

nil set_frametime_unfocused(optional frametime)

Set engine target frametime when game is unfocused (1/framerate, default 1/33). Always capped by the engine frametime. Set to 0 to go as fast as possible. Call without arguments to reset.

set_hotkey

Search script examples for set_hotkey

CallbackId set_hotkey(function cb, KEY key, HOTKEY_TYPE flags = HOTKEY_TYPE.NORMAL)

Returns unique id >= 0 for the callback to be used in clear_callback or -1 if the key could not be registered. Add callback function to be called on a hotkey, using Windows hotkey api. These hotkeys will override all game and UI input and can work even when the game is unfocused. They are by design very intrusive and won't let anything else use the same key combo. Can't detect if input is active in another instance, use ImGuiIO if you need Playlunky hotkeys to react to Overlunky input state. Key is a KEY combo (e.g. KEY.OL_MOD_CTRL | KEY.X), possibly returned by GuiDrawContext:key_picker. Doesn't work with mouse buttons.
The callback signature is nil on_hotkey(KEY key)

set_infinite_loop_detection_enabled

Search script examples for set_infinite_loop_detection_enabled

nil set_infinite_loop_detection_enabled(bool enable)

Disable the Infinite Loop Detection of 420 million instructions per frame, if you know what you're doing and need to perform some serious calculations that hang the game updates for several seconds.

set_journal_enabled

Search script examples for set_journal_enabled

nil set_journal_enabled(bool b)

Enables or disables the journal

set_level_config

Search script examples for set_level_config

nil set_level_config(LEVEL_CONFIG config, int value)

Set the value for the specified config

set_level_logic_enabled

Search script examples for set_level_logic_enabled

nil set_level_logic_enabled(bool enable)

Setting to false disables all player logic in SCREEN.LEVEL, mainly the death screen from popping up if all players are dead or missing, but also shop camera zoom and some other small things.

set_liquid_layer

Search script examples for set_liquid_layer

nil set_liquid_layer(LAYER l)

Change layer at which the liquid spawns in, THIS FUNCTION NEEDS TO BE CALLED BEFORE THE LEVEL IS BUILD, otherwise collisions and other stuff will be wrong for the newly spawned liquid This sadly also makes lavamanders extinct, since the logic for their spawn is hardcoded to front layer with bunch of other unrelated stuff (you can still spawn them with script or place them directly in level files) Everything should be working more or less correctly (report on community discord if you find something unusual)

set_seed

Search script examples for set_seed

nil set_seed(int seed)

Set seed and reset run.

set_setting

-- set some visual settings needed by your mod
-- doing this here will reapply these after visiting the options, which would reset them to real values

set_callback(function()
    if state.screen_next == SCREEN.LEVEL then
        -- use the secret tiny hud size
        set_setting(GAME_SETTING.HUD_SIZE, 3)
        -- force opaque textboxes
        set_setting(GAME_SETTING.TEXTBOX_OPACITY, 0)
    end
end, ON.PRE_LOAD_SCREEN)

Search script examples for set_setting

bool set_setting(GAME_SETTING setting, int value)

Sets the specified setting temporarily. These values are not saved and might reset to the users real settings if they visit the options menu. (Check example.) All settings are available in unsafe mode and only a smaller subset SAFE_SETTING by default for Hud and other visuals. Returns false, if setting failed.

set_speedhack

Search script examples for set_speedhack

nil set_speedhack(optional multiplier)

Set multiplier (default 1.0) for a QueryPerformanceCounter hook based speedhack, similar to the one in Cheat Engine. Call without arguments to reset. Also see set_frametime

set_start_level_paused

Search script examples for set_start_level_paused

nil set_start_level_paused(bool enable)

Setting to true will stop the state update from unpausing after a screen load, leaving you with state.pause == PAUSE.FADE on the first frame to do what you want.

set_storage_layer

-- Sets the right layer when using the vanilla tile code if waddler is still happy,
-- otherwise spawns the floor to the left of this tile.
-- Manually spawning FLOOR_STORAGE pre-tilecode doesn't seem to work as expected,
-- so we destroy it post-tilecode.
set_post_tile_code_callback(function(x, y, layer)
    if not test_flag(state.quest_flags, 10) then
        -- Just set the layer and let the vanilla tilecode handle the floor
        set_storage_layer(layer)
    else
        local floor = get_entity(get_grid_entity_at(x, y, layer))
        if floor then
            floor:destroy()
        end
        if get_grid_entity_at(x - 1, y, layer) ~= -1 then
            local left = get_entity(get_grid_entity_at(x - 1, y, layer))
            spawn_grid_entity(left.type.id, x, y, layer)
        end
    end
end, "storage_floor")

-- This fixes a bug in the game that breaks storage on transition.
-- The old storage_uid is not cleared after every level for some reason.
set_callback(function()
    state.storage_uid = -1
end, ON.TRANSITION)

-- Having a waddler is completely optional for storage,
-- but this makes a nice waddler room if he still likes you.
define_tile_code("waddler")
set_pre_tile_code_callback(function(x, y, layer)
    if not test_flag(state.quest_flags, 10) then
        local uid = spawn_roomowner(ENT_TYPE.MONS_STORAGEGUY, x + 0.5, y, layer, ROOM_TEMPLATE.WADDLER)
        set_on_kill(uid, function()
            -- Disable current level storage if you kill waddler
            state.storage_uid = -1
        end)
    end
    return true
end, "waddler")

Search script examples for set_storage_layer

nil set_storage_layer(LAYER layer)

Set layer to search for storage items on

set_tiamat_cutscene_enabled

Search script examples for set_tiamat_cutscene_enabled

nil set_tiamat_cutscene_enabled(bool enable)

Tiamat cutscene is also responsible for locking the exit door, so you may need to close it yourself if you still want Tiamat kill to be required

show_journal

Search script examples for show_journal

nil show_journal(JOURNALUI_PAGE_SHOWN chapter, int page)

Open the journal on a chapter and page. The main Journal spread is pages 0..1, so most chapters start at 2. Use even page numbers only.

toggle_journal

Search script examples for toggle_journal

nil toggle_journal()

Open or close the journal as if pressing the journal button. Will respect visible journal popups and force_journal.

two_lines_angle

Search script examples for two_lines_angle

float two_lines_angle(Vec2 A, Vec2 common, Vec2 B)

Measures angle between two lines with one common point

float two_lines_angle(Vec2 line1_A, Vec2 line1_B, Vec2 line2_A, Vec2 line2_B)

Gets line1_A, intersection point and line2_B and calls the 3 parameter version of this function

update_liquid_collision_at

Search script examples for update_liquid_collision_at

nil update_liquid_collision_at(float x, float y, bool add, optional<LAYER> layer = nullopt)

Updates the floor collisions used by the liquids, set add to false to remove tile of collision, set to true to add one optional layer parameter to be used when liquid was moved to back layer using set_liquid_layer

update_state

Search script examples for update_state

nil update_state()

Run state update manually, i.e. simulate one logic frame. Use in e.g. POST_UPDATE, but be mindful of infinite loops, this will cause another POST_UPDATE. Can even be called thousands of times to simulate minutes of gameplay in a few seconds.

warp

Search script examples for warp

nil warp(int w, int l, int t)

Warp to a level immediately.

Input functions

buttons_to_inputs

Search script examples for buttons_to_inputs

INPUTS buttons_to_inputs(float x, float y, BUTTON buttons)

Converts (x, y, BUTTON) to INPUTS

get_io

Search script examples for get_io

ImGuiIO get_io()

Returns: ImGuiIO for raw keyboard, mouse and xinput gamepad stuff.

get_raw_input

Search script examples for get_raw_input

RawInput get_raw_input()

Returns RawInput, a game structure for raw keyboard and controller state

mouse_position

Search script examples for mouse_position

tuple<float, float> mouse_position()

Current mouse cursor position in screen coordinates.

Lighting functions

create_illumination

Search script examples for create_illumination

Illumination create_illumination(Vec2 pos, Color color, LIGHT_TYPE type, float size, int flags, int uid, LAYER layer)

Illumination create_illumination(Color color, float size, float x, float y)

Illumination create_illumination(Color color, float size, int uid)

Creates a new Illumination. Don't forget to continuously call refresh_illumination, otherwise your light emitter fades out! Check out the illumination.lua script for an example.

refresh_illumination

Search script examples for refresh_illumination

nil refresh_illumination(Illumination illumination)

Refreshes an Illumination, keeps it from fading out (updates the timer, keeping it in sync with the game render)

Message functions

cancel_speechbubble

Search script examples for cancel_speechbubble

nil cancel_speechbubble()

cancel_toast

Search script examples for cancel_toast

nil cancel_toast()

console_prinspect

Search script examples for console_prinspect

nil console_prinspect(variadic_args objects)

Prinspect to in-game console.

console_print

Search script examples for console_print

nil console_print(string message)

Print a log message to in-game console with a comment identifying the script that sent it.

log_print

Search script examples for log_print

nil log_print(string message)

Log to spelunky.log

lua_print

Search script examples for lua_print

nil lua_print()

Standard lua print function, prints directly to the terminal but not to the game

message

Search script examples for message

nil message(string message)

Same as print

messpect

Search script examples for messpect

nil messpect(variadic_args objects)

Same as prinspect

prinspect

prinspect(state.level, state.level_next)
local some_stuff_in_a_table = {
    some = state.time_total,
    stuff = state.world
}
prinspect(some_stuff_in_a_table)

Search script examples for prinspect

nil prinspect(variadic_args objects)

Prints any type of object by first funneling it through inspect, no need for a manual tostring or inspect.

print

Search script examples for print

nil print(string message)

Print a log message on screen.

printf

Search script examples for printf

nil printf()

Short for print(string.format(...))

say

Search script examples for say

nil say(int entity_uid, string message, int sound_type, bool top)

Show a message coming from an entity

speechbubble_visible

Search script examples for speechbubble_visible

bool speechbubble_visible()

toast

Search script examples for toast

nil toast(string message)

Show a message that looks like a level feeling.

toast_visible

Search script examples for toast_visible

bool toast_visible()

Movable Behavior functions

make_custom_behavior

Search script examples for make_custom_behavior

CustomMovableBehavior make_custom_behavior(string behavior_name, int state_id, VanillaMovableBehavior base_behavior)

Make a CustomMovableBehavior, if base_behavior is nil you will have to set all of the behavior functions. If a behavior with behavior_name already exists for your script it will be returned instead.

Network functions

http_get

Search script examples for http_get

optional<string> http_get(string url)

Send a synchronous HTTP GET request and return response as a string or nil on an error

http_get_async

Search script examples for http_get_async

nil http_get_async(string url, function on_data)

Send an asynchronous HTTP GET request and run the callback when done. If there is an error, response will be nil and vice versa. The callback signature is nil on_data(string response, string error)

udp_listen

Search script examples for udp_listen

UdpServer udp_listen(string host, int port, function cb)

Start an UDP server on specified address and run callback when data arrives. Return a string from the callback to reply. Requires unsafe mode. The server will be closed once the handle is released.

udp_send

Search script examples for udp_send

nil udp_send(string host, int port, string msg)

Send data to specified UDP address. Requires unsafe mode.

Option functions

register_option_bool

register_option_bool("bomb_bag", "BombBag", "Spawn bomb bag at the start of every level", false)

set_callback(function()
    if options.bomb_bag then
        -- Spawn the bomb bag at player location thanks to the LAYER.PLAYER1
        spawn_entity_snapped_to_floor(ENT_TYPE.ITEM_PICKUP_BOMBBAG, 0, 0, LAYER.PLAYER1)
    end
end, ON.LEVEL)

Search script examples for register_option_bool

nil register_option_bool(string name, string desc, string long_desc, bool value)

Add a boolean option that the user can change in the UI. Read with options.name, value is the default.

register_option_button

Search script examples for register_option_button

nil register_option_button(string name, string desc, string long_desc, function on_click)

Add a button that the user can click in the UI. Sets the timestamp of last click on value and runs the callback function.

register_option_callback

Search script examples for register_option_callback

nil register_option_callback(string name, any value, function on_render)

Add custom options using the window drawing functions. Everything drawn in the callback will be rendered in the options window and the return value saved to options[name] or overwriting the whole options table if using and empty name. value is the default value, and pretty important because anything defined in the callback function will only be defined after the options are rendered. See the example for details.
The callback signature is optional on_render(GuiDrawContext draw_ctx)

register_option_combo

Search script examples for register_option_combo

nil register_option_combo(string name, string desc, string long_desc, string opts, int value)

Add a combobox option that the user can change in the UI. Read the int index of the selection with options.name. Separate opts with \0, with a double \0\0 at the end. value is the default index 1..n.

register_option_float

Search script examples for register_option_float

nil register_option_float(string name, string desc, string long_desc, float value, float min, float max)

Add a float option that the user can change in the UI. Read with options.name, value is the default. Keep in mind these are just soft limits, you can override them in the UI with double click.

register_option_int

Search script examples for register_option_int

nil register_option_int(string name, string desc, string long_desc, int value, int min, int max)

Add an integer option that the user can change in the UI. Read with options.name, value is the default. Keep in mind these are just soft limits, you can override them in the UI with double click.

register_option_string

Search script examples for register_option_string

nil register_option_string(string name, string desc, string long_desc, string value)

Add a string option that the user can change in the UI. Read with options.name, value is the default.

unregister_option

Search script examples for unregister_option

nil unregister_option(string name)

Removes an option by name. To make complicated conditionally visible options you should probably just use register_option_callback though.

Particle functions

advance_screen_particles

Search script examples for advance_screen_particles

nil advance_screen_particles(ParticleEmitterInfo particle_emitter)

Advances the state of the screen particle emitter (simulates the next positions, ... of all the particles in the emitter). Only used with screen particle emitters. See the particles.lua example script for more details.

extinguish_particles

Search script examples for extinguish_particles

nil extinguish_particles(ParticleEmitterInfo particle_emitter)

Extinguish a particle emitter (use the return value of generate_world_particles or generate_screen_particles as the parameter in this function)

generate_screen_particles

Search script examples for generate_screen_particles

ParticleEmitterInfo generate_screen_particles(PARTICLEEMITTER particle_emitter_id, float x, float y)

Generate particles of the specified type at a certain screen coordinate (use e.g. local emitter = generate_screen_particles(PARTICLEEMITTER.CHARSELECTOR_TORCHFLAME_FLAMES, 0.0, 0.0)). See the particles.lua example script for more details.

generate_world_particles

Search script examples for generate_world_particles

ParticleEmitterInfo generate_world_particles(PARTICLEEMITTER particle_emitter_id, int uid)

Generate particles of the specified type around the specified entity uid (use e.g. local emitter = generate_world_particles(PARTICLEEMITTER.PETTING_PET, players[1].uid)). You can then decouple the emitter from the entity with emitter.entity_uid = -1 and freely move it around. See the particles.lua example script for more details.

get_particle_type

Search script examples for get_particle_type

ParticleDB get_particle_type(PARTICLEEMITTER id)

Get the ParticleDB details of the specified ID

render_screen_particles

Search script examples for render_screen_particles

nil render_screen_particles(ParticleEmitterInfo particle_emitter)

Renders the particles to the screen. Only used with screen particle emitters. See the particles.lua example script for more details.

Position functions

activate_tiamat_position_hack

activate_tiamat_position_hack(true);

set_post_entity_spawn(function(ent)

    -- make them same as in the game, but relative to the tiamat entity
    ent.attack_x = ent.x - 1
    ent.attack_y = ent.y + 2

end, SPAWN_TYPE.ANY, 0, ENT_TYPE.MONS_TIAMAT)

Search script examples for activate_tiamat_position_hack

nil activate_tiamat_position_hack(bool activate)

Activate custom variables for position used for detecting the player (normally hardcoded) note: because those variables are custom and game does not initiate them, you need to do it yourself for each Tiamat entity, recommending set_post_entity_spawn default game values are: attack_x = 17.5 attack_y = 62.5

distance

Search script examples for distance

float distance(int uid_a, int uid_b)

Calculate the tile distance of two entities by uid

draw_text_size

-- draw text
set_callback(function(draw_ctx)
    -- get a random color
    local color = math.random(0, 0xffffffff)
    -- zoom the font size based on frame
    local size = (get_frame() % 199)+1
    local text = 'Awesome!'
    -- calculate size of text
    local w, h = draw_text_size(size, text)
    -- draw to the center of screen
    draw_ctx:draw_text(0-w/2, 0-h/2, size, text, color)
end, ON.GUIFRAME)

Search script examples for draw_text_size

tuple<float, float> draw_text_size(float size, string text)

Calculate the bounding box of text, so you can center it etc. Returns width, height in screen distance.

fix_liquid_out_of_bounds

-- call this in ON.FRAME if needed in your custom level
set_callback(fix_liquid_out_of_bounds, ON.FRAME)

Search script examples for fix_liquid_out_of_bounds

nil fix_liquid_out_of_bounds()

Removes all liquid that is about to go out of bounds, this would normally crash the game, but playlunky/overlunky patch this bug. The patch however does not destroy the liquids that fall pass the level bounds, so you may still want to use this function if you spawn a lot of liquid that may fall out of the level

game_position

Search script examples for game_position

tuple<float, float> game_position(float x, float y)

Get the game coordinates at the screen position (x, y)

get_aabb_bounds

Search script examples for get_aabb_bounds

AABB get_aabb_bounds()

Same as get_bounds but returns AABB struct instead of loose floats

get_bounds

-- Draw the level boundaries
set_callback(function(draw_ctx)
    local xmin, ymax, xmax, ymin = get_bounds()
    local sx, sy = screen_position(xmin, ymax) -- top left
    local sx2, sy2 = screen_position(xmax, ymin) -- bottom right
    draw_ctx:draw_rect(sx, sy, sx2, sy2, 4, 0, rgba(255, 255, 255, 255))
end, ON.GUIFRAME)

Search script examples for get_bounds

tuple<float, float, float, float> get_bounds()

Basically gets the absolute coordinates of the area inside the unbreakable bedrock walls, from wall to wall. Every solid entity should be inside these boundaries. The order is: left x, top y, right x, bottom y

get_camera_position

Search script examples for get_camera_position

tuple<float, float> get_camera_position()

Gets the current camera position in the level

get_hitbox

Search script examples for get_hitbox

AABB get_hitbox(int uid, optional extrude, optional offsetx, optional offsety)

Gets the hitbox of an entity, use extrude to make the hitbox bigger/smaller in all directions and offset to offset the hitbox in a given direction

get_hud_position

Search script examples for get_hud_position

AABB get_hud_position(int index)

Approximate bounding box of the player hud element for player index 1..4 based on user settings and player count

get_image_size

Search script examples for get_image_size

tuple<int, int> get_image_size(string path)

Get image size from file. Returns a tuple containing width and height.

get_position

Search script examples for get_position

tuple<float, float, int> get_position(int uid)

Get position x, y, layer of entity by uid. Use this, don't use Entity.x/y because those are sometimes just the offset to the entity you're standing on, not real level coordinates.

get_render_hitbox

Search script examples for get_render_hitbox

AABB get_render_hitbox(int uid, optional extrude, optional offsetx, optional offsety)

Same as get_hitbox but based on get_render_position

get_render_position

Search script examples for get_render_position

tuple<float, float, int> get_render_position(int uid)

Get interpolated render position x, y, layer of entity by uid. This gives smooth hitboxes for 144Hz master race etc...

get_velocity

Search script examples for get_velocity

tuple<float, float> get_velocity(int uid)

Get velocity vx, vy of an entity by uid. Use this, don't use Entity.velocityx/velocityy because those are relative to Entity.overlay.

get_window_size

Search script examples for get_window_size

tuple<int, int> get_window_size()

Gets the resolution (width and height) of the screen

get_zoom_level

Search script examples for get_zoom_level

float get_zoom_level()

Get the current set zoom level

position_is_valid

Search script examples for position_is_valid

bool position_is_valid(float x, float y, LAYER layer, POS_TYPE flags)

Check if position satisfies the given POS_TYPE flags, to be used in a custom is_valid function procedural for spawns.

screen_aabb

Search script examples for screen_aabb

AABB screen_aabb(AABB box)

Convert an AABB to a screen AABB that can be directly passed to draw functions

screen_distance

Search script examples for screen_distance

float screen_distance(float x)

Translate a distance of x tiles to screen distance to be be used in drawing functions

screen_position

Search script examples for screen_position

tuple<float, float> screen_position(float x, float y)

Translate an entity position to screen position to be used in drawing functions

set_camera_position

Search script examples for set_camera_position

nil set_camera_position(float cx, float cy)

Sets the absolute current camera position without rubberbanding animation. Ignores camera bounds or currently focused uid, but doesn't clear them. Best used in ON.RENDER_PRE_GAME or similar. See Camera for proper camera handling with bounds and rubberbanding.

set_camp_camera_bounds_enabled

Search script examples for set_camp_camera_bounds_enabled

nil set_camp_camera_bounds_enabled(bool b)

Enables or disables the default position based camp camera bounds, to set them manually yourself

update_camera_position

Search script examples for update_camera_position

nil update_camera_position()

Updates the camera focus according to the params set in Camera, i.e. to apply normal camera movement when paused etc.

zoom

Search script examples for zoom

nil zoom(float level)

Set the zoom level used in levels and shops. 13.5 is the default, or 12.5 for shops. See zoom_reset.

zoom_reset

Search script examples for zoom_reset

nil zoom_reset()

Reset the default zoom levels for all areas and sets current zoom level to 13.5.

Room functions

define_room_template

Search script examples for define_room_template

int define_room_template(string room_template, ROOM_TEMPLATE_TYPE type)

Define a new room template to use with set_room_template

get_room_index

Search script examples for get_room_index

tuple<int, int> get_room_index(float x, float y)

Transform a position to a room index to be used in get_room_template and PostRoomGenerationContext.set_room_template

get_room_pos

Search script examples for get_room_pos

tuple<float, float> get_room_pos(int x, int y)

Transform a room index into the top left corner position in the room

get_room_template

Search script examples for get_room_template

optional<int> get_room_template(int x, int y, LAYER layer)

Get the room template given a certain index, returns nil if coordinates are out of bounds

get_room_template_name

Search script examples for get_room_template_name

string get_room_template_name(int room_template)

For debugging only, get the name of a room template, returns 'invalid' if room template is not defined

is_machine_room_origin

Search script examples for is_machine_room_origin

bool is_machine_room_origin(int x, int y)

Get whether a room is the origin of a machine room

is_room_flipped

Search script examples for is_room_flipped

bool is_room_flipped(int x, int y)

Get whether a room is flipped at the given index, returns false if coordinates are out of bounds

set_room_template_size

Search script examples for set_room_template_size

bool set_room_template_size(int room_template, int width, int height)

Set the size of room template in tiles, the template must be of type ROOM_TEMPLATE_TYPE.MACHINE_ROOM.

spawn_roomowner

-- spawns waddler selling pets
-- all the aggro etc mechanics from a normal shop still apply
local x, y, l = get_position(get_player(1).uid)
local owner = spawn_roomowner(ENT_TYPE.MONS_STORAGEGUY, x+1, y, l, ROOM_TEMPLATE.SHOP)
add_item_to_shop(spawn_on_floor(ENT_TYPE.MONS_PET_DOG, x-1, y, l), owner)
add_item_to_shop(spawn_on_floor(ENT_TYPE.MONS_PET_CAT, x-2, y, l), owner)
add_item_to_shop(spawn_on_floor(ENT_TYPE.MONS_PET_HAMSTER, x-3, y, l), owner)

-- use in a tile code to add shops to custom levels
-- this may spawn some shop related decorations too
define_tile_code("pet_shop_boys")
set_pre_tile_code_callback(function(x, y, layer)
    local owner = spawn_roomowner(ENT_TYPE.MONS_YANG, x, y, layer, ROOM_TEMPLATE.SHOP)
    -- another dude for the meme, this has nothing to do with the shop
    spawn_on_floor(ENT_TYPE.MONS_BODYGUARD, x+1, y, layer)
    add_item_to_shop(spawn_on_floor(ENT_TYPE.MONS_PET_HAMSTER, x+2, y, layer), owner)
    return true
end, "pet_shop_boys")

Search script examples for spawn_roomowner

int spawn_roomowner(ENT_TYPE owner_type, float x, float y, LAYER layer, ROOM_TEMPLATE room_template = -1)

Spawn a RoomOwner (or a few other like CavemanShopkeeper) in the coordinates and make them own the room, optionally changing the room template. Returns the RoomOwner uid.

Shop functions

add_item_to_shop

Search script examples for add_item_to_shop

nil add_item_to_shop(int item_uid, int shop_owner_uid)

Adds entity as shop item, has to be of Purchasable type, check the entity hierarchy list to find all the Purchasable entity types. Adding other entities will result in not obtainable items or game crash

change_diceshop_prizes

Search script examples for change_diceshop_prizes

nil change_diceshop_prizes(array<ENT_TYPE> ent_types)

Change ENT_TYPE's spawned in dice shops (Madame Tusk as well), by default there are 25:
{ITEM_PICKUP_BOMBBAG, ITEM_PICKUP_BOMBBOX, ITEM_PICKUP_ROPEPILE, ITEM_PICKUP_COMPASS, ITEM_PICKUP_PASTE, ITEM_PICKUP_PARACHUTE, ITEM_PURCHASABLE_CAPE, ITEM_PICKUP_SPECTACLES, ITEM_PICKUP_CLIMBINGGLOVES, ITEM_PICKUP_PITCHERSMITT, ENT_TYPE_ITEM_PICKUP_SPIKESHOES, ENT_TYPE_ITEM_PICKUP_SPRINGSHOES, ITEM_MACHETE, ITEM_BOOMERANG, ITEM_CROSSBOW, ITEM_SHOTGUN, ITEM_FREEZERAY, ITEM_WEBGUN, ITEM_CAMERA, ITEM_MATTOCK, ITEM_PURCHASABLE_JETPACK, ITEM_PURCHASABLE_HOVERPACK, ITEM_TELEPORTER, ITEM_PURCHASABLE_TELEPORTER_BACKPACK, ITEM_PURCHASABLE_POWERPACK}
Min 6, Max 255, if you want less then 6 you need to write some of them more then once (they will have higher "spawn chance"). If you use this function in the level with diceshop in it, you have to update item_ids in the ITEM_DICE_PRIZE_DISPENSER. Use empty table as argument to reset to the game default

is_inside_active_shop_room

Search script examples for is_inside_active_shop_room

bool is_inside_active_shop_room(float x, float y, LAYER layer)

Checks whether a coordinate is inside a room containing an active shop. This function checks whether the shopkeeper is still alive.

is_inside_shop_zone

Search script examples for is_inside_shop_zone

bool is_inside_shop_zone(float x, float y, LAYER layer)

Checks whether a coordinate is inside a shop zone, the rectangle where the camera zooms in a bit. Does not check if the shop is still active!

spawn_shopkeeper

-- spawns a shopkeeper selling a shotgun next to you
-- converts the current room to a ROOM_TEMPLATE.SHOP with shop music and zoom effect
local x, y, l = get_position(get_player(1).uid)
local owner = spawn_shopkeeper(x+1, y, l)
add_item_to_shop(spawn_on_floor(ENT_TYPE.ITEM_SHOTGUN, x-1, y, l), owner)

-- spawns a shopkeeper selling a puppy next to you
-- also converts the room to a shop, but after the shopkeeper is spawned
-- this enables the safe zone for moving items, but disables shop music and zoom for whatever reason
local x, y, l = get_position(get_player(1).uid)
local owner = spawn_shopkeeper(x+1, y, l, ROOM_TEMPLATE.SIDE)
add_item_to_shop(spawn_on_floor(ENT_TYPE.MONS_PET_DOG, x-1, y, l), owner)
local ctx = PostRoomGenerationContext:new()
local rx, ry = get_room_index(x, y)
ctx:set_room_template(rx, ry, l, ROOM_TEMPLATE.SHOP)

Search script examples for spawn_shopkeeper

int spawn_shopkeeper(float x, float y, LAYER layer, ROOM_TEMPLATE room_template = ROOM_TEMPLATE.SHOP)

Spawn a Shopkeeper in the coordinates and make the room their shop. Returns the Shopkeeper uid. Also see spawn_roomowner.

Sound functions

create_sound

Search script examples for create_sound

optional<CustomSound> create_sound(string path)

Loads a sound from disk relative to this script, ownership might be shared with other code that loads the same file. Returns nil if file can't be found

get_sound

Search script examples for get_sound

optional<CustomSound> get_sound(string path_or_vanilla_sound)

Gets an existing sound, either if a file at the same path was already loaded or if it is already loaded by the game

play_sound

Search script examples for play_sound

SoundMeta play_sound(VANILLA_SOUND sound, int source_uid)

Spawn functions

change_altar_damage_spawns

Search script examples for change_altar_damage_spawns

nil change_altar_damage_spawns(array<ENT_TYPE> ent_types)

Change ENT_TYPE's spawned when you damage the altar, by default there are 6:
{MONS_BAT, MONS_BEE, MONS_SPIDER, MONS_JIANGSHI, MONS_FEMALE_JIANGSHI, MONS_VAMPIRE}
Max 255 types. Use empty table as argument to reset to the game default

change_sunchallenge_spawns

Search script examples for change_sunchallenge_spawns

nil change_sunchallenge_spawns(array<ENT_TYPE> ent_types)

Change ENT_TYPE's spawned by FLOOR_SUNCHALLENGE_GENERATOR, by default there are 4:
{MONS_WITCHDOCTOR, MONS_VAMPIRE, MONS_SORCERESS, MONS_NECROMANCER}
Use empty table as argument to reset to the game default

default_spawn_is_valid

Search script examples for default_spawn_is_valid

bool default_spawn_is_valid(float x, float y, LAYER layer)

Default function in spawn definitions to check whether a spawn is valid or not

define_extra_spawn

Search script examples for define_extra_spawn

int define_extra_spawn(function do_spawn, function is_valid, int num_spawns_frontlayer, int num_spawns_backlayer)

Define a new extra spawn, these are semi-guaranteed level gen spawns with a fixed upper bound. The function nil do_spawn(float x, float y, LAYER layer) contains your code to spawn the thing, whatever it is. The function bool is_valid(float x, float y, LAYER layer) determines whether the spawn is legal in the given position and layer. Use for example when you can spawn only on the ceiling, under water or inside a shop. Set is_valid to nil in order to use the default rule (aka. on top of floor and not obstructed). To change the number of spawns use PostRoomGenerationContext:set_num_extra_spawns during ON.POST_ROOM_GENERATION No name is attached to the extra spawn since it is not modified from level files, instead every call to this function will return a new unique id.

define_procedural_spawn

Search script examples for define_procedural_spawn

PROCEDURAL_CHANCE define_procedural_spawn(string procedural_spawn, function do_spawn, function is_valid)

Define a new procedural spawn, the function nil do_spawn(float x, float y, LAYER layer) contains your code to spawn the thing, whatever it is. The function bool is_valid(float x, float y, LAYER layer) determines whether the spawn is legal in the given position and layer. Use for example when you can spawn only on the ceiling, under water or inside a shop. Set is_valid to nil in order to use the default rule (aka. on top of floor and not obstructed). If a user disables your script but still uses your level mod nothing will be spawned in place of your procedural spawn.

door

Search script examples for door

int door(float x, float y, LAYER layer, int w, int l, int t)

Short for spawn_door.

get_missing_extra_spawns

Search script examples for get_missing_extra_spawns

tuple<int, int> get_missing_extra_spawns(int extra_spawn_chance_id)

Use to query whether any of the requested spawns could not be made, usually because there were not enough valid spaces in the level. Returns missing spawns in the front layer and missing spawns in the back layer in that order. The value only makes sense after level generation is complete, aka after ON.POST_LEVEL_GENERATION has run.

get_procedural_spawn_chance

Search script examples for get_procedural_spawn_chance

int get_procedural_spawn_chance(PROCEDURAL_CHANCE chance_id)

Get the inverse chance of a procedural spawn for the current level. A return value of 0 does not mean the chance is infinite, it means the chance is zero.

layer_door

Search script examples for layer_door

nil layer_door(float x, float y)

Short for spawn_layer_door.

set_ghost_spawn_times

Search script examples for set_ghost_spawn_times

nil set_ghost_spawn_times(int normal = 10800, int cursed = 9000)

Determines when the ghost appears, either when the player is cursed or not

spawn

-- spawn a jetpack next to the player
spawn(ENT_TYPE.ITEM_JETPACK, 1, 0, LAYER.PLAYER, 0, 0)

Search script examples for spawn

int spawn(ENT_TYPE entity_type, float x, float y, LAYER layer, float vx, float vy)

Short for spawn_entity.

spawn_apep

Search script examples for spawn_apep

int spawn_apep(float x, float y, LAYER layer, bool right)

Spawns apep with the choice if it going left or right, if you want the game to choose use regular spawn functions with ENT_TYPE.MONS_APEP_HEAD

spawn_companion

Search script examples for spawn_companion

int spawn_companion(ENT_TYPE companion_type, float x, float y, LAYER layer)

Spawn a companion (hired hand, player character, eggplant child)

spawn_critical

Search script examples for spawn_critical

int spawn_critical(ENT_TYPE entity_type, float x, float y, LAYER layer, float vx, float vy)

Short for spawn_entity_nonreplaceable.

spawn_door

Search script examples for spawn_door

int spawn_door(float x, float y, LAYER layer, int w, int l, int t)

Spawn a door to another world, level and theme and return the uid of spawned entity. Uses level coordinates with LAYER.FRONT and LAYER.BACK, but player-relative coordinates with LAYER.PLAYERn

spawn_entity

-- spawn megajelly on top of player using absolute coordinates on level start
set_callback(function()
    local x, y, layer = get_position(players[1].uid)
    spawn_entity(ENT_TYPE.MONS_MEGAJELLYFISH, x, y+3, layer, 0, 0)
end, ON.LEVEL)

-- spawn clover next to player using player-relative coordinates
set_callback(function()
    spawn(ENT_TYPE.ITEM_PICKUP_CLOVER, 1, 0, LAYER.PLAYER1, 0, 0)
end, ON.LEVEL)

Search script examples for spawn_entity

int spawn_entity(ENT_TYPE entity_type, float x, float y, LAYER layer, float vx, float vy)

Spawn an entity in position with some velocity and return the uid of spawned entity. Uses level coordinates with LAYER.FRONT and LAYER.BACK, but player-relative coordinates with LAYER.PLAYER(n), where (n) is a player number (1-4).

spawn_entity_nonreplaceable

Search script examples for spawn_entity_nonreplaceable

int spawn_entity_nonreplaceable(ENT_TYPE entity_type, float x, float y, LAYER layer, float vx, float vy)

Same as spawn_entity but does not trigger any pre-entity-spawn callbacks, so it will not be replaced by another script

spawn_entity_over

Search script examples for spawn_entity_over

int spawn_entity_over(ENT_TYPE entity_type, int over_uid, float x, float y)

Spawn an entity of entity_type attached to some other entity over_uid, in offset x, y

spawn_entity_snapped_to_floor

Search script examples for spawn_entity_snapped_to_floor

int spawn_entity_snapped_to_floor(ENT_TYPE entity_type, float x, float y, LAYER layer)

Spawns an entity directly on the floor below the tile at the given position. Use this to avoid the little fall that some entities do when spawned during level gen callbacks.

spawn_grid_entity

Search script examples for spawn_grid_entity

int spawn_grid_entity(ENT_TYPE entity_type, float x, float y, LAYER layer)

Spawn a grid entity, such as floor or traps, that snaps to the grid.

spawn_layer_door

Search script examples for spawn_layer_door

nil spawn_layer_door(float x, float y)

Spawn a door to backlayer.

spawn_liquid

Search script examples for spawn_liquid

nil spawn_liquid(ENT_TYPE entity_type, float x, float y)

nil spawn_liquid(ENT_TYPE entity_type, float x, float y, float velocityx, float velocityy, int liquid_flags, int amount, float blobs_separation)

Spawn liquids, always spawns in the front layer, will have fun effects if entity_type is not a liquid (only the short version, without velocity etc.). Don't overuse this, you are still restricted by the liquid pool sizes and thus might crash the game. liquid_flags - not much known about, 2 - will probably crash the game, 3 - pause_physics, 6-12 is probably agitation, surface_tension etc. set to 0 to ignore amount - it will spawn amount x amount (so 1 = 1, 2 = 4, 3 = 6 etc.), blobs_separation is optional

spawn_mushroom

Search script examples for spawn_mushroom

int spawn_mushroom(float x, float y, LAYER l, int height)

int spawn_mushroom(float x, float y, LAYER l)

Spawns and grows mushroom, height relates to the trunk, without it, it will roll the game default 3-5 height Regardless, if there is not enough space, it will spawn shorter one or if there is no space even for the smallest one, it will just not spawn at all Returns uid of the base or -1 if it wasn't able to spawn

spawn_on_floor

Search script examples for spawn_on_floor

int spawn_on_floor(ENT_TYPE entity_type, float x, float y, LAYER layer)

Short for spawn_entity_snapped_to_floor.

spawn_over

Search script examples for spawn_over

int spawn_over(ENT_TYPE entity_type, int over_uid, float x, float y)

Short for spawn_entity_over

spawn_player

Search script examples for spawn_player

int spawn_player(int player_slot, optional x, optional y, optional<LAYER> layer)

Spawn a player in given location, if player of that slot already exist it will spawn clone, the game may crash as this is very unexpected situation If you want to respawn a player that is a ghost, set in his Inventory health to above 0, and time_of_death to 0 and call this function, the ghost entity will be removed automatically

spawn_playerghost

Search script examples for spawn_playerghost

int spawn_playerghost(ENT_TYPE char_type, float x, float y, LAYER layer)

Spawn the PlayerGhost entity, it will not move and not be connected to any player, you can then use steal_input and send_input to control it or change it's player_inputs to the input of real player so he can control it directly

spawn_tree

Search script examples for spawn_tree

int spawn_tree(float x, float y, LAYER layer, int height)

int spawn_tree(float x, float y, LAYER layer)

Spawns and grows a tree

spawn_unrolled_player_rope

Search script examples for spawn_unrolled_player_rope

int spawn_unrolled_player_rope(float x, float y, LAYER layer, TEXTURE texture)

int spawn_unrolled_player_rope(float x, float y, LAYER layer, TEXTURE texture, int max_length)

Spawns an already unrolled rope as if created by player

String functions

add_custom_name

Search script examples for add_custom_name

nil add_custom_name(int uid, string name)

Adds custom name to the item by uid used in the shops This is better alternative to add_string but instead of changing the name for entity type, it changes it for this particular entity

add_string

Search script examples for add_string

STRINGID add_string(string str)

Add custom string, currently can only be used for names of shop items (EntityDB->description) Returns STRINGID of the new string

change_string

Search script examples for change_string

nil change_string(STRINGID id, string str)

Change string at the given id (don't use stringid diretcly for vanilla string, use hash_to_stringid first) This edits custom string and in game strings but changing the language in settings will reset game strings

clear_custom_name

Search script examples for clear_custom_name

nil clear_custom_name(int uid)

Clears the name set with add_custom_name

enum_get_mask_names

Search script examples for enum_get_mask_names

table<string> enum_get_mask_names(table enum, int value)

Return the matching names for a bitmask in an enum table of masks

enum_get_name

Search script examples for enum_get_name

string enum_get_name(table enum, int value)

Return the name of the first matching number in an enum table

enum_get_names

Search script examples for enum_get_names

table<string> enum_get_names(table enum, int value)

Return all the names of a number in an enum table

get_character_name

Search script examples for get_character_name

string get_character_name(ENT_TYPE type_id)

Same as Player.get_name

get_character_short_name

Search script examples for get_character_short_name

string get_character_short_name(ENT_TYPE type_id)

Same as Player.get_short_name

get_string

Search script examples for get_string

string get_string(STRINGID string_id)

Get string behind STRINGID, don't use stringid directly for vanilla string, use hash_to_stringid first Will return the string of currently choosen language

hash_to_stringid

Search script examples for hash_to_stringid

STRINGID hash_to_stringid(int hash)

Convert the hash to stringid Check strings00_hashed.str for the hash values, or extract assets with modlunky and check those.

key_name

Search script examples for key_name

string key_name()

Returns human readable string from KEY chord (e.g. "Ctrl+X", "Unknown" or "None")

set_level_string

-- set the level string shown in hud, journal and game over
-- also change the one used in transitions for consistency
set_callback(function()
    if state.screen_next == SCREEN.LEVEL then
        local level_str = "test" .. tostring(state.level_count)
        set_level_string(level_str)
        change_string(hash_to_stringid(0xda7c0c5b), F"{level_str} COMPLETED!")
    end
end, ON.PRE_LOAD_SCREEN)

Search script examples for set_level_string

nil set_level_string(string str)

Set the level number shown in the hud and journal to any string. This is reset to the default "%d-%d" automatically just before PRE_LOAD_SCREEN to a level or main menu, so use in PRE_LOAD_SCREEN, POST_LEVEL_GENERATION or similar for each level. Use "%d-%d" to reset to default manually. Does not affect the "...COMPLETED!" message in transitions or lines in "Dear Journal", you need to edit them separately with change_string.

Texture functions

define_texture

Search script examples for define_texture

TEXTURE define_texture(TextureDefinition texture_data)

Defines a new texture that can be used in Entity::set_texture If a texture with the same definition already exists the texture will be reloaded from disk.

get_texture

Search script examples for get_texture

optional<TEXTURE> get_texture(TextureDefinition texture_data)

Gets a texture with the same definition as the given, if none exists returns nil

get_texture_definition

Search script examples for get_texture_definition

TextureDefinition get_texture_definition(TEXTURE texture_id)

Gets a TextureDefinition for equivalent to the one used to define the texture with id

reload_texture

Search script examples for reload_texture

nil reload_texture(string texture_path)

Reloads a texture from disk, use this only as a development tool for example in the console Note that define_texture will also reload the texture if it already exists

replace_texture

Search script examples for replace_texture

bool replace_texture(TEXTURE vanilla_id, TEXTURE custom_id)

Replace a vanilla texture definition with a custom texture definition and reload the texture.

replace_texture_and_heart_color

Search script examples for replace_texture_and_heart_color

bool replace_texture_and_heart_color(TEXTURE vanilla_id, TEXTURE custom_id)

Replace a vanilla texture definition with a custom texture definition and reload the texture. Set corresponding character heart color to the pixel in the center of the player indicator arrow in that texture. (448,1472)

reset_lut

Search script examples for reset_lut

nil reset_lut(LAYER layer)

Same as set_lut(nil, layer)

reset_texture

Search script examples for reset_texture

nil reset_texture(TEXTURE vanilla_id)

Reset a replaced vanilla texture to the original and reload the texture.

set_lut

Search script examples for set_lut

nil set_lut(optional<TEXTURE> texture_id, LAYER layer)

Force the LUT texture for the given layer (or both) until it is reset. Pass nil in the first parameter to reset

Theme functions

force_co_subtheme

Search script examples for force_co_subtheme

nil force_co_subtheme(COSUBTHEME subtheme)

Forces the theme of the next cosmic ocean level(s) (use e.g. force_co_subtheme(COSUBTHEME.JUNGLE). Use COSUBTHEME.RESET to reset to default random behaviour)

force_custom_subtheme

Search script examples for force_custom_subtheme

nil force_custom_subtheme(CustomTheme|ThemeInfo|THEME customtheme)

Force current subtheme used in the CO theme. You can pass a CustomTheme, ThemeInfo or THEME. Not to be confused with force_co_subtheme.

force_custom_theme

Search script examples for force_custom_theme

nil force_custom_theme(CustomTheme|ThemeInfo|THEME customtheme)

Force a theme in PRE_LOAD_LEVEL_FILES, POST_ROOM_GENERATION or PRE_LEVEL_GENERATION to change different aspects of the levelgen. You can pass a CustomTheme, ThemeInfo or THEME.

get_co_subtheme

Search script examples for get_co_subtheme

COSUBTHEME get_co_subtheme()

Gets the sub theme of the current cosmic ocean level, returns COSUBTHEME.NONE if the current level is not a CO level.

Tile code functions

define_tile_code

Search script examples for define_tile_code

TILE_CODE define_tile_code(string tile_code)

Define a new tile code, to make this tile code do anything you have to use either set_pre_tile_code_callback or set_post_tile_code_callback. If a user disables your script but still uses your level mod nothing will be spawned in place of your tile code.

get_short_tile_code

Search script examples for get_short_tile_code

optional<int> get_short_tile_code(ShortTileCodeDef short_tile_code_def)

Gets a short tile code based on definition, returns nil if it can't be found

get_short_tile_code_definition

Search script examples for get_short_tile_code_definition

optional<ShortTileCodeDef> get_short_tile_code_definition(SHORT_TILE_CODE short_tile_code)

Gets the definition of a short tile code (if available), will vary depending on which file is loaded

set_post_tile_code_callback

Search script examples for set_post_tile_code_callback

CallbackId set_post_tile_code_callback(function cb, string tile_code)

Add a callback for a specific tile code that is called after the game handles the tile code. Use this to affect what the game or other scripts spawned in this position. This is received even if a previous pre-tile-code-callback has returned true
The callback signature is nil post_tile_code(float x, float y, int layer, ROOM_TEMPLATE room_template)

set_pre_tile_code_callback

Search script examples for set_pre_tile_code_callback

CallbackId set_pre_tile_code_callback(function cb, string tile_code)

Add a callback for a specific tile code that is called before the game handles the tile code. Return true in order to stop the game or scripts loaded after this script from handling this tile code. For example, when returning true in this callback set for "floor" then no floor will spawn in the game (unless you spawn it yourself)
The callback signature is bool pre_tile_code(float x, float y, int layer, ROOM_TEMPLATE room_template)

Deprecated functions

on_frame

Use set_callback(function, ON.FRAME) instead

on_camp

Use set_callback(function, ON.CAMP) instead

on_level

Use set_callback(function, ON.LEVEL) instead

on_start

Use set_callback(function, ON.START) instead

on_transition

Use set_callback(function, ON.TRANSITION) instead

on_death

Use set_callback(function, ON.DEATH) instead

on_win

Use set_callback(function, ON.WIN) instead

on_screen

Use set_callback(function, ON.SCREEN) instead

on_guiframe

Use set_callback(function, ON.GUIFRAME) instead

load_script

Search script examples for load_script

nil load_script()
Same as import().

read_prng

Search script examples for read_prng

vector<int> read_prng()
Read the game prng state. Use prng:get_pair() instead.

force_dark_level

-- forces any level to be dark, even bosses
set_callback(function()
    state.level_flags = set_flag(state.level_flags, 18)
end, ON.POST_ROOM_GENERATION)

Search script examples for force_dark_level

nil force_dark_level(bool g)
Set level flag 18 on post room generation instead, to properly force every level to dark

get_entities

Search script examples for get_entities

vector<int> get_entities()

Use get_entities_by(0, MASK.ANY, LAYER.BOTH) instead

get_entities_by_mask

Search script examples for get_entities_by_mask

vector<int> get_entities_by_mask(int mask)

Use get_entities_by(0, mask, LAYER.BOTH) instead

get_entities_by_layer

Search script examples for get_entities_by_layer

vector<int> get_entities_by_layer(LAYER layer)

Use get_entities_by(0, MASK.ANY, layer) instead

get_entities_overlapping

Search script examples for get_entities_overlapping

vector<int> get_entities_overlapping(array<ENT_TYPE> entity_types, int mask, float sx, float sy, float sx2, float sy2, LAYER layer)

vector<int> get_entities_overlapping(ENT_TYPE entity_type, int mask, float sx, float sy, float sx2, float sy2, LAYER layer)

Use get_entities_overlapping_hitbox instead

get_entity_ai_state

Search script examples for get_entity_ai_state

int get_entity_ai_state(int uid)

As the name is misleading. use Movable.move_state field instead

set_arrowtrap_projectile

Search script examples for set_arrowtrap_projectile

nil set_arrowtrap_projectile(ENT_TYPE regular_entity_type, ENT_TYPE poison_entity_type)

Use replace_drop(DROP.ARROWTRAP_WOODENARROW, new_arrow_type) and replace_drop(DROP.POISONEDARROWTRAP_WOODENARROW, new_arrow_type) instead

set_blood_multiplication

Search script examples for set_blood_multiplication

nil set_blood_multiplication(int default_multiplier, int vladscape_multiplier)

This function never worked properly as too many places in the game individually check for vlads cape and calculate the blood multiplication default_multiplier doesn't do anything due to some changes in last game updates, vladscape_multiplier only changes the multiplier to some entities death's blood spit

setflag

Search script examples for setflag

nil setflag()

clrflag

Search script examples for clrflag

nil clrflag()

testflag

Search script examples for testflag

nil testflag()

steal_input

Search script examples for steal_input

nil steal_input(int uid)
Deprecated because it's a weird old hack that crashes the game. You can modify inputs in many other ways, like editing state.player_inputs.player_slot_1.buttons_gameplay in PRE_UPDATE or a set_pre_process_input hook. Steal input from a Player, HiredHand or PlayerGhost.

return_input

Search script examples for return_input

nil return_input(int uid)
Return input previously stolen with steal_input

send_input

Search script examples for send_input

nil send_input(int uid, INPUTS buttons)
Send input to entity, has to be previously stolen with steal_input

read_input

Search script examples for read_input

INPUTS read_input(int uid)
Use players[1].input.buttons_gameplay for only the inputs during the game, or .buttons for all the inputs, even during the pause menu Of course, you can get the Player by other mean, it doesn't need to be the players table You can only read inputs from actual players, HH don't have any inputs

read_stolen_input

Search script examples for read_stolen_input

INPUTS read_stolen_input(int uid)
Read input that has been previously stolen with steal_input Use state.player_inputs.player_slots[player_slot].buttons_gameplay for only the inputs during the game, or .buttons for all the inputs, even during the pause menu

clear_entity_callback

Search script examples for clear_entity_callback

nil clear_entity_callback(int uid, CallbackId cb_id)
Use entity.clear_virtual instead. Clears a callback that is specific to an entity.

set_pre_statemachine

Search script examples for set_pre_statemachine

optional<CallbackId> set_pre_statemachine(int uid, function fun)
Use entity:set_pre_update_state_machine instead. Returns unique id for the callback to be used in clear_entity_callback or nil if uid is not valid. uid has to be the uid of a Movable or else stuff will break. Sets a callback that is called right before the statemachine, return true to skip the statemachine update. Use this only when no other approach works, this call can be expensive if overused. Check here to see whether you can use this callback on the entity type you intend to.
The callback signature is bool statemachine(Entity self)

set_post_statemachine

Search script examples for set_post_statemachine

optional<CallbackId> set_post_statemachine(int uid, function fun)
Use entity:set_post_update_state_machine instead. Returns unique id for the callback to be used in clear_entity_callback or nil if uid is not valid. uid has to be the uid of a Movable or else stuff will break. Sets a callback that is called right after the statemachine, so you can override any values the satemachine might have set (e.g. animation_frame). Use this only when no other approach works, this call can be expensive if overused. Check here to see whether you can use this callback on the entity type you intend to.
The callback signature is nil statemachine(Entity self)

set_on_destroy

Search script examples for set_on_destroy

optional<CallbackId> set_on_destroy(int uid, function fun)
Use entity:set_pre_destroy instead. Returns unique id for the callback to be used in clear_entity_callback or nil if uid is not valid. Sets a callback that is called right when an entity is destroyed, e.g. as if by Entity.destroy() before the game applies any side effects. Use this only when no other approach works, this call can be expensive if overused.
The callback signature is nil on_destroy(Entity self)

set_on_kill

Search script examples for set_on_kill

optional<CallbackId> set_on_kill(int uid, function fun)
Use entity:set_pre_kill instead. Returns unique id for the callback to be used in clear_entity_callback or nil if uid is not valid. Sets a callback that is called right when an entity is eradicated, before the game applies any side effects. Use this only when no other approach works, this call can be expensive if overused.
The callback signature is nil on_kill(Entity self, Entity killer)

set_on_damage

Search script examples for set_on_damage

optional<CallbackId> set_on_damage(int uid, function fun)
Use entity:set_pre_damage instead. Returns unique id for the callback to be used in clear_entity_callback or nil if uid is not valid. Sets a callback that is called right before an entity is damaged, return true to skip the game's damage handling. Note that damage_dealer can be nil ! (long fall, ...) DO NOT CALL self:damage() in the callback ! Use this only when no other approach works, this call can be expensive if overused. The entity has to be of a Movable type.
The callback signature is bool on_damage(Entity self, Entity damage_dealer, int damage_amount, float vel_x, float vel_y, int stun_amount, int iframes)

set_pre_floor_update

Search script examples for set_pre_floor_update

optional<CallbackId> set_pre_floor_update(int uid, function fun)
Use entity:set_pre_floor_update instead. Returns unique id for the callback to be used in clear_entity_callback or nil if uid is not valid. Sets a callback that is called right before a floor is updated (by killed neighbor), return true to skip the game's neighbor update handling. Use this only when no other approach works, this call can be expensive if overused.
The callback signature is bool pre_floor_update(Entity self)

set_post_floor_update

-- Use FLOOR_GENERIC with textures from different themes that update correctly when destroyed.
-- This lets you use the custom tile code 'floor_generic_tidepool'
-- in the level editor to spawn tidepool floor in dwelling for example...
define_tile_code("floor_generic_tidepool")
set_pre_tile_code_callback(function(x, y, layer)
    local uid = spawn_grid_entity(ENT_TYPE.FLOOR_GENERIC, x, y, layer)
    set_post_floor_update(uid, function(me)
        me:set_texture(TEXTURE.DATA_TEXTURES_FLOOR_TIDEPOOL_0)
        for i,v in ipairs(entity_get_items_by(me.uid, ENT_TYPE.DECORATION_GENERIC, MASK.DECORATION)) do
            local deco = get_entity(v)
            deco:set_texture(TEXTURE.DATA_TEXTURES_FLOOR_TIDEPOOL_0)
        end
    end)
    return true
end, "floor_generic_tidepool")


-- Fix quicksand decorations when not in temple
set_post_entity_spawn(function(ent)
    ent:set_post_floor_update(function(me)
        me:set_texture(TEXTURE.DATA_TEXTURES_FLOOR_TEMPLE_0)
        for i,v in ipairs(entity_get_items_by(me.uid, ENT_TYPE.DECORATION_GENERIC, MASK.DECORATION)) do
            local deco = get_entity(v)
            deco:set_texture(TEXTURE.DATA_TEXTURES_FLOOR_TEMPLE_0)
        end
    end)
end, SPAWN_TYPE.ANY, MASK.FLOOR, ENT_TYPE.FLOOR_QUICKSAND)

Search script examples for set_post_floor_update

optional<CallbackId> set_post_floor_update(int uid, function fun)
Use entity:set_post_floor_update instead. Returns unique id for the callback to be used in clear_entity_callback or nil if uid is not valid. Sets a callback that is called right after a floor is updated (by killed neighbor). Use this only when no other approach works, this call can be expensive if overused.
The callback signature is nil post_floor_update(Entity self)

set_on_open

Search script examples for set_on_open

optional<CallbackId> set_on_open(int uid, function fun)
Use entity:set_pre_trigger_action instead. Returns unique id for the callback to be used in clear_entity_callback or nil if uid is not valid. Sets a callback that is called right when a container is opened by the player (up+whip) Use this only when no other approach works, this call can be expensive if overused. Check here to see whether you can use this callback on the entity type you intend to.
The callback signature is nil on_open(Entity entity_self, Entity opener)

set_pre_collision1

Search script examples for set_pre_collision1

optional<CallbackId> set_pre_collision1(int uid, function fun)
Use entity:set_pre_collision1 instead. Returns unique id for the callback to be used in clear_entity_callback or nil if uid is not valid. Sets a callback that is called right before the collision 1 event, return true to skip the game's collision handling. Use this only when no other approach works, this call can be expensive if overused. Check here to see whether you can use this callback on the entity type you intend to.
The callback signature is bool pre_collision1(Entity entity_self, Entity collision_entity)

set_pre_collision2

Search script examples for set_pre_collision2

optional<CallbackId> set_pre_collision2(int uid, function fun)
Use entity:set_pre_collision2 instead. Returns unique id for the callback to be used in clear_entity_callback or nil if uid is not valid. Sets a callback that is called right before the collision 2 event, return true to skip the game's collision handling. Use this only when no other approach works, this call can be expensive if overused. Check here to see whether you can use this callback on the entity type you intend to.
The callback signature is bool pre_collision12(Entity self, Entity collision_entity)

set_pre_render

Search script examples for set_pre_render

optional<CallbackId> set_pre_render(int uid, function fun)
Use entity.rendering_info:set_pre_render in combination with render_info:get_entity instead. Returns unique id for the callback to be used in clear_entity_callback or nil if uid is not valid. Sets a callback that is called right after the entity is rendered. Return true to skip the original rendering function and all later pre_render callbacks. Use this only when no other approach works, this call can be expensive if overused.
The callback signature is bool render(VanillaRenderContext render_ctx, Entity self)

set_post_render

Search script examples for set_post_render

optional<CallbackId> set_post_render(int uid, function fun)
Use entity.rendering_info:set_post_render in combination with render_info:get_entity instead. Returns unique id for the callback to be used in clear_entity_callback or nil if uid is not valid. Sets a callback that is called right after the entity is rendered. Use this only when no other approach works, this call can be expensive if overused.
The callback signature is nil post_render(VanillaRenderContext render_ctx, Entity self)

generate_particles

Search script examples for generate_particles

ParticleEmitterInfo generate_particles(PARTICLEEMITTER particle_emitter_id, int uid)

Use generate_world_particles

draw_line

Search script examples for draw_line

nil draw_line(float x1, float y1, float x2, float y2, float thickness, uColor color)
Use GuiDrawContext.draw_line instead

draw_rect

Search script examples for draw_rect

nil draw_rect(float x1, float y1, float x2, float y2, float thickness, float rounding, uColor color)
Use GuiDrawContext.draw_rect instead

draw_rect_filled

Search script examples for draw_rect_filled

nil draw_rect_filled(float x1, float y1, float x2, float y2, float rounding, uColor color)
Use GuiDrawContext.draw_rect_filled instead

draw_circle

Search script examples for draw_circle

nil draw_circle(float x, float y, float radius, float thickness, uColor color)
Use GuiDrawContext.draw_circle instead

draw_circle_filled

Search script examples for draw_circle_filled

nil draw_circle_filled(float x, float y, float radius, uColor color)
Use GuiDrawContext.draw_circle_filled instead

draw_text

Search script examples for draw_text

nil draw_text(float x, float y, float size, string text, uColor color)
Use GuiDrawContext.draw_text instead

draw_image

Search script examples for draw_image

nil draw_image(IMAGE image, float x1, float y1, float x2, float y2, float uvx1, float uvy1, float uvx2, float uvy2, uColor color)
Use GuiDrawContext.draw_image instead

draw_image_rotated

Search script examples for draw_image_rotated

nil draw_image_rotated(IMAGE image, float x1, float y1, float x2, float y2, float uvx1, float uvy1, float uvx2, float uvy2, uColor color, float angle, float px, float py)
Use GuiDrawContext.draw_image_rotated instead

window

Search script examples for window

nil window(string title, float x, float y, float w, float h, bool movable, function callback)
Use GuiDrawContext.window instead

win_text

Search script examples for win_text

nil win_text(string text)
Use GuiDrawContext.win_text instead

win_separator

Search script examples for win_separator

nil win_separator()
Use GuiDrawContext.win_separator instead

win_inline

Search script examples for win_inline

nil win_inline()
Use GuiDrawContext.win_inline instead

win_sameline

Search script examples for win_sameline

nil win_sameline(float offset, float spacing)
Use GuiDrawContext.win_sameline instead

win_button

Search script examples for win_button

bool win_button(string text)
Use GuiDrawContext.win_button instead

win_input_text

Search script examples for win_input_text

string win_input_text(string label, string value)
Use GuiDrawContext.win_input_text instead

win_input_int

Search script examples for win_input_int

int win_input_int(string label, int value)
Use GuiDrawContext.win_input_int instead

win_input_float

Search script examples for win_input_float

float win_input_float(string label, float value)
Use GuiDrawContext.win_input_float instead

win_slider_int

Search script examples for win_slider_int

int win_slider_int(string label, int value, int min, int max)
Use GuiDrawContext.win_slider_int instead

win_drag_int

Search script examples for win_drag_int

int win_drag_int(string label, int value, int min, int max)
Use GuiDrawContext.win_drag_int instead

win_slider_float

Search script examples for win_slider_float

float win_slider_float(string label, float value, float min, float max)
Use GuiDrawContext.win_slider_float instead

win_drag_float

Search script examples for win_drag_float

float win_drag_float(string label, float value, float min, float max)
Use GuiDrawContext.win_drag_float instead

win_check

Search script examples for win_check

bool win_check(string label, bool value)
Use GuiDrawContext.win_check instead

win_combo

Search script examples for win_combo

int win_combo(string label, int selected, string opts)
Use GuiDrawContext.win_combo instead

win_pushid

Search script examples for win_pushid

nil win_pushid(int id)
Use GuiDrawContext.win_pushid instead

win_popid

Search script examples for win_popid

nil win_popid()
Use GuiDrawContext.win_popid instead

win_image

Search script examples for win_image

nil win_image(IMAGE image, float width, float height)
Use GuiDrawContext.win_image instead

Non-Entity types

Arena types

ArenaConfigArenas

Used in ArenaState

Type Name Description
array<bool, 40> list
bool dwelling_1
bool dwelling_2
bool dwelling_3
bool dwelling_4
bool dwelling_5
bool jungle_1
bool jungle_2
bool jungle_3
bool jungle_4
bool jungle_5
bool volcana_1
bool volcana_2
bool volcana_3
bool volcana_4
bool volcana_5
bool tidepool_1
bool tidepool_2
bool tidepool_3
bool tidepool_4
bool tidepool_5
bool temple_1
bool temple_2
bool temple_3
bool temple_4
bool temple_5
bool icecaves_1
bool icecaves_2
bool icecaves_3
bool icecaves_4
bool icecaves_5
bool neobabylon_1
bool neobabylon_2
bool neobabylon_3
bool neobabylon_4
bool neobabylon_5
bool sunkencity_1
bool sunkencity_2
bool sunkencity_3
bool sunkencity_4
bool sunkencity_5

ArenaConfigEquippedItems

Used in ArenaState

Type Name Description
bool paste
bool climbing_gloves
bool pitchers_mitt
bool spike_shoes
bool spring_shoes
bool parachute
bool kapala
bool scepter

ArenaConfigItems

Used in ArenaState

Type Name Description
bool rock
bool pot
bool bombbag
bool bombbox
bool ropepile
bool pickup_12bag
bool pickup_24bag
bool cooked_turkey
bool royal_jelly
bool torch
bool boomerang
bool machete
bool mattock
bool crossbow
bool webgun
bool freezeray
bool shotgun
bool camera
bool plasma_cannon
bool wooden_shield
bool metal_shield
bool teleporter
bool mine
bool snaptrap
bool paste
bool climbing_gloves
bool pitchers_mitt
bool spike_shoes
bool spring_shoes
bool parachute
bool cape
bool vlads_cape
bool jetpack
bool hoverpack
bool telepack
bool powerpack
bool excalibur
bool scepter
bool kapala
bool true_crown

ArenaState

Used in StateMemory

Type Name Description
int current_arena
array<int, 4> player_teams
int format
int ruleset
array<int, 4> player_lives
array<int, 4> player_totalwins
array<bool, 4> player_won
int timer The menu selection for timer, default values 0..20 where 0 == 30 seconds, 19 == 10 minutes and 20 == infinite. Can go higher, although this will glitch the menu text. Actual time (seconds) = (state.arena.timer + 1) x 30
int timer_ending
int wins
int lives
int time_to_win
array<int, 4> player_idolheld_countdown
int health
int bombs
int ropes
int stun_time
int mount
int arena_select
ArenaConfigArenas arenas
int dark_level_chance
int crate_frequency
ArenaConfigItems items_enabled
ArenaConfigItems items_in_crate
int held_item
int equipped_backitem
ArenaConfigEquippedItems equipped_items
int whip_damage
bool final_ghost
int breath_cooldown
bool punish_ball

LogicArena1

Used in LogicList Derived from Logic

Type Name Description
int crate_spawn_timer

LogicArenaAlienBlast

Used in LogicList Derived from Logic

Type Name Description
int timer

LogicArenaLooseBombs

Used in LogicList Derived from Logic

Type Name Description
int timer

Callback context types

GuiDrawContext

-- Draw the level boundaries
set_callback(function(draw_ctx)
    local xmin, ymax, xmax, ymin = get_bounds()
    local sx, sy = screen_position(xmin, ymax) -- top left
    local sx2, sy2 = screen_position(xmax, ymin) -- bottom right
    draw_ctx:draw_rect(sx, sy, sx2, sy2, 4, 0, rgba(255, 255, 255, 255))
end, ON.GUIFRAME)

Used in register_option_callback and set_callback with ON.GUIFRAME

Type Name Description
nil draw_line(float x1, float y1, float x2, float y2, float thickness, uColor color) Draws a line on screen
nil draw_rect(float left, float top, float right, float bottom, float thickness, float rounding, uColor color) Draws a rectangle on screen from top-left to bottom-right.
nil draw_rect(AABB rect, float thickness, float rounding, uColor color) Draws a rectangle on screen from top-left to bottom-right.
nil draw_rect_filled(float left, float top, float right, float bottom, float rounding, uColor color) Draws a filled rectangle on screen from top-left to bottom-right.
nil draw_rect_filled(AABB rect, float rounding, uColor color) Draws a filled rectangle on screen from top-left to bottom-right.
nil draw_triangle(Vec2 p1, Vec2 p2, Vec2 p3, float thickness, uColor color) Draws a triangle on screen.
nil draw_triangle_filled(Vec2 p1, Vec2 p2, Vec2 p3, uColor color) Draws a filled triangle on screen.
nil draw_poly(array points, float thickness, uColor color) Draws a polyline on screen.
nil draw_poly_filled(array points, uColor color) Draws a filled convex polyline on screen.
nil draw_bezier_cubic(Vec2 p1, Vec2 p2, Vec2 p3, Vec2 p4, float thickness, uColor color) Draws a cubic bezier curve on screen.
nil draw_bezier_quadratic(Vec2 p1, Vec2 p2, Vec2 p3, float thickness, uColor color) Draws a quadratic bezier curve on screen.
nil draw_circle(float x, float y, float radius, float thickness, uColor color) Draws a circle on screen
nil draw_circle_filled(float x, float y, float radius, uColor color) Draws a filled circle on screen
nil draw_text(float x, float y, float size, string text, uColor color) Draws text in screen coordinates x, y, anchored top-left. Text size 0 uses the default 18.
nil draw_image(IMAGE image, float left, float top, float right, float bottom, float uvx1, float uvy1, float uvx2, float uvy2, uColor color) Draws an image on screen from top-left to bottom-right. Use UV coordinates 0, 0, 1, 1 to just draw the whole image.
nil draw_image(IMAGE image, AABB rect, AABB uv_rect, uColor color) Draws an image on screen from top-left to bottom-right. Use UV coordinates 0, 0, 1, 1 to just draw the whole image.
nil draw_image_rotated(IMAGE image, float left, float top, float right, float bottom, float uvx1, float uvy1, float uvx2, float uvy2, uColor color, float angle, float px, float py) Same as draw_image but rotates the image by angle in radians around the pivot offset from the center of the rect (meaning px=py=0 rotates around the center)
nil draw_image_rotated(IMAGE image, AABB rect, AABB uv_rect, uColor color, float angle, float px, float py) Same as draw_image but rotates the image by angle in radians around the pivot offset from the center of the rect (meaning px=py=0 rotates around the center)
nil draw_layer(DRAW_LAYER layer) Draw on top of UI windows, including platform windows that may be outside the game area, or only in current widget window. Defaults to main viewport background.
bool window(string title, float x, float y, float w, float h, bool movable, function callback) Create a new widget window. Put all win_ widgets inside the callback function. The window functions are just wrappers for the
ImGui widgets, so read more about them there. Use screen position and distance, or 0, 0, 0, 0 to
autosize in center. Use just a ##Label as title to hide titlebar.
Important: Keep all your labels unique! If you need inputs with the same label, add ##SomeUniqueLabel after the text, or use pushid to
give things unique ids. ImGui doesn't know what you clicked if all your buttons have the same text...
Returns false if the window was closed from the X.

The callback signature is nil win(GuiDrawContext ctx, Vec2 pos, Vec2 size)
nil win_text(string text) Add some text to window, automatically wrapped
nil win_separator() Add a separator line to window
nil win_separator_text(string text) Add a separator text line to window
nil win_inline() Add next thing on the same line. This is same as win_sameline(0, -1)
nil win_sameline(float offset, float spacing) Add next thing on the same line, with an offset
bool win_button(string text) Add a button
string win_input_text(string label, string value) Add a text field
int win_input_int(string label, int value) Add an integer field
float win_input_float(string label, float value) Add a float field
int win_slider_int(string label, int value, int min, int max) Add an integer slider
int win_drag_int(string label, int value, int min, int max) Add an integer dragfield
float win_slider_float(string label, float value, float min, float max) Add an float slider
float win_drag_float(string label, float value, float min, float max) Add an float dragfield
bool win_check(string label, bool value) Add a checkbox
int win_combo(string label, int selected, string opts) Add a combo box
nil win_pushid(int id) Add unique identifier to the stack, to distinguish identical inputs from each other. Put before the input.
nil win_pushid(string id) Add unique identifier to the stack, to distinguish identical inputs from each other. Put before the input.
nil win_popid() Pop unique identifier from the stack. Put after the input.
nil win_image(IMAGE image, float width, float height) Draw image to window.
bool win_imagebutton(string label, IMAGE image, float width, float height, float uvx1, float uvy1, float uvx2, float uvy2) Draw imagebutton to window.
nil win_section(string title, function callback) Add a collapsing accordion section, put contents in the callback function.
nil win_indent(float width) Indent contents, or unindent if negative
nil win_width(float width) Sets next item width (width>1: width in pixels, width<0: to the right of window, -1<width<1: fractional, multiply by available window width)
int key_picker(string message, KEY_TYPE flags) Returns KEY flags including held OL_MOD modifiers, or -1 before any key has been pressed and released, or mouse button pressed. Also returns -1 before all initially held keys are released before the picker was opened, or if another key picker is already waiting for keys. If a modifier is released, that modifier is returned as an actual keycode (e.g. KEY.LSHIFT) while the other held modifiers are returned as KEY.OL_MOD_... flags.
Shows a fullscreen key picker with a message, with the accepted input type (keyboard/mouse) filtered by flags. The picker won't show before all previously held keys have been released and other key pickers have returned a valid key.

LoadContext

Context received in ON.LOAD Used to load from save_{}.dat into a string

Type Name Description
string load()

PostRoomGenerationContext

Context received in ON.POST_ROOM_GENERATION. Used to change the room templates in the level and other shenanigans that affect level gen.

Type Name Description
bool set_room_template(int x, int y, LAYER layer, ROOM_TEMPLATE room_template) Set the room template at the given index and layer, returns false if the index is outside of the level.
bool mark_as_machine_room_origin(int x, int y, LAYER layer) Marks the room as the origin of a machine room, should be the top-left corner of the machine room
Run this after setting the room template for the room, otherwise the machine room will not spawn correctly
bool mark_as_set_room(int x, int y, LAYER layer) Marks the room as a set-room, a corresponding setroomy-x template must be loaded, else the game will crash
bool unmark_as_set_room(int x, int y, LAYER layer) Unmarks the room as a set-room
bool set_shop_type(int x, int y, LAYER layer, int shop_type) Set the shop type for a specific room, does nothing if the room is not a shop
bool set_procedural_spawn_chance(PROCEDURAL_CHANCE chance_id, int inverse_chance) Force a spawn chance for this level, has the same restrictions as specifying the spawn chance in the .lvl file.
Note that the actual chance to spawn is 1/inverse_chance and that is also slightly skewed because of technical reasons.
Returns false if the given chance is not defined.
nil set_num_extra_spawns(int extra_spawn_id, int num_spawns_front_layer, int num_spawns_back_layer) Change the amount of extra spawns for the given extra_spawn_id.
optional<SHORT_TILE_CODE> define_short_tile_code(ShortTileCodeDef short_tile_code_def) Defines a new short tile code, automatically picks an unused character or returns a used one in case of an exact match
Returns nil if all possible short tile codes are already in use
nil change_short_tile_code(SHORT_TILE_CODE short_tile_code, ShortTileCodeDef short_tile_code_def) Overrides a specific short tile code, this means it will change for the whole level

PreHandleRoomTilesContext

Context received in ON.PRE_HANDLE_ROOM_TILES. Used to change the room data as well as add a backlayer room if none is set yet.

Type Name Description
optional<SHORT_TILE_CODE> get_short_tile_code(int tx, int ty, LAYER layer) Gets the tile code at the specified tile coordinate
Valid coordinates are 0 <= tx < CONST.ROOM_WIDTH, 0 <= ty < CONST.ROOM_HEIGHT and layer in {LAYER.FRONT, LAYER.BACK}
Also returns nil if layer == LAYER.BACK and the room does not have a back layer
bool set_short_tile_code(int tx, int ty, LAYER layer, SHORT_TILE_CODE short_tile_code) Sets the tile code at the specified tile coordinate
Valid coordinates are 0 <= tx < CONST.ROOM_WIDTH, 0 <= ty < CONST.ROOM_HEIGHT and layer in {LAYER.FRONT, LAYER.BACK, LAYER.BOTH}
Also returns false if layer == LAYER.BACK and the room does not have a back layer
vector<tuple<int, int, LAYER>> find_all_short_tile_codes(LAYER layer, SHORT_TILE_CODE short_tile_code) Finds all places a short tile code is used in the room, layer must be in {LAYER.FRONT, LAYER.BACK, LAYER.BOTH}
Returns an empty list if layer == LAYER.BACK and the room does not have a back layer
bool replace_short_tile_code(LAYER layer, SHORT_TILE_CODE short_tile_code, SHORT_TILE_CODE replacement_short_tile_code) Replaces all instances of short_tile_code in the given layer with replacement_short_tile_code, layer must be in {LAYER.FRONT, LAYER.BACK, LAYER.BOTH}
Returns false if layer == LAYER.BACK and the room does not have a back layer
bool has_back_layer() Check whether the room has a back layer
nil add_empty_back_layer() Add a back layer filled with all 0 if there is no back layer yet
Does nothing if there already is a backlayer
nil add_copied_back_layer() Add a back layer that is a copy of the front layer
Does nothing if there already is a backlayer

PreLoadLevelFilesContext

Context received in ON.PRE_LOAD_LEVEL_FILES, used for forcing specific .lvl files to load.

Type Name Description
nil override_level_files(array levels) Block all loading .lvl files and instead load the specified .lvl files. This includes generic.lvl so if you need it specify it here.
All .lvl files are loaded relative to Data/Levels, but they can be completely custom .lvl files that ship with your mod so long as they are in said folder.
Use at your own risk, some themes/levels expect a certain level file to be loaded.
nil add_level_files(array levels) Load additional levels files other than the ones that would usually be loaded. Stacks with override_level_files if that was called first.
All .lvl files are loaded relative to Data/Levels, but they can be completely custom .lvl files that ship with your mod so long as they are in said folder.

SaveContext

Context received in ON.SAVE Used to save a string to some form of save_{}.dat Future calls to this will override the save

Type Name Description
bool save(string data)

VanillaRenderContext

Used in set_callback ON.RENDER_* callbacks, set_post_render, set_post_render_screen, set_pre_render, set_pre_render_screen

Type Name Description
nil draw_text(string text, float x, float y, float scale_x, float scale_y, Color color, VANILLA_TEXT_ALIGNMENT alignment, VANILLA_FONT_STYLE fontstyle) Draw text using the built-in renderer
Use in combination with ON.RENDER_✱ events. See vanilla_rendering.lua in the example scripts.
nil draw_text(TextRenderingInfo tri, Color color)
tuple<float, float> draw_text_size(string text, float scale_x, float scale_y, int fontstyle) Measure the provided text using the built-in renderer
If you can, consider creating your own TextRenderingInfo instead
You can then use :text_size() and draw_text with that one object
draw_text_size works by creating new TextRenderingInfo just to call :text_size(), which is not very optimal
nil draw_screen_texture(TEXTURE texture_id, int row, int column, float left, float top, float right, float bottom, Color color) Draw a texture in screen coordinates from top-left to bottom-right using the built-in renderer
Use in combination with ON.RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events
nil draw_screen_texture(TEXTURE texture_id, int row, int column, AABB rect, Color color) Draw a texture in screen coordinates from top-left to bottom-right using the built-in renderer
Use in combination with ON.RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events
nil draw_screen_texture(TEXTURE texture_id, int row, int column, AABB rect, Color color, float angle, float px, float py) Draw a texture in screen coordinates from top-left to bottom-right using the built-in renderer with angle, px/py is pivot for the rotation where 0,0 is center 1,1 is top right corner etc.
Use in combination with ON.RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events
nil draw_screen_texture(TEXTURE texture_id, int row, int column, Quad dest, Color color) Draw a texture in screen coordinates from top-left to bottom-right using the built-in renderer
Use in combination with ON.RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events
nil draw_screen_texture(TEXTURE texture_id, Quad source, Quad dest, Color color) Draw a texture in screen coordinates from top-left to bottom-right using the built-in renderer. source - the coordinates in the texture, dest - the coordinates on the screen
Use in combination with ON.RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events
nil draw_screen_texture(TEXTURE texture_id, TextureRenderingInfo tri, Color color) Draw a texture in screen coordinates using TextureRenderingInfo
Use in combination with ON.RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events
nil set_corner_finish(CORNER_FINISH c) Set the preferred way of drawing corners for the non filled shapes
nil draw_screen_line(Vec2 A, Vec2 B, float thickness, Color color) Draws a line on screen using the built-in renderer from point A to point B.
Use in combination with ON.RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events
nil draw_screen_rect(AABB rect, float thickness, Color color, optional angle, optional px, optional py) Draw rectangle in screen coordinates from top-left to bottom-right using the built-in renderer with optional angle.
px/py is pivot for the rotation where 0,0 is center 1,1 is top right corner etc. (corner from the AABB, not the visible one from adding the thickness)
Use in combination with ON.RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events
nil draw_screen_rect_filled(AABB rect, Color color, optional angle, optional px, optional py) Draw filled rectangle in screen coordinates from top-left to bottom-right using the built-in renderer with optional angle.
px/py is pivot for the rotation where 0,0 is center 1,1 is top right corner etc.
Use in combination with ON.RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events
nil draw_screen_triangle(Triangle triangle, float thickness, Color color) Draw triangle in screen coordinates using the built-in renderer.
Use in combination with ON.RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events
nil draw_screen_triangle_filled(Triangle triangle, Color color) Draw filled triangle in screen coordinates using the built-in renderer.
Use in combination with ON.RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events
nil draw_screen_poly(array points, float thickness, Color color, bool closed) Draw a polyline on screen from points using the built-in renderer
Draws from the first to the last point, use closed to connect first and last as well
Use in combination with ON.RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events
nil draw_screen_poly(Quad points, float thickness, Color color, bool closed) Draw quadrilateral in screen coordinates from top-left to bottom-right using the built-in renderer.
Use in combination with ON.RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events
nil draw_screen_poly_filled(array points, Color color) Draw a convex polygon on screen from points using the built-in renderer
Can probably draw almost any polygon, but the convex one is guaranteed to look correct
Use in combination with ON.RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events
nil draw_screen_poly_filled(Quad points, Color color) Draw filled quadrilateral in screen coordinates from top-left to bottom-right using the built-in renderer.
Use in combination with ON.RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events
nil draw_world_texture(TEXTURE texture_id, int row, int column, float left, float top, float right, float bottom, Color color) Draw a texture in world coordinates from top-left to bottom-right using the built-in renderer
Use in combination with ON.RENDER_PRE_DRAW_DEPTH event
For more control use the version taking a Quad instead
nil draw_world_texture(TEXTURE texture_id, int row, int column, AABB dest, Color color) Draw a texture in world coordinates from top-left to bottom-right using the built-in renderer
Use in combination with ON.RENDER_PRE_DRAW_DEPTH event
For more control use the version taking a Quad instead
nil draw_world_texture(TEXTURE texture_id, int row, int column, AABB dest, Color color, float angle, float px, float py) Draw a texture in world coordinates from top-left to bottom-right using the built-in renderer with angle, px/py is pivot for the rotation where 0,0 is center 1,1 is top right corner etc.
Use in combination with ON.RENDER_PRE_DRAW_DEPTH event
For more control use the version taking a Quad instead
nil draw_world_texture(TEXTURE texture_id, int row, int column, Quad dest, Color color, WORLD_SHADER shader) Draw a texture in world coordinates from top-left to bottom-right using the built-in renderer
The shader parameter controls how to render the texture
Use in combination with ON.RENDER_PRE_DRAW_DEPTH event
nil draw_world_texture(TEXTURE texture_id, int row, int column, Quad dest, Color color) Draw a texture in world coordinates from top-left to bottom-right using the built-in renderer
Use in combination with ON.RENDER_PRE_DRAW_DEPTH event
nil draw_world_texture(TEXTURE texture_id, Quad source, Quad dest, Color color, WORLD_SHADER shader) Draw a texture in world coordinates from top-left to bottom-right using the built-in renderer. source - the coordinates in the texture, dest - the coordinates on the screen
The shader parameter controls how to render the texture
Use in combination with ON.RENDER_PRE_DRAW_DEPTH event
nil draw_world_texture(TEXTURE texture_id, Quad source, Quad dest, Color color) Draw a texture in world coordinates from top-left to bottom-right using the built-in renderer. source - the coordinates in the texture, dest - the coordinates on the screen
Use in combination with ON.RENDER_PRE_DRAW_DEPTH event
nil draw_world_line(Vec2 A, Vec2 B, float thickness, Color color) Draws a line in world coordinates using the built-in renderer from point A to point B.
Use in combination with ON.RENDER_PRE_DRAW_DEPTH event
nil draw_world_rect(AABB rect, float thickness, Color color, optional angle, optional px, optional py) Draw rectangle in world coordinates from top-left to bottom-right using the built-in renderer with optional angle.
px/py is pivot for the rotation where 0,0 is center 1,1 is top right corner etc. (corner from the AABB, not the visible one from adding the thickness)
Use in combination with ON.RENDER_PRE_DRAW_DEPTH event
nil draw_world_rect_filled(AABB rect, Color color, optional angle, optional px, optional py) Draw rectangle in world coordinates from top-left to bottom-right using the built-in renderer with optional angle.
px/py is pivot for the rotation where 0,0 is center 1,1 is top right corner etc.
Use in combination with ON.RENDER_PRE_DRAW_DEPTH event
nil draw_world_triangle(Triangle triangle, float thickness, Color color) Draw triangle in world coordinates using the built-in renderer.
Use in combination with ON.RENDER_PRE_DRAW_DEPTH event
nil draw_world_triangle_filled(Triangle triangle, Color color) Draw filled triangle in world coordinates using the built-in renderer.
Use in combination with ON.RENDER_PRE_DRAW_DEPTH event
nil draw_world_poly(array points, float thickness, Color color, bool closed) Draw a polyline in world coordinates from points using the built-in renderer
Draws from the first to the last point, use closed to connect first and last as well
Use in combination with ON.RENDER_PRE_DRAW_DEPTH event
nil draw_world_poly(Quad points, float thickness, Color color, bool closed) Draw quadrilateral in world coordinates from top-left to bottom-right using the built-in renderer.
Use in combination with ON.RENDER_PRE_DRAW_DEPTH event
nil draw_world_poly_filled(array points, Color color) Draw a convex polygon in world coordinates from points using the built-in renderer
Can probably draw almost any polygon, but the convex one is guaranteed to look correct
Use in combination with ON.RENDER_PRE_DRAW_DEPTH event
nil draw_world_poly_filled(Quad points, Color color) Draw filled quadrilateral in world coordinates from top-left to bottom-right using the built-in renderer.
Use in combination with ON.RENDER_PRE_DRAW_DEPTH event
AABB bounding_box
render_draw_depth

Ai

Used in Player

Type Name Description
Entity target
int target_uid
int timer
int state AI state (patrol, sleep, attack, aggro...)
int last_state
int trust Levels completed with, 0..3
int whipped Number of times whipped by player
int walk_pause_timer positive: walking, negative: waiting/idle

Animation

Used in EntityDB

Type Name Description
int id
int first_tile
int num_tiles
int interval
REPEAT_TYPE repeat_mode

EntityDB

When cloning an entity type, remember to save it in the script for as long as you need it. Otherwise the memory will be freed immediately, which eventually leads to a crash when used or overwritten by other stuff:

-- Create a special fast snake type with weird animation
special_snake = EntityDB:new(ENT_TYPE.MONS_SNAKE)
special_snake.max_speed = 1
special_snake.acceleration = 2
special_snake.animations[2].num_tiles = 1

set_post_entity_spawn(function(snake)
    -- 50% chance to make snakes special
    if prng:random_chance(2, PRNG_CLASS.PROCEDURAL_SPAWNS) then
        -- Assign custom type
        snake.type = special_snake
        -- This is only really needed if types are changed during the level
        snake.current_animation = special_snake.animations[2]
    end
end, SPAWN_TYPE.ANY, MASK.MONSTER, ENT_TYPE.MONS_SNAKE)

You can also use Entity.user_data to store the custom type:

-- Custom player who is buffed a bit every level
set_callback(function()
    -- Doing this to include HH
    for i,v in ipairs(get_entities_by_mask(MASK.PLAYER)) do
        local player = get_entity(v)

        -- Create new custom type on the first level, based on the original type
        if not player.user_data then
            player.user_data = {}
            player.user_data.type = EntityDB:new(player.type.id)
        end

        -- Set the player entity type to the custom type every level
        player.type = player.user_data.type

        -- Buff the player every subsequent level
        if state.level_count > 0 then
            player.type.max_speed = player.type.max_speed * 1.1
            player.type.acceleration = player.type.acceleration * 1.1
            player.type.jump = player.type.jump * 1.1
        end
    end
end, ON.POST_LEVEL_GENERATION)

Illegal bad example, don't do this:

set_callback(function()
    -- Nobody owns the new type and the memory is freed immediately, eventually leading to a crash
    players[1].type = EntityDB:new(players[1].type)
    players[1].type.max_speed = 2
end, ON.POST_LEVEL_GENERATION)

Used in Entity and get_type
Stores static common data for an ENT_TYPE. You can also clone entity types with the copy constructor to create new custom entities with different common properties. This tool can be helpful when messing with the animations. The default values are also listed in entities.json.

Type Name Description
EntityDB new(EntityDB other)
EntityDB new(ENT_TYPE other)
ENT_TYPE id
int search_flags MASK
float width
float height
float offsetx
float offsety
float hitboxx
float hitboxy
int draw_depth
int collision2_mask MASK, will only call collision2 when colliding with entities that match this mask.
int collision_mask MASK used for collision with floors, walls etc.
float friction
float elasticity
float weight
float acceleration
float max_speed
float sprint_factor
float jump
Color default_color
int damage
int life
int sacrifice_value Favor for sacrificing alive. Halved when dead (health == 0).
int blood_content
TEXTURE texture
map<int, Animation> animations
int properties_flags
int default_flags
int default_more_flags
bool leaves_corpse_behind
int sound_killed_by_player
int sound_killed_by_other
STRINGID description
int tilex
int tiley

HudInventory

Type Name Description
bool enabled
int health
int bombs
int ropes
bool ankh
bool kapala
SpritePosition kapala_sprite
bool poison
bool curse
bool elixir
ENT_TYPE crown Powerup type or 0
array<SpritePosition, 18> powerup_sprites
int item_count Amount of generic pickup items at the bottom. Set to 0 to not draw them.

Inventory

Used in Player, PlayerGhost and Items

Type Name Description
int money Sum of the money collected in current level
int bombs
int ropes
int player_slot
int poison_tick_timer Used to transfer information to transition/next level. Is not updated during a level
You can use ON.PRE_LEVEL_GENERATION to access/edit this
bool cursed Used to transfer information to transition/next level. Is not updated during a level
You can use ON.PRE_LEVEL_GENERATION to access/edit this
bool elixir_buff Used to transfer information to transition/next level. Is not updated during a level
You can use ON.PRE_LEVEL_GENERATION to access/edit this
int health Used to transfer information to transition/next level. Is not updated during a level
You can use ON.PRE_LEVEL_GENERATION to access/edit this
int kapala_blood_amount Used to transfer information to transition/next level. Is not updated during a level
You can use ON.PRE_LEVEL_GENERATION to access/edit this
int time_of_death Is set to state.time_total when player dies in coop (to determinate who should be first to re-spawn from coffin)
ENT_TYPE held_item Used to transfer information to transition/next level. Is not updated during a level
You can use ON.PRE_LEVEL_GENERATION to access/edit this
int held_item_metadata Metadata of the held item (health, is cursed etc.)
Used to transfer information to transition/next level. Is not updated during a level
You can use ON.PRE_LEVEL_GENERATION to access/edit this
int saved_pets_count
ENT_TYPE mount_type Used to transfer information to transition/next level (player riding a mount). Is not updated during a level
You can use ON.PRE_LEVEL_GENERATION to access/edit this
int mount_metadata Metadata of the mount (health, is cursed etc.)
Used to transfer information to transition/next level (player riding a mount). Is not updated during a level
You can use ON.PRE_LEVEL_GENERATION to access/edit this
int kills_level
int kills_total
int collected_money_total Total money collected during previous levels (so excluding the current one)
int collected_money_count Count/size for the collected_money arrays
array<ENT_TYPE, 512> collected_money Types of gold/gems collected during this level, used later to display during the transition
array<int, 512> collected_money_values Values of gold/gems collected during this level, used later to display during the transition
array<ENT_TYPE, 256> killed_enemies Types of enemies killed during this level, used later to display during the transition
int companion_count Number of companions, it will determinate how many companions will be transferred to next level
Increments when player acquires new companion, decrements when one of them dies
array<ENT_TYPE, 8> companions Used to transfer information to transition/next level. Is not updated during a level
You can use ON.PRE_LEVEL_GENERATION to access/edit this
array<ENT_TYPE, 8> companion_held_items Used to transfer information to transition/next level. Is not updated during a level
You can use ON.PRE_LEVEL_GENERATION to access/edit this
array<int, 8> companion_held_item_metadatas Metadata of items held by companions (health, is cursed etc.)
Used to transfer information to transition/next level. Is not updated during a level
You can use ON.PRE_LEVEL_GENERATION to access/edit this
array<int, 8> companion_trust (0..3) Used to transfer information to transition/next level. Is not updated during a level
You can use ON.PRE_LEVEL_GENERATION to access/edit this
array<int, 8> companion_health Used to transfer information to transition/next level. Is not updated during a level
You can use ON.PRE_LEVEL_GENERATION to access/edit this
array<int, 8> companion_poison_tick_timers Used to transfer information to transition/next level. Is not updated during a level
You can use ON.PRE_LEVEL_GENERATION to access/edit this
array<bool, 8> is_companion_cursed Used to transfer information to transition/next level. Is not updated during a level
You can use ON.PRE_LEVEL_GENERATION to access/edit this
array<ENT_TYPE, 30> acquired_powerups Used to transfer information to transition/next level. Is not updated during a level
You can use ON.PRE_LEVEL_GENERATION to access/edit this

Generic types

AABB

Axis-Aligned-Bounding-Box, represents for example a hitbox of an entity or the size of a gui element

Type Name Description
AABB new() Create a new axis aligned bounding box - defaults to all zeroes
AABB new(AABB other) Copy an axis aligned bounding box
AABB new(Vec2 top_left, Vec2 bottom_right)
AABB new(float left_, float top_, float right_, float bottom_) Create a new axis aligned bounding box by specifying its values
float left
float bottom
float right
float top
bool overlaps_with(AABB other)
AABB abs() Fixes the AABB if any of the sides have negative length
AABB extrude(float amount) Grows or shrinks the AABB by the given amount in all directions.
If amount < 0 and abs(amount) > right/top - left/bottom the respective dimension of the AABB will become 0.
AABB extrude(float amount_x, float amount_y) Grows or shrinks the AABB by the given amount in each direction.
If amount_x/y < 0 and abs(amount_x/y) > right/top - left/bottom the respective dimension of the AABB will become 0.
AABB offset(float off_x, float off_y) Offsets the AABB by the given offset.
float area() Compute area of the AABB, can be zero if one dimension is zero or negative if one dimension is inverted.
tuple<float, float> center() Short for (aabb.left + aabb.right) / 2.0f, (aabb.top + aabb.bottom) / 2.0f.
float width() Short for aabb.right - aabb.left.
float height() Short for aabb.top - aabb.bottom.
bool is_point_inside(Vec2 p) Checks if point lies between left/right and top/bottom
bool is_point_inside(float x, float y)
AABB set(AABB other)
tuple<float, float, float, float> split()

BackgroundMusic

Used in GameManager

Type Name Description
BackgroundSound game_startup
BackgroundSound main_backgroundtrack
BackgroundSound basecamp
BackgroundSound win_scene
BackgroundSound arena
BackgroundSound arena_intro_and_win
BackgroundSound level_gameplay
BackgroundSound dark_level
BackgroundSound level_transition
BackgroundSound backlayer
BackgroundSound shop
BackgroundSound angered_shopkeeper
BackgroundSound inside_sunken_city_pipe
BackgroundSound pause_menu
BackgroundSound death_transition

Bucket

Shared memory structure used for Playlunky-Overlunky interoperability

Type Name Description
map<string, any> data You can store arbitrary simple values here in Playlunky to be read in on Overlunky script for example.
Overlunky overlunky Access Overlunky options here, nil if Overlunky is not loaded.
PauseAPI pause PauseAPI is used by Overlunky and can be used to control the Overlunky pause options from scripts. Can be accessed from the global pause more easily.
SharedIO io Shared part of ImGuiIO to block keyboard/mouse input across API instances.
int count Number of API instances present

Color

-- make a semi transparent red color and print it in different formats
local color = Color:red()
color.a = 0.5
local r, g, b, a = color:get_rgba()
prinspect(r, g, b, a) -- 255, 0, 0, 128
prinspect(color.r, color.g, color.b, color.a) -- 1.0, 0.0, 0.0, 0.5
prinspect(string.format("%x"), color:get_ucolor()) -- 800000ff

Type Name Description
Color new() Create a new color - defaults to black
Color new(Color other)
Color new(Color color)
Color new(float r_, float g_, float b_, float a_) Create a new color by specifying its values
Color new(string color_name, optional alpha = nullopt)
float r
float g
float b
float a
Color white()
Color silver()
Color gray()
Color black()
Color red()
Color maroon()
Color yellow()
Color olive()
Color lime()
Color green()
Color aqua()
Color teal()
Color blue()
Color navy()
Color fuchsia()
Color purple()
tuple<int, int, int, int> get_rgba() Returns RGBA colors in 0..255 range
Color set_rgba(int red, int green, int blue, int alpha) Changes color based on given RGBA colors in 0..255 range
uColor get_ucolor() Returns the uColor used in GuiDrawContext drawing functions
Color set_ucolor(uColor color) Changes color based on given uColor
Color set(Color other) Copies the values of different Color to this one

ControllerButton

Type Name Description
bool down Button is being held
bool pressed Button was just pressed down this frame

CutsceneBehavior

Type Name Description

Hud

set_callback(function(ctx, hud)
    -- draw on screen bottom but keep neat animations
    if hud.y > 0 then hud.y = -hud.y end
    -- spoof some values
    hud.data.inventory[1].health = prng:random_int(1, 99, 0)
    -- hide generic pickup items
    hud.data.inventory[1].item_count = 0
    -- hide money element
    hud.data.money.opacity = 0
    -- get real current opacity of p1 inventory element
    prinspect(hud.data.players[1].opacity * hud.data.opacity * hud.opacity)
end, ON.RENDER_PRE_HUD)

Type Name Description
float y
float opacity
HudData data

HudData

Type Name Description
array<HudInventory, MAX_PLAYERS> inventory
bool udjat
int money_total
int money_counter
int time_total in ms
int time_level in ms
int world_num
int level_num
bool angry_shopkeeper
bool seed_shown
int seed
float opacity
float roll_in
array<HudPlayer, MAX_PLAYERS> players
HudMoney money
ParticleEmitterInfo money_increase_sparkles
HudElement timer
HudElement level
float clover_falling_apart_timer
array<ParticleEmitterInfo, MAX_PLAYERS> player_cursed_particles
array<ParticleEmitterInfo, MAX_PLAYERS> player_poisoned_particles
TextureRenderingInfo player_highlight For player related icons, they use the same TextureRendering, just offset while drawing
TextureRenderingInfo player_heart
TextureRenderingInfo player_ankh
TextureRenderingInfo kapala_icon
TextureRenderingInfo player_crown
TextureRenderingInfo player_bomb
TextureRenderingInfo player_rope
TextureRenderingInfo udjat_icon
TextureRenderingInfo money_and_time_highlight Money and time use the same TextureRendering, just offset while drawing
TextureRenderingInfo dollar_icon
TextureRenderingInfo hourglass_icon
TextureRenderingInfo clover_icon
TextureRenderingInfo level_highlight
TextureRenderingInfo level_icon
TextureRenderingInfo seed_background

HudElement

Type Name Description
bool dim Hide background and dim if using the auto adjust setting.
float opacity Background will be drawn if this is not 0.5
int time_dim Level time when element should dim again after highlighted, INT_MAX if dimmed on auto adjust. 0 on opaque.

HudMoney

Derived from HudElement

Type Name Description
int total
int counter
int timer

HudPlayer

Derived from HudElement

Type Name Description
int health
int bombs
int ropes

ItemOwnerDetails

Used in RoomOwnersInfo

Type Name Description
ENT_TYPE owner_type
int owner_uid

KeyboardKey

Type Name Description
bool down Key is being held
bool pressed Key was just pressed down this frame

Letter

Type Name Description
Triangle bottom
Triangle top
Quad get_quad() Get the Quad of a letter (easier to work with compared to the two triangles)
This assumes that the triangles are in the correct 'touching each other' position
if the positions were altered the results may not end up as expected
nil set_quad(Quad quad) Inverse of the get_quad
Vec2 center() Get's approximated center of a letter by finding the highest and lowest values, then finding the center of a rectangle build from those values

MagmamanSpawnPosition

Used in LogicMagmamanSpawn

Type Name Description
MagmamanSpawnPosition new(int x_, int y_)
int x
int y
int timer

MovableBehavior

Opaque handle to a movable behavior used in some Movable functions

Type Name Description
int get_state_id()
int get_state_id() Get the state_id of a behavior, this is the id that needs to be returned from a behavior's
get_next_state_id to enter this state, given that the behavior is added to the movable.

Overlunky

Used to get and set Overlunky settings in Bucket

Type Name Description
map<string, any> options Current Overlunky options. Read only.
map<string, any> set_options Write some select options here to change Overlunky options.
map<string, KEY> keys Current Overlunky key bindings. Read only. You can use this to bind some custom feature to the same unknown key as currently bound by the user.
set<string> ignore_keys Disable some key bindings in Overlunky, whatever key they are actually bound to. Remember this might not be bound to the default any more, so only use this if you also plan on overriding the current keybinding, or just need to disable some feature and don't care what key it is bound on.
set<KEY> ignore_keycodes Disable keys that may or may not be used by Overlunky. You should probably write the keycodes you need here just in case if you think using OL will interfere with your keybinds.
set<string> ignore_features TODO: Disable Overlunky features. Doesn't do anything yet.
int selected_uid Currently selected uid in the entity picker or -1 if nothing is selected.
vector<int> selected_uids Currently selected uids in the entity finder.
int hovered_uid Currently hovered entity uid or -1 if nothing is hovered.
optional<int> set_selected_uid Set currently selected uid in the entity picker or -1 to clear selection.
optional<vector<int>> set_selected_uids Set currently selected uids in the entity finder.

PRNG

PRNG (short for Pseudo-Random-Number-Generator) holds 10 128bit wide buffers of memory that are mutated on every generation of a random number. The game uses specific buffers for specific scenarios, for example the third buffer is used every time particles are spawned to determine a random velocity. The used buffer is determined by PRNG_CLASS. If you want to make a mod that does not affect level generation but still uses the prng then you want to stay away from specific buffers. If you don't care what part of the game you affect just use prng.random.

Type Name Description
nil seed(int seed) Same as seed_prng
float random_float(PRNG_CLASS type) Generate a random floating point number in the range [0, 1)
bool random_chance(int inverse_chance, PRNG_CLASS type) Returns true with a chance of 1/inverse_chance
optional<int> random_index(int i, PRNG_CLASS type) Generate a integer number in the range [1, i] or nil if i < 1
int random_int(int min, int max, PRNG_CLASS type) Generate a integer number in the range [min, max]
float random() Drop-in replacement for math.random()
optional<int> random(int i) Drop-in replacement for math.random(i)
int random(int min, int max) Drop-in replacement for math.random(min, max)
tuple<int, int> get_pair(PRNG_CLASS type)
nil set_pair(PRNG_CLASS type, int first, int second)

PauseAPI

Control the pause API

Type Name Description
PAUSE_TYPE pause Current pause state bitmask. Use custom PAUSE_TYPE.PRE_✱ (or multiple) to freeze the game at the specified callbacks automatically. Checked after the matching ON update callbacks, so can be set on the same callback you want to block at the latest. Vanilla PAUSE flags will be forwarded to state.pause, but use of vanilla PAUSE flags is discouraged and might not work with other PauseAPI features.
PAUSE_TYPE pause_type Pause mask to toggle when using the PauseAPI methods to set or get pause state.
PAUSE_TRIGGER pause_trigger Bitmask for conditions when the current pause_type should be automatically enabled in pause, can have multiple conditions.
PAUSE_SCREEN pause_screen Bitmask to only enable PAUSE_TRIGGER.SCREEN during specific SCREEN, or any screen when NONE.
PAUSE_TRIGGER unpause_trigger Bitmask for conditions when the current pause_type should be automatically disabled in pause, can have multiple conditions.
PAUSE_SCREEN unpause_screen Bitmask to only enable PAUSE_TRIGGER.SCREEN during specific SCREEN, or any screen when NONE.
PAUSE_SCREEN ignore_screen Bitmask for game SCREEN where the PRE_✱ pause types are ignored, even though enabled in pause. Can also use the special cases [FADE, EXIT] to unfreeze temporarily during fades (or other screen transitions where player input is probably impossible) or the level exit walk of shame.
PAUSE_SCREEN ignore_screen_trigger Bitmask for game SCREEN where the triggers are ignored.
bool skip Set to true to unfreeze the game for one update cycle. Sets back to false after ON.POST_GAME_LOOP, so it can be used to check if current frame is a frame advance frame.
bool update_camera Set to true to enable normal camera movement when the game is paused or frozen on a callback by PauseAPI.
bool blocked Is true when PauseAPI is freezing the game.
bool skip_fade Set to true to skip all fade transitions, forcing fade_timer and fade_value to 0 on every update.
bool last_instance Set to true to run pause logic and triggers only in the last API instance in the chain (Playlunky) when multiple instances of the API (Overlunky and Playlunky) are injected.
int last_trigger_frame Global frame stamp when one of the triggers was last triggered, used to prevent running them again on the same frame on unpause.
int last_fade_timer Fade timer stamp when fade triggers were last checked.
nil frame_advance() Sets skip
PAUSE_TYPE get_pause() Get the current pause flags
nil set_pause(PAUSE_TYPE flags) Set the current pause flags
bool set_paused(bool enable = true) Enable/disable the current pause_type flags in pause state
bool paused() Is the game currently paused and that pause state matches any of the current the pause_type
bool toggle() Toggles pause state
bool loading() Is the game currently loading and PAUSE_SCREEN.LOADING would be triggered, based on state.loading and some arbitrary checks.
int modifiers_down Bitmask of modifier KEYs that are currently held
int modifiers_block Bitmask of modifier KEYs that will block all game input
bool modifiers_clear_input Enable to clear affected input when modifiers are held, disable to ignore all input events, i.e. keep held button state as it was before pressing the modifier key

Quad

Type Name Description
Quad new()
Quad new(Quad other)
Quad new(Vec2 bottom_left_, Vec2 bottom_right_, Vec2 top_right_, Vec2 top_left_)
Quad new(float _bottom_left_x, float _bottom_left_y, float _bottom_right_x, float _bottom_right_y, float _top_right_x, float _top_right_y, float _top_left_x, float _top_left_y)
Quad new(AABB aabb)
float bottom_left_x
float bottom_left_y
float bottom_right_x
float bottom_right_y
float top_right_x
float top_right_y
float top_left_x
float top_left_y
AABB get_AABB() Returns the max/min values of the Quad
Quad offset(Vec2 off)
Quad offset(float off_x, float off_y)
Quad rotate(float angle, float px, float py) Rotates a Quad by an angle, px/py are not offsets, use :get_AABB():center() to get approximated center for symmetrical quadrangle
Quad flip_horizontally()
Quad flip_vertically()
bool is_point_inside(Vec2 p, optional epsilon) Check if point lies inside of triangle
Because of the imprecise nature of floating point values, the epsilon value is needed to compare the floats, the default value is 0.00001
bool is_point_inside(float x, float y, optional epsilon)
Quad set(Quad other)
tuple<Vec2, Vec2, Vec2, Vec2> split() Returns the corners in order: bottom_left, bottom_right, top_right, top_left

RenderInfo

For using a custom normal map:

set_post_entity_spawn(function(ent)
  -- Doesn't really make sense with this texture, you can use your custom normal texture id here
  ent.rendering_info:set_normal_map_texture(TEXTURE.DATA_TEXTURES_FLOORSTYLED_GOLD_NORMAL_0)
  ent.rendering_info.shader = 30 -- Make sure to set the shader to one that uses normal map
end, SPAWN_TYPE.LEVEL_GEN, MASK.FLOOR, ENT_TYPE.FLOORSTYLED_MINEWOOD)

Note: if using set_texture_num, make sure to have used set_second_texture/set_third_texture before, since not doing so can lead to crashes

Some information used to render the entity, can not be changed, used in Entity

Type Name Description
float x
float y
WORLD_SHADER shader
Quad source
Quad destination
float tilew
float tileh
bool facing_left
bool render_inactive
int texture_num
Entity get_entity()
bool set_normal_map_texture(TEXTURE texture_id) Sets second_texture to the texture specified, then sets third_texture to SHINE_0 and texture_num to 3. You still have to change shader to 30 to render with normal map (same as COG normal maps)
optional<TEXTURE> get_second_texture()
optional<TEXTURE> get_third_texture()
bool set_second_texture(TEXTURE texture_id)
bool set_third_texture(TEXTURE texture_id)
bool set_texture_num(int num) Set the number of textures that may be used, need to have them set before for it to work
CallbackId set_pre_virtual(RENDER_INFO_OVERRIDE entry, function fun) Hooks before the virtual function at index entry.
CallbackId set_post_virtual(RENDER_INFO_OVERRIDE entry, function fun) Hooks after the virtual function at index entry.
nil clear_virtual(CallbackId callback_id) Clears the hook given by callback_id, alternatively use clear_callback() inside the hook.
CallbackId set_pre_dtor(function fun) Hooks before the virtual function.
The callback signature is nil dtor(RenderInfo self)
CallbackId set_post_dtor(function fun) Hooks after the virtual function.
The callback signature is nil dtor(RenderInfo self)
CallbackId set_pre_render(function fun) Hooks before the virtual function.
The callback signature is bool render(RenderInfo self, float float, VanillaRenderContext vanilla_render_context)
CallbackId set_post_render(function fun) Hooks after the virtual function.
The callback signature is nil render(RenderInfo self, float float, VanillaRenderContext vanilla_render_context)

RoomOwnerDetails

Used in RoomOwnersInfo

Type Name Description
int layer
int room_index
int owner_uid

RoomOwnersInfo

Used in StateMemory

Type Name Description
map<int, ItemOwnerDetails> owned_items key/index is the uid of an item
vector<RoomOwnerDetails> owned_rooms

SaveState

Type Name Description
SaveState new() Create a new temporary SaveState/clone of the main level state. Unlike save_state slots that are preallocated by the game anyway, these will use 32MiB a pop and aren't freed automatically, so make sure to clear them or reuse the same one to save memory. The garbage collector will eventually clear the SaveStates you don't have a handle to any more though.
nil load() Load a SaveState
nil save() Save over a previously allocated SaveState
nil clear() Delete the SaveState and free the memory. The SaveState can't be used after this.
StateMemory get_state() Access the StateMemory inside a SaveState

SharedIO

Type Name Description
optional<bool> wantkeyboard
optional<bool> wantmouse

ShortTileCodeDef

Used in get_short_tile_code, get_short_tile_code_definition and PostRoomGenerationContext

Type Name Description
TILE_CODE tile_code Tile code that is used by default when this short tile code is encountered. Defaults to 0.
int chance Chance in percent to pick tile_code over alt_tile_code, ignored if chance == 0. Defaults to 100.
TILE_CODE alt_tile_code Alternative tile code, ignored if chance == 100. Defaults to 0.

SpawnInfo

Type Name Description
ROOM_TEMPLATE room_template
Entity grid_entity Grid entity at this position, will only try to spawn procedural if this is nil
float x
float y

SpritePosition

Type Name Description
int column
int row

Triangle

Type Name Description
Triangle new()
Triangle new(Triangle other)
Triangle new(Vec2 _a, Vec2 _b, Vec2 _c)
Triangle new(float ax, float ay, float bx, float by, float cx, float cy)
Vec2 A
Vec2 B
Vec2 C
Triangle offset(Vec2 off)
Triangle offset(float x, float y)
Triangle rotate(float angle, float px, float py) Rotate triangle by an angle, the px/py are just coordinates, not offset from the center
Vec2 center() Also known as centroid
tuple<float, float, float> get_angles() Returns ABC, BCA, CAB angles in radians
Triangle scale(float scale)
float area()
bool is_point_inside(Vec2 p, optional epsilon) Check if point lies inside of triangle
Because of the imprecise nature of floating point values, the epsilon value is needed to compare the floats, the default value is 0.0001
bool is_point_inside(float x, float y, optional epsilon)
Triangle set(Triangle other)
tuple<Vec2, Vec2, Vec2> split() Returns the corner points

UdpServer

Type Name Description

Vec2

Simple object to hold pair of coordinates

Type Name Description
Vec2 new()
Vec2 new(Vec2 other)
Vec2 new(float x_, float y_)
float x
float y
Vec2 rotate(float angle, float px, float py)
Vec2 rotate(float angle, Vec2 p)
float distance_to(Vec2 other) Just simple Pythagoras theorem
Vec2 set(Vec2 other)
tuple<float, float> split()

Input types

ControllerInput

Type Name Description
array<ControllerButton, 16> buttons Zero-based indexing. Use PlayerSlot.input_mapping_controller or RAW_BUTTON (or RAW_DUALSHOCK) to index this.

Gamepad

Used in ImGuiIO

Type Name Description
bool enabled
GAMEPAD buttons
float lt
float rt
float lx
float ly
float rx
float ry

ImGuiIO

Used in get_io, also see set_hotkey and GuiDrawContext::key_picker.

Type Name Description
Vec2 displaysize
float framerate
bool wantkeyboard True if anyone else (i.e. some input box, OL hotkey) is already capturing keyboard or reacted to this keypress and you probably shouldn't.
Set this to true every GUIFRAME while you want to capture keyboard and disable UI key bindings and game keys. Won't affect UI or game keys on this frame though, that train has already sailed. Also see Bucket::Overlunky for other ways to override key bindings.
Do not set this to false, unless you want the player input to bleed through input fields.
array<bool, 652> keys ZeroIndexArray of currently held keys, indexed by KEY <= 0xFF
keydown Returns true if key or chord is down.
bool keydown(KEY keychord)
bool keydown(char key)
keypressed Returns true if key or chord was pressed this GUIFRAME.
bool keypressed(KEY keychord, bool repeat = false)
bool keypressed(char key, bool repeat = false)
keyreleased Returns true if key or chord was released this GUIFRAME.
bool keyreleased(KEY keychord)
bool keyreleased(char key)
bool keyctrl
bool keyshift
bool keyalt
bool keysuper
bool modifierdown(int chord) bool modifierdown(KEY keychord)
Returns true if modifiers in chord are down, ignores other keys in chord.
bool wantmouse True if anyone else (i.e. hovering some window) is already capturing mouse and you probably shouldn't.
Set this to true if you want to capture mouse and override UI mouse binding.
Vec2 mousepos
array<bool, 5> mousedown
array<bool, 5> mouseclicked
array<bool, 5> mousedoubleclicked
array<bool, 5> mousereleased
float mousewheel
Gamepad gamepad
Gamepad gamepads(int index) Gamepad gamepads(int index)
This is the XInput index 1..4, might not be the same as the player slot.
bool showcursor True when the cursor is visible.
Set to true to force the cursor visible.

InputMapping

Used in PlayerSlot

Type Name Description
int jump
int attack
int bomb
int rope
int walk_run
int use_door_buy
int pause_menu
int journal
int left
int right
int up
int down
array<RAW_KEY, 12> mapping Can be indexed with INPUT_FLAG. Keyboard uses RAW_KEY values, controller uses RAW_BUTTON values.

PlayerInputs

Used in StateMemory

Type Name Description
array<PlayerSlot, MAX_PLAYERS> player_slots
PlayerSlot player_slot_1
PlayerSlot player_slot_2
PlayerSlot player_slot_3
PlayerSlot player_slot_4
array<PlayerSlotSettings, MAX_PLAYERS> player_settings
PlayerSlotSettings player_slot_1_settings
PlayerSlotSettings player_slot_2_settings
PlayerSlotSettings player_slot_3_settings
PlayerSlotSettings player_slot_4_settings

RawInput

Type Name Description
array<KeyboardKey, 112> keyboard State of all keyboard buttons in a random game order as usual, most key indexes can be found in RAW_KEY. Zero-based indexing, i.e. use PlayerSlot.input_mapping_keyboard directly to index this.
array<ControllerInput, 12> controller State of controller buttons per controller. Zero-based indexing, i.e. use GameProps.input_index directly to index this.

Journal types

JournalPage

Used in set_callback with ON.RENDER_POST_JOURNAL_PAGE

Type Name Description
TextureRenderingInfo background
int page_number
bool is_right_side_page() background.x < 0
JOURNAL_PAGE_TYPE get_type()

JournalPageBestiary

Derived from JournalPage JournalPageDiscoverable

Type Name Description
TextureRenderingInfo monster_background
TextureRenderingInfo monster_icon
TextureRenderingInfo defeated_killedby_black_bars
TextRenderingInfo defeated_text_info
TextRenderingInfo defeated_value_text_info
TextRenderingInfo killedby_text_info
TextRenderingInfo killedby_value_text_info

JournalPageDeathCause

Derived from JournalPage

Type Name Description
TextRenderingInfo death_cause_text_info

JournalPageDeathMenu

Derived from JournalPage

Type Name Description
TextRenderingInfo game_over_text_info
TextRenderingInfo level_text_info
TextRenderingInfo level_value_text_info
TextRenderingInfo money_text_info
TextRenderingInfo money_value_text_info
TextRenderingInfo time_text_info
TextRenderingInfo time_value_text_info

JournalPageDiscoverable

Derived from JournalPage

Type Name Description
bool show_main_image
TextRenderingInfo title_text_info
TextRenderingInfo entry_text_info
TextRenderingInfo chapter_title_text_info

JournalPageFeats

Derived from JournalPage

Type Name Description
TextRenderingInfo chapter_title_text_info
TextureRenderingInfo feat_icons

JournalPageItems

Derived from JournalPage JournalPageDiscoverable

Type Name Description
TextureRenderingInfo item_icon
TextureRenderingInfo item_background

JournalPageJournalMenu

Derived from JournalPage

Type Name Description
TextRenderingInfo journal_text_info
TextureRenderingInfo completion_badge

JournalPageLastGamePlayed

Derived from JournalPage

Type Name Description
TextureRenderingInfo main_image
TextRenderingInfo last_game_played_text_info
TextRenderingInfo level_text_info
TextRenderingInfo level_value_text_info
TextRenderingInfo money_text_info
TextRenderingInfo money_value_text_info
TextRenderingInfo time_text_info
TextRenderingInfo time_value_text_info
int sticker_count
array<TextureRenderingInfo, 20> stickers

JournalPagePeople

Derived from JournalPage JournalPageDiscoverable

Type Name Description
TextureRenderingInfo character_background
TextureRenderingInfo character_icon
TextureRenderingInfo character_drawing

JournalPagePlaces

Derived from JournalPage JournalPageDiscoverable

Type Name Description
TextureRenderingInfo main_image

JournalPagePlayerProfile

Derived from JournalPage

Type Name Description
TextureRenderingInfo player_icon
int player_icon_id
TextRenderingInfo player_profile_text_info
TextRenderingInfo plays_text_info
TextRenderingInfo plays_value_text_info
TextRenderingInfo wins_text_info
TextRenderingInfo wins_value_text_info
TextRenderingInfo deaths_text_info
TextRenderingInfo deaths_value_text_info
TextRenderingInfo win_pct_text_info
TextRenderingInfo win_pct_value_text_info
TextRenderingInfo average_score_text_info
TextRenderingInfo average_score_value_text_info
TextRenderingInfo top_score_text_info
TextRenderingInfo top_score_value_text_info
TextRenderingInfo deepest_level_text_info
TextRenderingInfo deepest_level_value_text_info
TextRenderingInfo deadliest_level_text_info
TextRenderingInfo deadliest_level_value_text_info
TextRenderingInfo average_time_text_info
TextRenderingInfo average_time_value_text_info
TextRenderingInfo best_time_text_info
TextRenderingInfo best_time_value_text_info

JournalPageProgress

Derived from JournalPage

Type Name Description
TextureRenderingInfo coffeestain_top

JournalPageTraps

Derived from JournalPage JournalPageDiscoverable

Type Name Description
TextureRenderingInfo trap_icon
TextureRenderingInfo trap_background

Levelgen types

DoorCoords

Deprecated kept for backward compatibility, don't use, check LevelGenSystem.exit_doors

Type Name Description
float door1_x
float door1_y
float door2_x door2 only valid when there are two in the level, like Volcana drill, Olmec, ...
float door2_y

LevelGenSystem

Data relating to level generation, changing anything in here from ON.LEVEL or later will likely have no effect, used in StateMemory

Type Name Description
SHOP_TYPE shop_type
SHOP_TYPE backlayer_shop_type
int shop_music
int backlayer_shop_music
float spawn_x
float spawn_y
int spawn_room_x
int spawn_room_y
vector<Vec2> exit_doors
array<ThemeInfo, 18> themes
int flags
int flags2
int flags3
array<int, 17> level_config

Lighting types

Illumination

Generic object for lights in the game, you can make your own with create_illumination
Used in StateMemory, Player, PlayerGhost, BurningRopeEffect ...

Type Name Description
array<LightParams, 4> lights Table of light1, light2, ... etc.
LightParams light1
LightParams light2
LightParams light3
LightParams light4 It's rendered on objects around, not as an actual bright spot
float brightness
float brightness_multiplier
float light_pos_x
float light_pos_y
float offset_x
float offset_y
float distortion
int entity_uid
int timer
int flags see flags.hpp illumination_flags
LIGHT_TYPE type_flags
bool enabled
int layer

LightParams

Used in Illumination

Type Name Description
float red
float green
float blue
float size
Color as_color() Returns LightParams as Color, note that size = alpha

Liquid types

LiquidPhysics

Use LIQUID_POOL enum for the index
Used in StateMemory

Type Name Description
array<LiquidPool, 5> pools

LiquidPhysicsEngine

Used in LiquidPool

Type Name Description
bool pause
float gravity
float cohesion
float elasticity
float size
float weight
int count

LiquidPhysicsParams

Used in LiquidPool

Type Name Description
float gravity
float cohesion
float elasticity

LiquidPool

Used in LiquidPhysics

Type Name Description
LiquidPhysicsParams default
LiquidPhysicsEngine engine

Logic types

Logic

Used in LogicList

Type Name Description
LOGIC logic_index

LogicApepTrigger

Used in LogicList Derived from Logic

Type Name Description
int spawn_cooldown
bool cooling_down
bool apep_journal_entry_logged

LogicBasecampSpeedrun

Used in LogicList Derived from Logic

Type Name Description
int administrator entity uid of the character that keeps the time
int crate entity uid. you must break this crate for the run to be valid, otherwise you're cheating

LogicCOGAnkhSacrifice

Used in LogicList Derived from Logic

Type Name Description
int timer

LogicChallenge

Used in LogicMoonChallenge, LogicStarChallenge, LogicSunChallenge Derived from Logic

Type Name Description
int floor_challenge_entrance_uid
int floor_challenge_waitroom_uid
bool challenge_active
int forcefield_countdown

LogicDiceShop

Used in LogicList Derived from Logic

Type Name Description
int boss_uid
ENT_TYPE boss_type
int bet_machine entity uid
int die1 entity uid
int die2 entity uid
int die_1_value
int die_2_value
int prize_dispenser entity uid
int prize entity uid
int forcefield entity uid
bool bet_active
bool forcefield_deactivated
int result_announcement_timer the time the boss waits after your second die throw to announce the results
int won_prizes_count
int balance cash balance of all the games

LogicGhostToast

Used in LogicList Derived from Logic

Type Name Description
int toast_timer default 90

LogicList

Used in StateMemory

Type Name Description
LogicTutorial tutorial Handles dropping of the torch and rope in intro routine (first time play)
LogicOuroboros ouroboros
LogicBasecampSpeedrun basecamp_speedrun Keep track of time, player position passing official
Logic ghost_trigger It's absence is the only reason why ghost doesn't spawn at boss levels or CO
LogicGhostToast ghost_toast_trigger
Logic tun_aggro Spawns tun at the door at 30s mark
LogicDiceShop diceshop
LogicTunPreChallenge tun_pre_challenge
LogicMoonChallenge tun_moon_challenge
LogicStarChallenge tun_star_challenge
LogicSunChallenge tun_sun_challenge
LogicMagmamanSpawn magmaman_spawn
LogicUnderwaterBubbles water_bubbles Only the bubbles that spawn from the floor (no border tiles, checks decoration flag), also spawn droplets falling from ceiling
Even without it, entities moving in water still spawn bubbles
LogicOlmecCutscene olmec_cutscene
LogicTiamatCutscene tiamat_cutscene
LogicApepTrigger apep_spawner Triggers and spawns Apep only in rooms set as ROOM_TEMPLATE.APEP
LogicCOGAnkhSacrifice city_of_gold_ankh_sacrifice All it does is it runs transition to Duat after time delay (sets the state next theme etc. and state.items for proper player respawn)
Logic duat_bosses_spawner
LogicTiamatBubbles bubbler Spawn rising bubbles at Tiamat (position hardcoded)
LogicTuskPleasurePalace tusk_pleasure_palace Triggers aggro on everyone when non-high roller enters door
Logic discovery_info black market, vlad, wet fur discovery, logic shows the toast
Logic black_market Changes the camera bounds when you reach black market
Logic jellyfish_trigger
LogicArena1 arena_1 Handles create spawns and more, is cleared as soon as the winner is decided (on last player alive)
Logic arena_2
Logic arena_3 Handles time end death
LogicArenaAlienBlast arena_alien_blast
LogicArenaLooseBombs arena_loose_bombs
Logic start_logic(LOGIC idx) This only properly constructs the base class
you may still need to initialise the parameters correctly
nil stop_logic(LOGIC idx)
nil stop_logic(Logic log)

LogicMagmamanSpawn

Used in LogicList Derived from Logic

Type Name Description
vector<MagmamanSpawnPosition> magmaman_positions
nil add_spawn(int x, int y)
nil add_spawn(MagmamanSpawnPosition ms)
nil remove_spawn(int x, int y)
nil remove_spawn(MagmamanSpawnPosition ms)

LogicMoonChallenge

Used in LogicList Derived from Logic LogicChallenge

Type Name Description
int mattock_uid entity uid

LogicOlmecCutscene

Used in LogicList Derived from Logic

Type Name Description
Entity fx_olmecpart_large
Entity olmec
Entity player
Entity cinematic_anchor
int timer

LogicOuroboros

Used in LogicList Derived from Logic

Type Name Description
SoundMeta sound
int timer

LogicStarChallenge

Used in LogicList Derived from Logic LogicChallenge

Type Name Description
vector<Entity> torches
int start_countdown

LogicSunChallenge

Used in LogicList Derived from Logic LogicChallenge

Type Name Description
int start_countdown

LogicTiamatBubbles

Used in LogicList Derived from Logic

Type Name Description
int bubble_spawn_timer

LogicTiamatCutscene

Used in LogicList Derived from Logic

Type Name Description
Entity tiamat
Entity player
Entity cinematic_anchor
int timer

LogicTuskPleasurePalace

Used in LogicList Derived from Logic

Type Name Description
int locked_door

LogicTutorial

Used in LogicList Derived from Logic

Type Name Description
Entity pet_tutorial
int timer

LogicUnderwaterBubbles

Used in LogicList Derived from Logic

Type Name Description
float gravity_direction 1.0 = normal, -1.0 = inversed, other values have undefined behavior
this value basically have to be the same as return from ThemeInfo:get_liquid_gravity()
int droplets_spawn_chance It's inverse chance, so the lower the number the higher the chance, values below 10 may crash the game
bool droplets_enabled Enable/disable spawn of ENT_TYPE.FX_WATER_DROP from ceiling (or ground if liquid gravity is inverse)

Online types

Online

Can be accessed via global online

Type Name Description
array<OnlinePlayer, 4> online_players
OnlinePlayer local_player
OnlineLobby lobby

OnlineLobby

Used in Online

Type Name Description
int code
int local_player_slot
string get_code() Gets the string equivalent of the code

OnlinePlayer

Used in Online

Type Name Description
int ready_state
int character
string player_name

Particle types

Particle

Used in ParticleEmitterInfo

Type Name Description
float x
float y
float velocityx
float velocityy
uColor color
float width
float height
int lifetime
int max_lifetime

ParticleDB

Used in ParticleDB, get_particle_type

Type Name Description
ParticleDB new(ParticleDB other)
ParticleDB new(PARTICLEEMITTER particle_id)
PARTICLEEMITTER id
int spawn_count_min
int spawn_count
int lifespan_min
int lifespan
int sheet_id
int animation_sequence_length
float spawn_interval
float shrink_growth_factor
float rotation_speed
float opacity
float hor_scattering
float ver_scattering
float scale_x_min
float scale_x
float scale_y_min
float scale_y
float hor_deflection_1
float ver_deflection_1
float hor_deflection_2
float ver_deflection_2
float hor_velocity
float ver_velocity
int red
int green
int blue
bool permanent
bool invisible
TEXTURE get_texture()
bool set_texture(TEXTURE texture_id)

ParticleEmitterInfo

Generic type for creating particles in the game, you can make your own with generate_world_particles or generate_screen_particles
Used in ScreenCharacterSelect, ScreenTitle, CursedEffect, OnFireEffect, PoisonedEffect ...

Type Name Description
ParticleDB particle_type
ParticleDB particle_type2
int particle_count
int particle_count_back_layer
int entity_uid
float x
float y
float offset_x
float offset_y
int layer
int draw_depth
array<Particle> emitted_particles
array<Particle> emitted_particles_back_layer

Savegame types

Constellation

Type Name Description
int star_count
array<ConstellationStar, 45> stars
float scale
int line_count
array<ConstellationLine, 90> lines
float line_red_intensity

ConstellationLine

Type Name Description
int from
int to

ConstellationStar

Type Name Description
int type
float x
float y
float size
float red
float green
float blue
float alpha
float halo_red
float halo_green
float halo_blue
float halo_alpha
bool canis_ring
bool fidelis_ring

SaveData

Type Name Description
array<bool, 16> places
array<bool, 78> bestiary
array<bool, 38> people
array<bool, 54> items
array<bool, 24> traps
string last_daily
int characters 20bit bitmask of unlocked characters
int tutorial_state Tutorial state 0..4. Changes the camp layout, camera and lighting. (0=nothing, 1=journal got, 2=key spawned, 3=door unlocked, 4=complete)
int shortcuts Terra quest state 0..10 (0=not met ... 10=complete)
array<int, 78> bestiary_killed
array<int, 78> bestiary_killed_by
array<int, 38> people_killed
array<int, 38> people_killed_by
int plays
int deaths
int wins_normal
int wins_hard
int wins_special
int score_total
int score_top
int deepest_area
int deepest_level
int time_best
int time_total
int time_tutorial
array<int, 20> character_deaths
array<int, 3> pets_rescued
bool completed_normal
bool completed_ironman
bool completed_hard
bool profile_seen
bool seeded_unlocked
int world_last
int level_last
int theme_last
int score_last
int time_last
array<ENT_TYPE, 20> stickers
array<int, 4> players
Constellation constellation

Screen types

FlyingThing

Type Name Description
TextureRenderingInfo texture_info
ENT_TYPE entity_type
float spritesheet_column
float spritesheet_row
float spritesheet_animation_length
float velocity_x
float amplitude
float frequency
float sinewave_angle

JournalPopupUI

Type Name Description
TextureRenderingInfo wiggling_page_icon
TextureRenderingInfo black_background
TextureRenderingInfo button_icon
float wiggling_page_angle
int chapter_to_show
int entry_to_show
int timer
float slide_position

JournalUI

Type Name Description
int state
JOURNALUI_PAGE_SHOWN chapter_shown
int current_page
int flipping_to_page
int max_page_count
TextureRenderingInfo book_background
TextureRenderingInfo arrow_left
TextureRenderingInfo arrow_right
TextureRenderingInfo entire_book
int fade_timer
int page_timer
float opacity
vector<JournalPage> pages Stores pages loaded into memory. It's not cleared after the journal is closed or when you go back to the main (menu) page.
Use :get_type() to check page type and cast it correctly (see ON.RENDER_PRE_JOURNAL_PAGE)
Type Name Description
float woodpanels_velocity
float woodpanels_progress
float scroll_unfurl_progress
float bottom_woodpanel_speed_multiplayer
float bottom_woodpanel_y_offset
TextureRenderingInfo bottom_woodpanel
TextureRenderingInfo top_woodpanel
TextureRenderingInfo scroll
TextureRenderingInfo top_woodpanel_left_scrollhandle
TextureRenderingInfo top_woodpanel_right_scrollhandle
STRINGID scroll_text
STRINGID bottom_left_text
STRINGID bottom_right_text
STRINGID bottom_middle_text
bool top_woodpanel_visible
bool bottom_woodpanel_visible
bool toggle_woodpanel_slidein_animation
bool capitalize_scroll_text

OnlineLobbyScreenPlayer

Type Name Description
int platform_icon 16 = PC, 17 = Discord, 18 = Steam, 19 = Xbox, 32 = switch, 48 = PS, 49 = PS again?
int character 0 - Ana Spelunky, 1 - Margaret Tunnel, 2 - Colin Northward, 3 - Roffy D. Sloth.. and so on. Same order as in ENT_TYPE
bool ready
bool searching

PauseUI

Type Name Description
float menu_slidein_progress
TextureRenderingInfo blurred_background
TextureRenderingInfo woodpanel_left
TextureRenderingInfo woodpanel_middle
TextureRenderingInfo woodpanel_right
TextureRenderingInfo woodpanel_top
TextureRenderingInfo scroll
TextureRenderingInfo confirmation_panel Prompt background
int selected_option It's set wh game displays the prompt
bool prompt_visible
array<int, MAX_PLAYERS> buttons_actions
array<int, MAX_PLAYERS> buttons_movement
int visibility 0 - Invisible, 1 - Sliding down, 2 - Visible, 3 - Sliding up

SaveRelated

Type Name Description
JournalPopupUI journal_popup_ui

Screen

Type Name Description
float render_timer
nil init() Initializes the screen.

ScreenArenaIntro

Derived from Screen

Type Name Description
TextureRenderingInfo players
TextureRenderingInfo background_colors
TextureRenderingInfo vertical_lines
TextureRenderingInfo vertical_line_electricity_effect
TextureRenderingInfo left_scroll
TextureRenderingInfo right_scroll
float scroll_unfurl
bool waiting
float names_opacity
float line_electricity_effect_timer
int state
int countdown
array<ParticleEmitterInfo, 9> particles

ScreenArenaItems

Derived from Screen

Type Name Description
MenuScreenPanels screen_panels
TextureRenderingInfo brick_background
TextureRenderingInfo black_background_bottom_right
TextureRenderingInfo woodpanel_bottom
TextureRenderingInfo scroll_bottom
TextureRenderingInfo scroll_right_handle_bottom
TextureRenderingInfo held_item_crate_on_scroll
TextureRenderingInfo held_item_on_scroll
TextureRenderingInfo item_background
TextureRenderingInfo toggles_background
TextureRenderingInfo item_selection_gold_outline
TextureRenderingInfo item_icons
TextureRenderingInfo item_held_badge
TextureRenderingInfo item_equipped_badge
TextureRenderingInfo item_off_gray_overlay
TextureRenderingInfo esc_woodpanel
map<int, float> items_to_gray_out
float center_panels_horizontal_slide_position
float esc_panel_slide_timer
int selected_item_index
ScreenControls controls

ScreenArenaLevel

Derived from Screen

Type Name Description
TextureRenderingInfo get_ready
TextureRenderingInfo get_ready_gray_background
TextureRenderingInfo get_ready_outline
array<ParticleEmitterInfo, 11> particles

ScreenArenaMenu

Derived from Screen

Type Name Description
MenuScreenPanels screen_panels
TextureRenderingInfo brick_background
TextureRenderingInfo blurry_border
TextureRenderingInfo blurry_border2
TextureRenderingInfo characters_drawing
TextureRenderingInfo info_black_background
TextureRenderingInfo main_panel_top_left_corner
TextureRenderingInfo main_panel_top
TextureRenderingInfo main_panel_top_right_corner
TextureRenderingInfo main_panel_left
TextureRenderingInfo main_panel_center
TextureRenderingInfo main_panel_right
TextureRenderingInfo main_panel_bottom_left_corner
TextureRenderingInfo main_panel_bottom
TextureRenderingInfo main_panel_bottom_right_corner
TextureRenderingInfo rules_scroll
TextureRenderingInfo black_option_boxes_left
TextureRenderingInfo black_option_boxes_center
TextureRenderingInfo black_option_boxes_right
TextureRenderingInfo gold_option_outline
TextureRenderingInfo option_icons
TextureRenderingInfo option_left_arrow
TextureRenderingInfo option_right_arrow
TextureRenderingInfo bottom_left_bricks
TextureRenderingInfo top_left_esc_panel
TextureRenderingInfo next_panel
float center_panels_hor_slide_position
float esc_next_panels_slide_timer
float main_panel_vertical_scroll_position
int selected_option_index
ScreenControls controls

ScreenArenaScore

Derived from Screen

Type Name Description
float woodpanel_slide
float scroll_unfurl
TextureRenderingInfo woodpanel
TextureRenderingInfo woodpanel_left_scroll
TextureRenderingInfo woodpanel_right_scroll
STRINGID text_id_1
STRINGID text_id_2
bool woodpanel_visible
bool woodpanel_slide_toggle
int animation_sequence
TextureRenderingInfo background
TextureRenderingInfo ok_panel
TextureRenderingInfo ready_panel
TextureRenderingInfo ready_speechbubble_indicator
TextureRenderingInfo pillars
TextureRenderingInfo bottom_lava
TextureRenderingInfo players
TextureRenderingInfo player_shadows
TextureRenderingInfo score_counter
TextureRenderingInfo lava_bubbles
array<bool, MAX_PLAYERS> player_won
float victory_jump_y_pos
float victory_jump_velocity
bool squash_and_celebrate
array<bool, MAX_PLAYERS> player_ready
int next_transition_timer
array<float, MAX_PLAYERS> player_bottom_pillar_offset
array<float, MAX_PLAYERS> player_crushing_pillar_height
array<bool, MAX_PLAYERS> player_create_giblets
float next_sidepanel_slidein_timer
array<ParticleEmitterInfo, 13> particles
array<ScreenArenaScoreLavaBubble, 15> lava_bubbles_positions

ScreenArenaScoreLavaBubble

Type Name Description
float x
float y
int timer1
int timer2
bool visible

ScreenArenaStagesSelect

Derived from Screen

Type Name Description
MenuScreenPanels screen_panels
int buttons
TextureRenderingInfo brick_background
TextureRenderingInfo info_black_background
TextureRenderingInfo woodenpanel_center
TextureRenderingInfo blocky_level_representation
TextureRenderingInfo theme_indicator
TextureRenderingInfo bricks_bottom_left
TextureRenderingInfo grid_background_row_0
TextureRenderingInfo grid_background_row_1
TextureRenderingInfo grid_background_row_2
TextureRenderingInfo grid_background_row_3
TextureRenderingInfo grid_background_row_4
TextureRenderingInfo grid_background_row_5
TextureRenderingInfo grid_background_row_6
TextureRenderingInfo grid_background_row_7
TextureRenderingInfo grid_background_disabled_cross
TextureRenderingInfo grid_background_manipulators
TextureRenderingInfo unknown21
TextureRenderingInfo grid_disabled_cross
TextureRenderingInfo grid_yellow_highlighter
TextureRenderingInfo woodpanel_esc
TextureRenderingInfo woodpanel_fight
TextureRenderingInfo big_player_drawing
TextureRenderingInfo players_turn_scroll
TextureRenderingInfo players_turn_scroll_handle
TextureRenderingInfo grid_player_icon
map<int, float> stages_to_gray_out
float panels_slide_from_both_sides
float visibility_all_stages
int selected_stage_index
ScreenControls controls

ScreenCamp

Derived from Screen

Type Name Description
int buttons

ScreenCharacterSelect

Derived from Screen

Type Name Description
float main_background_zoom_progress
float main_background_zoom_target
float blurred_border_zoom_progress
float blurred_border_zoom_target
MenuScreenPanels screen_panels
TextureRenderingInfo mine_entrance_background
TextureRenderingInfo character
TextureRenderingInfo character_shadow
TextureRenderingInfo character_flag
TextureRenderingInfo character_left_arrow
TextureRenderingInfo character_right_arrow
TextureRenderingInfo mine_entrance_border
TextureRenderingInfo mine_entrance_shutter
TextureRenderingInfo background
TextureRenderingInfo blurred_border
TextureRenderingInfo blurred_border2
TextureRenderingInfo topleft_woodpanel_esc
TextureRenderingInfo start_sidepanel
TextureRenderingInfo quick_select_panel
TextureRenderingInfo quick_select_selected_char_background
TextureRenderingInfo quick_select_panel_related
array<float, MAX_PLAYERS> player_shutter_timer
array<float, MAX_PLAYERS> player_x
array<float, MAX_PLAYERS> player_y
array<array<float, 2>, MAX_PLAYERS> player_arrow_slidein_timer
array<bool, MAX_PLAYERS> player_facing_left
array<bool, MAX_PLAYERS> player_quickselect_shown
array<float, MAX_PLAYERS> player_quickselect_fadein_timer
array<array<float, 2>, MAX_PLAYERS> player_quickselect_coords
array<float, MAX_PLAYERS> player_quickselect_wiggle_angle
float topleft_woodpanel_esc_slidein
float start_panel_slidein
float action_buttons_keycap_size
int next_screen_to_load
bool not_ready_to_start_yet
int available_mine_entrances
int amount_of_mine_entrances_activated
TextureRenderingInfo screen_blackout
float blackout_transparency
bool start_pressed
bool transition_to_game_started
bool disable_controls
array<FlyingThing, 6> flying_things
int flying_thing_countdown
ParticleEmitterInfo particle_ceilingdust_smoke
ParticleEmitterInfo particle_ceilingdust_rubble
ParticleEmitterInfo particle_mist
ParticleEmitterInfo particle_torchflame_smoke1
ParticleEmitterInfo particle_torchflame_flames1
ParticleEmitterInfo particle_torchflame_smoke2
ParticleEmitterInfo particle_torchflame_flames2
ParticleEmitterInfo particle_torchflame_smoke3
ParticleEmitterInfo particle_torchflame_flames3
ParticleEmitterInfo particle_torchflame_smoke4
ParticleEmitterInfo particle_torchflame_flames4
array<SoundMeta, 4> torch_sound
array<int, MAX_PLAYERS> buttons

ScreenCodeInput

Derived from Screen

Type Name Description
MenuScreenPanels screen_panels
bool allow_random needs to be set before opening the screen to show the correct text at the bottom
int selected_button_index
bool pressed_select
float topleft_woodpanel_esc_slidein
STRINGID scroll_text_id
STRINGID start_text_id
TextureRenderingInfo main_woodpanel_left_border
TextureRenderingInfo main_woodpanel_center
TextureRenderingInfo main_woodpanel_right_border
TextureRenderingInfo top_scroll
TextureRenderingInfo letter_cutouts
TextureRenderingInfo hand_pointer
TextureRenderingInfo key_background
TextureRenderingInfo topleft_woodpanel_esc
TextureRenderingInfo start_sidepanel
float start_sidepanel_slidein
int seed_length Current input length (0-8). You probably shouldn't write to this, except to set it to 0.
optional<int> get_seed() Get the seed currently entered in the seed dialog or nil if nothing is entered. Will also return incomplete seeds, check seed_length to verify it's ready.
nil set_seed(optional seed, optional length) Set the seed entered in the seed dialog. Call without arguments to clear entered seed. Optionally enter a length to set partial seed.

ScreenConstellation

-- forces any level transition to immediately go to constellation ending with custom text
set_callback(function()
    if state.screen_next == SCREEN.TRANSITION then
      if state.level_count == 0 then state.level_count = 1 end -- no /0
      state.win_state = WIN_STATE.COSMIC_OCEAN_WIN
      state.screen_next = SCREEN.CONSTELLATION
      state.world_next = 8
      state.level_next = 99
      state.theme_next = THEME.COSMIC_OCEAN
      state.level_gen.themes[THEME.COSMIC_OCEAN].sub_theme = state.level_gen.themes[state.theme]
      state:force_current_theme(THEME.COSMIC_OCEAN)
      set_global_interval(function()
        if state.screen_constellation.sequence_state == 2 then
          state.screen_constellation.constellation_text = "Lol u stars now"
          clear_callback()
        end
      end, 1)
    end
  end, ON.PRE_LOAD_SCREEN)

Derived from Screen

Type Name Description
int sequence_state
int animation_timer
float constellation_text_opacity
string constellation_text
SoundMeta explosion_and_loop
SoundMeta music

ScreenControls

Type Name Description
bool up
bool down
bool left
bool right
int direction_input -1 - none, 0 - UP, 1 - DOWN, 2 - LEFT, 3 - RIGHT
int hold_down_timer Delay after which fast scroll activates (can stop at different value, only matters when you hold down the direction button)
int fast_scroll_timer

ScreenCredits

Derived from Screen

Type Name Description
float credits_progression
SoundMeta bg_music_info

ScreenDeath

Derived from Screen

Type Name Description

ScreenEnterOnlineCode

Available in ScreenOnlineLobby Derived from Screen ScreenCodeInput

Type Name Description
TextureRenderingInfo enter_code_your_code_scroll
TextureRenderingInfo enter_code_your_code_scroll_left_handle
TextureRenderingInfo enter_code_your_code_scroll_right_handle

ScreenIntro

Derived from Screen

Type Name Description
TextureRenderingInfo blackout_background
float blackout_alpha
bool active ends the intro immediately if set to false
bool skip_prologue skips prologue and goes straight to the title screen after the intro

ScreenLevel

Derived from Screen

Type Name Description
int buttons

Derived from Screen

Type Name Description
TextureRenderingInfo logo_mossmouth
TextureRenderingInfo logo_blitworks
TextureRenderingInfo logo_fmod
int state 0 - mossmouth, 1 - blitworks, 2 - fmod, 3 - end (next screen)
int timer

ScreenMenu

Derived from Screen

Type Name Description
int state 0: "cthulhu_pre_movement",
1: "cthulhu_rotating",
2: "cthulhu_separating",
3: "cthulhu_lowering",
4: "cthulhu_transition_to_menu",
5: "return_from_backlayer",
6: "highlight_selection",
7: "idle",
8: "to_submenu",
9: "to_backlayer",
10: "backlayer_idle"
TextureRenderingInfo tunnel_background
TextureRenderingInfo cthulhu_disc
TextureRenderingInfo tunnel_ring_darkbrown
TextureRenderingInfo cthulhu_body
TextureRenderingInfo tunnel_ring_lightbrown
TextureRenderingInfo vine_left
TextureRenderingInfo vine_right
TextureRenderingInfo skull_left
TextureRenderingInfo salamander_right
TextureRenderingInfo left_spear
TextureRenderingInfo right_spear
TextureRenderingInfo spear_dangler_related
TextureRenderingInfo play_scroll
TextureRenderingInfo info_toast
SoundMeta cthulhu_sound
ParticleEmitterInfo particle_smoke
ParticleEmitterInfo particle_rubble
float cthulhu_disc_ring_angle
float cthulhu_disc_split_progress
float cthulhu_disc_y
float cthulhu_timer
ScreenControls controls
int selected_menu_index
int sides_hold_down_timer
int sides_fast_scroll_timer
bool loop Allow going up from first to last option
int menu_id 0 = main menu, 1 = play, 2 = online
int transfer_to_menu_id
float menu_text_opacity
array<float, 6> spear_position
array<SpritePosition, 6> spear_dangler
array<int, 6> spear_dangle_momentum
array<int, 6> spear_dangle_angle
float play_scroll_descend_timer
STRINGID scroll_text
float shake_offset_x
float shake_offset_y
bool loaded_once Set to true when going from title to menu screen for the first time, makes sure the animation play once

ScreenOnlineLoading

Derived from Screen

Type Name Description
TextureRenderingInfo ouroboros
float ouroboros_angle

ScreenOnlineLobby

Derived from Screen

Type Name Description
MenuScreenPanels screen_panels
array<OnlineLobbyScreenPlayer, 4> players
TextureRenderingInfo background_image
TextureRenderingInfo topleft_woodpanel_esc
float topleft_woodpanel_esc_slidein
float character_walk_offset
bool character_facing_left
int move_direction
TextureRenderingInfo character
TextureRenderingInfo player_ready_icon
TextureRenderingInfo arrow_left
TextureRenderingInfo arrow_right
float arrow_left_hor_offset
float arrow_right_hor_offset
TextureRenderingInfo platform_icon
int player_count
bool searching_for_players
bool show_code_panel
ScreenEnterOnlineCode screen_code_input

ScreenOptions

Derived from Screen

Type Name Description
bool down
bool up
int direction_input -1 = none, 0 = down, 1 = up
int hold_down_timer
int fast_scroll_timer
int selected_menu_index
int sides_hold_down_timer
int sides_fast_scroll_timer
bool loop Allow going up from first to last option
MenuScreenPanels screen_panels
int menu_id
int transfer_to_menu_id
bool show_apply_button
TextureRenderingInfo topleft_woodpanel_esc
TextureRenderingInfo brick_background
TextureRenderingInfo brick_middlelayer
TextureRenderingInfo brick_foreground
TextureRenderingInfo selected_item_rounded_rect
TextureRenderingInfo selected_item_scarab
TextureRenderingInfo item_option_arrow_left
TextureRenderingInfo item_option_arrow_right
TextureRenderingInfo tooltip_background
TextureRenderingInfo progressbar_background
TextureRenderingInfo volume_progressbar_foreground
TextureRenderingInfo progressbar_foreground
TextureRenderingInfo volume_progressbar_position_indicator
TextureRenderingInfo sectionheader_background
TextureRenderingInfo pet_icons In "Gameplay" menu
TextureRenderingInfo bottom_scroll For the code in the sync menu
TextureRenderingInfo bottom_left_scrollhandle
TextureRenderingInfo bottom_right_scrollhandle
float topleft_woodpanel_esc_slidein
float text_fadein
float vertical_scroll_effect
bool options_visiable
bool show_highlight Shows the red background behind the option, the scarab on the left and left/right arrows
vector<STRINGID> tooltip_text
bool disable_controls Used for sync progress
int sync_progress_state 0 - none, 1 - waiting for the code, 2 - code acquired, 3 - sync in progress, 4 - sync completed
float credits_progression

ScreenPrologue

Derived from Screen

Type Name Description
STRINGID line1
STRINGID line2
STRINGID line3
float line1_alpha
float line2_alpha
float line3_alpha

ScreenRecap

Derived from Screen

Type Name Description

ScreenScores

Derived from Screen

Type Name Description
int animation_state
TextureRenderingInfo woodpanel1
TextureRenderingInfo woodpanel2
TextureRenderingInfo woodpanel3
TextureRenderingInfo woodpanel_cutout
TextureRenderingInfo dollarsign
TextureRenderingInfo hourglass
int animation_timer
float woodpanel_slidedown_timer

ScreenStateCamp

Derived from Screen

Type Name Description
int time_till_reset Delay after player death to reset camp

ScreenStateLevel

Derived from Screen

Type Name Description
int buttons
int time_till_death_screen Delay after player death to open the death screen

ScreenTeamSelect

Derived from Screen

Type Name Description
TextureRenderingInfo player_portrait
TextureRenderingInfo scroll_bottom_left
TextureRenderingInfo scrollend_bottom_left
TextureRenderingInfo four_ropes
TextureRenderingInfo gems_above_the_ropes
TextureRenderingInfo four_characters
TextureRenderingInfo left_arrow
TextureRenderingInfo right_arrow
TextureRenderingInfo start_panel
TextureRenderingInfo go_back_wooden_panel
float start_panel_slide
float go_back_wooden_panel_slide
float pulsating_arrows_timer
int selected_player
int buttons
bool ready

ScreenTitle

Derived from Screen

Type Name Description
TextureRenderingInfo logo_spelunky2
TextureRenderingInfo ana
TextureRenderingInfo ana_right_eyeball_torch_reflection
TextureRenderingInfo ana_left_eyeball_torch_reflection
ParticleEmitterInfo particle_torchflame_smoke
ParticleEmitterInfo particle_torchflame_backflames
ParticleEmitterInfo particle_torchflame_flames
ParticleEmitterInfo particle_torchflame_backflames_animated
ParticleEmitterInfo particle_torchflame_flames_animated
ParticleEmitterInfo particle_torchflame_ash
float brightness
SoundMeta music
SoundMeta torch_sound

ScreenTransition

Derived from Screen

Type Name Description
float woodpanel_pos
float stats_scroll_horizontal_posaa
float stats_scroll_vertical_pos
float level_completed_pos
float stats_scroll_unfurl_actualvalue
float stats_scroll_unfurl_targetvalue
TextureRenderingInfo woodpanel1
TextureRenderingInfo woodpanel2
TextureRenderingInfo woodpanel3
TextureRenderingInfo woodpanel_cutout1
TextureRenderingInfo woodpanel_cutout2
TextureRenderingInfo woodpanel_cutout3
TextureRenderingInfo woodplank
TextureRenderingInfo woodpanel_bottomcutout1
TextureRenderingInfo woodpanel_bottomcutout2
TextureRenderingInfo woodpanel_bottomcutout3
TextureRenderingInfo scroll
TextureRenderingInfo stats_scroll_top_bottom
TextureRenderingInfo killcount_rounded_rect
TextureRenderingInfo level_completed_panel
int stats_scroll_state_1
int stats_scroll_state_2
bool hide_press_to_go_next_level
TextureRenderingInfo mama_tunnel
TextureRenderingInfo speechbubble
TextureRenderingInfo speechbubble_arrow
float mama_tunnel_fade_targetvalue
float mama_tunnel_fade_targetvalue
STRINGID mama_tunnel_text_id
bool mama_tunnel_choice_visible
bool mama_tunnel_agree_with_gift
bool mama_tunnel_face_invisible
float mama_tunnel_face_transparency
TextureRenderingInfo mama_tunnel_agree_panel
TextureRenderingInfo mama_tunnel_agree_panel_indicator
TextureRenderingInfo woodpanel_cutout_big_money1
TextureRenderingInfo woodpanel_cutout_big_money2
TextureRenderingInfo woodpanel_cutout_big_money3
TextureRenderingInfo big_dollar_sign
int stats_scroll_unfurl_sequence
array<int, MAX_PLAYERS> player_stats_scroll_numeric_value
array<TextureRenderingInfo, MAX_PLAYERS> player_secondary_icon
array<TextureRenderingInfo, MAX_PLAYERS> player_icon
array<int, MAX_PLAYERS> player_secondary_icon_type
array<int, MAX_PLAYERS> player_icon_index
TextureRenderingInfo hourglasses
TextureRenderingInfo small_dollar_signs
Color this_level_money_color
array<int, MAX_PLAYERS> buttons

ScreenWin

Derived from Screen

Type Name Description
int sequence_timer
int frame_timer
int animation_state
Entity rescuing_ship_entity

Sound types

BackgroundSound

Derived from SoundMeta

Type Name Description

CustomSound

Handle to a loaded sound, can be used to play the sound and receive a PlayingSound for more control It is up to you to not release this as long as any sounds returned by CustomSound:play() are still playing

Type Name Description
PlayingSound play()
PlayingSound play(bool paused)
PlayingSound play(bool paused, SOUND_TYPE sound_type)
map<VANILLA_SOUND_PARAM, string> get_parameters()

PlayingSound

Handle to a playing sound, start the sound paused to make sure you can apply changes before playing it You can just discard this handle if you do not need extended control anymore

Type Name Description
bool is_playing()
bool stop()
bool set_pause(bool pause)
bool set_mute(bool mute)
bool set_pitch(float pitch)
bool set_pan(float pan)
bool set_volume(float volume)
bool set_looping(SOUND_LOOP_MODE loop_mode)
bool set_callback(function callback)
map<VANILLA_SOUND_PARAM, string> get_parameters()
optional<float> get_parameter(VANILLA_SOUND_PARAM parameter_index)
bool set_parameter(VANILLA_SOUND_PARAM parameter_index, float value)

SoundMeta

Type Name Description
float x
float y
array<float, 38> left_channel Use VANILLA_SOUND_PARAM as index, warning: special case with first index at 0, loop using pairs will get you all results but the key/index will be wrong, ipairs will have correct key/index but will skip the first element
array<float, 38> right_channel Use VANILLA_SOUND_PARAM as index warning: special case with first index at 0, loop using pairs will get you all results but the key/index will be wrong, ipairs will have correct key/index but will skip the first element
bool start_over when false, current track starts from the beginning, is immediately set back to true
bool playing set to false to turn off

State types

Camera

Type Name Description
float bounds_left
float bounds_right
float bounds_bottom
float bounds_top
float calculated_focus_x
float calculated_focus_y
float adjusted_focus_x
float adjusted_focus_y
float focus_offset_x
float focus_offset_y
float focus_x
float focus_y
float vertical_pan
int shake_countdown_start
int shake_countdown
float shake_amplitude
float shake_multiplier_x
float shake_multiplier_y
bool uniform_shake
int focused_entity_uid if set to -1, you have free control over camera focus through focus_x, focus_y
float inertia This is a bad name, but it represents the camera tweening speed. [0..5] where 0=still, 1=default (move 20% of distance per frame), 5=max (move 5*20% or 100% aka instantly to destination per frame)
int peek_timer amount of frames to freeze camera in place and move to the peek_layer
during the peek you can freely set camera position no matter if focused_entity_uid is set to -1 or not
int peek_layer
AABB get_bounds()
nil set_bounds(AABB bounds)

GameManager

Can be accessed via global game_manager

Type Name Description
BackgroundMusic music
GameProps game_props
ScreenLogo screen_logo
ScreenIntro screen_intro
ScreenPrologue screen_prologue
ScreenTitle screen_title
ScreenMenu screen_menu
ScreenOptions screen_options
Screen screen_player_profile It just opens journal
Screen screen_leaderboards All handled by the Online
ScreenCodeInput screen_seed_input
ScreenCamp screen_camp
ScreenLevel screen_level
Screen screen_transition
Screen screen_arena_level
Screen screen_arena_score
ScreenOnlineLoading screen_online_loading
ScreenOnlineLobby screen_online_lobby
PauseUI pause_ui
JournalUI journal_ui
SaveRelated save_related
BackgroundSound main_menu_music
array<int, MAX_PLAYERS> buttons_controls Yet another place to get player inputs, in some format
array<int, MAX_PLAYERS> buttons_movement Yet another place to get player inputs, in some format

GameProps

Type Name Description
array<int, MAX_PLAYERS> input Used for player input and might be used for some menu inputs not found in buttons_menu. You can probably capture and edit this in ON.POST_PROCESS_INPUT. These are raw inputs, without things like autorun applied.
array<int, MAX_PLAYERS> input_previous
MENU_INPUT input_menu Inputs used to control all the menus, separate from player inputs. You can probably capture and edit this in ON.POST_PROCESS_INPUT
MENU_INPUT input_menu_previous Previous state of buttons_menu
bool game_has_focus
bool menu_open
array<int, 5> input_index Input index for players 1-4 and maybe for the menu controls. -1: disabled, 0..3: keyboards, 4..7: Xinput, 8..11: other controllers

Items

Used in StateMemory

Type Name Description
int player_count
int saved_pets_count Only for the level transition, the actual number is held in player inventory
array<ENT_TYPE, 4> saved_pets Pet information for level transition
array<bool, 4> is_pet_cursed
array<bool, 4> is_pet_poisoned
int leader Index of leader player in coop
array<SelectPlayerSlot, MAX_PLAYERS> player_select
array<Inventory, MAX_PLAYERS> player_inventory
array<Player, MAX_PLAYERS> players Table of players, also keeps the dead body until they are destroyed (necromancer revive also destroys the old body)

JournalProgressStainSlot

Used in StateMemory

Type Name Description
float x
float y
float angle
float scale
int texture_column
int texture_row
int texture_range

JournalProgressStickerSlot

Used in StateMemory

Type Name Description
int theme
int grid_position
ENT_TYPE entity_type
float x
float y
float angle

PlayerSlot

Type Name Description
INPUTS buttons_gameplay
INPUTS buttons
InputMapping input_mapping_keyboard
InputMapping input_mapping_controller
int player_slot
bool is_participating

PlayerSlotSettings

Type Name Description
bool controller_vibration
bool auto_run_enabled
bool controller_right_stick

QuestsInfo

Type Name Description
int yang_state
int jungle_sisters_flags
int van_horsing_state
int sparrow_state
int madame_tusk_state
int beg_state

SelectPlayerSlot

Used in Items

Type Name Description
bool activated
ENT_TYPE character
TEXTURE texture

StateMemory

Can be accessed via global state

Type Name Description
SCREEN screen_last Previous SCREEN, used to check where we're coming from when loading another SCREEN
SCREEN screen Current SCREEN, generally read-only or weird things will happen
SCREEN screen_next 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.
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.
int width level width in rooms (number of rooms horizontally)
int height level height in rooms (number of rooms vertically)
int kali_favor
int kali_status
int kali_altars_destroyed Also affects if the player has punish ball, if the punish ball is destroyed it is set to -1
int kali_gifts 0 - none, 1 - item, 3 - kapala
int seed Current seed in seeded mode, just set to a funny value and does nothing in adventure mode
int time_total Total frames of current run, equal to the final game time on win
int world Current world number, shown in hud and used by some game logic like choosing the next level on transition
int world_next Next world number, used when loading a new level or transition
int world_start World number to start new runs in
int level Current level number, shown in hud and used by some game logic like choosing the next level on transition
int level_next Next level number, used when loading a new level or transition
int level_start Level number to start new runs in
THEME theme Current THEME number, used to pick the music and by some game logic like choosing the next level on transition
THEME theme_next Next THEME number, used when loading a new level or transition
THEME theme_start THEME to start new runs in
ThemeInfo current_theme Points to the current ThemeInfo
nil force_current_theme(THEME t) This function should only be used in a very specific circumstance (forcing the exiting theme when manually transitioning). Will crash the game if used inappropriately!
int shoppie_aggro Current shoppie aggro
int shoppie_aggro_next Shoppie aggro to use in the next level
int outposts_spawned
int merchant_aggro Tun aggro
int kills_npc
int level_count Current zero-based level count, or number of levels completed
int damage_taken Total amount of damage taken, excluding cause of death
JOURNAL_FLAG journal_flags
int time_last_level Level time of previous level in frames, used by game logic to decide dark levels etc
int time_level Level time of current level in frames, show on the hud
int level_flags
QUEST_FLAG quest_flags 32bit flags, can be written to trigger a run reset on next level load etc.
PRESENCE_FLAG presence_flags
FADE loading Current loading/fade state. Pauses all updates if > FADE.NONE. Writing FADE.OUT or FADE.LOAD will trigger a screen load to screen_next.
float fade_value Current fade-to-black amount (0.0 = all visible; 1.0 = all black). Manipulated by the loading routine when loading > 0.
int fade_timer Remaining frames for fade-in/fade-out when loading. Counts down to 0.
int fade_length Total frames for fade-in/fade-out when loading.
int fade_delay 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.
bool fade_enabled Enables the fade effect on FADE.IN, setting to false makes loading skip FADE.IN state instantly
bool fade_circle Makes loading use circle iris effect instead of fade on FADE.IN
int saved_dogs Run totals
int saved_cats
int saved_hamsters
int win_state 0 = no win 1 = tiamat win 2 = hundun win 3 = CO win; set this and next doorway leads to victory scene
Illumination illumination The global level illumination, very big and bright.
int money_last_levels
int money_shop_total 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
PlayerInputs player_inputs Access the player inputs even when no player entities are available
QuestsInfo quests NPC quest states
Camera camera Camera bounds and position
int special_visibility_flags
CAUSE_OF_DEATH cause_of_death
ENT_TYPE cause_of_death_entity_type
int toast_timer
int speechbubble_timer
int speechbubble_owner
LevelGenSystem level_gen Entrance and exit coordinates, shop types and all themes
int correct_ushabti See get_correct_ushabti. == anim_frame - (2 * floor(anim_frame/12))
Items items Has the current player count, player inventories and character selections
int camera_layer
int layer_transition_timer
int transition_to_layer
ScreenCharacterSelect screen_character_select
ScreenTeamSelect screen_team_select For the arena
ScreenStateCamp screen_camp
ScreenStateLevel screen_level
ScreenTransition screen_transition
ScreenDeath screen_death
ScreenWin screen_win
ScreenCredits screen_credits The spaceship minigame
ScreenScores screen_scores Landing on the moon after win
ScreenConstellation screen_constellation
ScreenRecap screen_recap Journal after CO win
ScreenArenaStagesSelect screen_arena_stages_select
ScreenArenaIntro screen_arena_intro
ScreenArenaLevel screen_arena_level
ScreenArenaScore screen_arena_score
ScreenArenaMenu screen_arena_menu
ScreenArenaItems screen_arena_items
int get_correct_ushabti() Returns animation_frame of the correct ushabti
nil set_correct_ushabti(int animation_frame)
ArenaState arena
ENT_TYPE speedrun_character Who administers the tutorial speedrun in base camp
bool speedrun_activation_trigger must transition from true to false to activate it
ENT_TYPE end_spaceship_character Who pops out the spaceship for a tiamat/hundun win, this is set upon the spaceship door open
bool world2_coffin_spawned
bool world4_coffin_spawned
bool world6_coffin_spawned
ENT_TYPE first_damage_cause
int first_damage_world
int first_damage_level
int time_speedrun
ENT_TYPE coffin_contents the contents of the special coffin that will be spawned during levelgen
int screen_change_counter
int time_startup Number of frames since the game was launched
int storage_uid entity uid of the first floor_storage entity
array<ENT_TYPE, 99> waddler_storage
array<int, 99> waddler_metadata
int journal_progress_sticker_count
array<JournalProgressStickerSlot, 40> journal_progress_sticker_slots stickers for notable items and entities in journal progress page
int journal_progress_stain_count
array<JournalProgressStainSlot, 30> journal_progress_stain_slots blood splats and paw prints in journal progress page
int journal_progress_theme_count
array<THEME, 9> journal_progress_theme_slots visited themes in journal progress page
ThemeInfo theme_info Points to the current ThemeInfo
LogicList logic Level logic like dice game and cutscenes
LiquidPhysics liquid
int next_entity_uid Next entity spawned will have this uid
RoomOwnersInfo room_owners Holds info about owned rooms and items (shops, challenge rooms, vault etc.)

Texture types

TextRenderingInfo

Type Name Description
new TextRenderingInfo:new(string text, float scale_x, float scale_y, VANILLA_TEXT_ALIGNMENT alignment, VANILLA_FONT_STYLE fontstyle)
TextRenderingInfo:new(string text, float x, float y, float scale_x, float scale_y, VANILLA_TEXT_ALIGNMENT alignment, VANILLA_FONT_STYLE fontstyle)
Creates new TextRenderingInfo that can be used in VanillaRenderContext draw_text
For static text, it is better to use one object and call draw_text with it, instead of relaying on draw_text creating this object for you
float x
float y
int text_length You can also just use # operator on the whole TextRenderingInfo to get the text length
float width
float height
TEXTURE special_texture_id Used to draw buttons and stuff, default is -1 which uses the buttons texture
span<Letter> get_dest() Returns reference to the letter coordinates relative to the x,y position
span<Letter> get_source() Returns reference to the letter coordinates in the texture
tuple<float, float> text_size() {width, height}, is only updated when you set/change the text. This is equivalent to draw_text_size
nil rotate(float angle, optional px, optional py) Rotates the text around the pivot point (default 0), pivot is relative to the text position (x, y), use px and py to offset it
nil set_text(string text, float scale_x, float scale_y, VANILLA_TEXT_ALIGNMENT alignment, VANILLA_FONT_STYLE fontstyle) Changes the text, only position stays the same, everything else (like rotation) is reset or set according to the parameters
TEXTURE get_font()
bool set_font(TEXTURE id)

TextureDefinition

Use TextureDefinition.new() to get a new instance to this and pass it to define_texture. width and height always have to be the size of the image file. They should be divisible by tile_width and tile_height respectively. tile_width and tile_height define the size of a single tile, the image will automatically be divided into these tiles. Tiles are labeled in sequence starting at the top left, going right and down at the end of the image (you know, like sentences work in the English language). Use those numbers in Entity::animation_frame. sub_image_offset_x, sub_image_offset_y, sub_image_width and sub_image_height can be used if only a part of the image should be used. Leave them at zero to ignore this.

Type Name Description
string texture_path
int width
int height
int tile_width
int tile_height
int sub_image_offset_x
int sub_image_offset_y
int sub_image_width
int sub_image_height

TextureRenderingInfo

Type Name Description
new
float x
float y
float destination_bottom_left_x destination is relative to the x,y center point
float destination_bottom_left_y
float destination_bottom_right_x
float destination_bottom_right_y
float destination_top_left_x
float destination_top_left_y
float destination_top_right_x
float destination_top_right_y
nil set_destination(AABB bbox)
Quad dest_get_quad()
nil dest_set_quad(Quad quad)
float source_bottom_left_x
float source_bottom_left_y
float source_bottom_right_x
float source_bottom_right_y
float source_top_left_x
float source_top_left_y
float source_top_right_x
float source_top_right_y
Quad source_get_quad()
nil source_set_quad(Quad quad)

Theme types

CustomTheme

Very basic example how to use a CustomTheme in the procedural levels. Search the examples or check Eternal Flame of Gehenna for custom levels.

-- create a new theme based on dwelling
local my_theme = CustomTheme:new()
-- get some ember effects from volcana
my_theme:override(THEME_OVERRIDE.SPAWN_EFFECTS, THEME.VOLCANA)
-- change level size
my_theme:post(THEME_OVERRIDE.INIT_LEVEL, function()
    state.width = 5
    state.height = 15
end)
-- set floor textures to eggy
my_theme.textures[DYNAMIC_TEXTURE.FLOOR] = TEXTURE.DATA_TEXTURES_FLOOR_EGGPLANT_0
set_callback(function(ctx)
    -- use the level gen from ice caves
    ctx:override_level_files({"generic.lvl", "icecavesarea.lvl"})
    -- force our theme instead of the default
    force_custom_theme(my_theme)
end, ON.PRE_LOAD_LEVEL_FILES)

You can call theme functions from other themes, for example to make all growable tile codes work in your theme:

local custom = CustomTheme:new()
custom:post(THEME_OVERRIDE.SPAWN_LEVEL, function()
    state.level_gen.themes[THEME.VOLCANA]:spawn_traps()
    state.level_gen.themes[THEME.TIDE_POOL]:spawn_traps()
    state.level_gen.themes[THEME.JUNGLE]:spawn_traps()
end)

Customizable ThemeInfo with ability to override certain theming functions from different themes or write custom functions. Check ThemeInfo for some notes on the vanilla theme functions. Warning: We WILL change these function names, especially the unknown ones, when you figure out what they do. Derived from ThemeInfo

Type Name Description
CustomTheme new(int theme_id_, int base_theme_, bool defaults) Create a new theme with an id and base theme, overriding defaults. Check theme functions that are default enabled here.
CustomTheme new(int theme_id_, int base_theme_) Create a new theme with defaults.
CustomTheme new() Create a new theme with base dwelling and id 100.
string level_file Level file to load. Probably doesn't do much in custom themes, especially if you're forcing them in PRE_LOAD_LEVEL_FILES.
int theme Theme index. Probably shouldn't collide with the vanilla ones. Purpose unknown.
map<DYNAMIC_TEXTURE, TEXTURE> textures Add TEXTUREs here to override different dynamic textures.
nil override(THEME_OVERRIDE index, bool enabled_) To disable or enable theme functions using the base_theme.
nil override(THEME_OVERRIDE index, int theme_) To override a theme function with another theme.
nil override(THEME_OVERRIDE index, function func_) To override a theme function with a lua function.
nil pre(THEME_OVERRIDE index, function func_) Set a callback to be called before this theme function.
nil post(THEME_OVERRIDE index, function func_) Set a callback to be called after this theme function, to fix some changes it did for example.
int base_theme Base THEME to load enabled functions from, when no other theme is specified.
nil reset_theme_flags()
nil init_flags()
nil init_level()
nil init_rooms()
nil generate_path(bool reset)
nil add_special_rooms()
nil add_player_coffin()
nil add_dirk_coffin()
nil add_idol()
nil add_vault()
nil add_coffin()
nil add_special_feeling()
nil spawn_level()
nil spawn_border()
nil post_process_level()
nil spawn_traps()
nil post_process_entities()
nil spawn_procedural()
nil spawn_background()
nil spawn_lights()
nil spawn_transition()
nil post_transition()
nil spawn_players()
nil spawn_effects()
string get_level_file()
int get_theme_id()
int get_base_id()
int get_floor_spreading_type()
int get_floor_spreading_type2()
bool get_transition_styled_floor()
int get_transition_floor_modifier()
int get_transition_styled_floor_type()
int get_backwall_type()
int get_border_type()
int get_critter_type()
float get_liquid_gravity()
bool get_player_damage()
bool get_explosion_soot()
int get_backlayer_lut()
float get_backlayer_light_level()
bool get_loop()
int get_vault_level()
bool get_theme_flag(int index)
TEXTURE get_dynamic_texture(DYNAMIC_TEXTURE texture_id) Add TEXTURE s to textures map of the CustomTheme to override different dynamic textures easily.
nil pre_transition()
int get_exit_room_y_level()
int get_shop_chance()
nil spawn_decoration()
nil spawn_decoration2()
nil spawn_extra()
nil do_procedural_spawn(SpawnInfo info)

ThemeInfo

-- When hell freezes over: Examples for hooking ThemeInfo virtuals

state.level_gen.themes[THEME.VOLCANA]:set_pre_texture_dynamic(function(theme, id)
    -- change volcana floor to ice floor
    if id == DYNAMIC_TEXTURE.FLOOR then
        return TEXTURE.DATA_TEXTURES_FLOOR_ICE_0
    end
end)

state.level_gen.themes[THEME.VOLCANA]:set_pre_spawn_effects(function(theme)
    -- run the effects function from another theme to get cool ice particle effects
    for i=1,50 do
        state.level_gen.themes[THEME.ICE_CAVES]:spawn_effects()
    end
    -- then we run this to fix the weird camera bounds set by ice caves
    state.level_gen.themes[THEME.DWELLING]:spawn_effects()
    -- don't spawn volcanic effects
    return true
end)

-- make players cold
state.level_gen.themes[THEME.VOLCANA]:set_post_spawn_players(function(theme)
    for i,p in pairs(get_local_players()) do
        spawn_over(ENT_TYPE.LOGICAL_FROST_BREATH, p.uid, 0, 0)
    end
end)

-- make vlads bluish
state.level_gen.themes[THEME.VOLCANA]:set_pre_texture_backlayer_lut(function(theme)
    return TEXTURE.DATA_TEXTURES_LUT_ICECAVES_0
end)

Type Name Description
int unknown3
int unknown4
int theme
bool allow_beehive
bool allow_leprechaun
ThemeInfo sub_theme
nil reset_theme_flags() Sets the beehive and leprechaun flags
nil init_flags() Initializes some flags in the LevelGenSystem, also dark level flag in state.level_flags.
nil init_level() Adds the entrance room and sets spawn_room_x/y. Sets the level size and toast for echoes feeling. Sets some other level_flags, shop related flags and shop_type.
nil init_rooms()
nil generate_path(bool reset) Generates and adds the path rooms and exit room
Params: reset to start over from the beginning if other rooms didn't fit
nil add_special_rooms() Adds rooms related to udjat, black market, castle etc
nil add_player_coffin() Adds a player revival coffin room
nil add_dirk_coffin() Adds a Dirk coffin room
nil add_idol() Adds an idol room
nil add_vault() Adds a vault room
nil add_coffin() Adds a character unlock coffin room
nil add_special_feeling() Adds the metal clanking or oppression rooms
nil spawn_level() Calls many other theme functions to spawn the floor, enemies, items etc, but not background and players. (Disable this to only spawn background and players.)
nil spawn_border() Spawns the border entities (some floor or teleportingborder)
nil post_process_level() Theme specific specialties like randomizing ushabti and Coco coffin location, spawns impostor lakes
nil spawn_traps() Spawns theme specific random traps, pushblocks and critters. Sets special exit doors.
nil post_process_entities() Fixes textures on pleasure palace ladders, adds some decorations
nil spawn_procedural() Adds legs under platforms, random pots, goldbars, monsters, compass indicator, random shadows...
nil spawn_background() Adds the main level background , e.g. CO stars / Duat moon / Plain backwall for other themes
nil spawn_lights() Adds room lights to udjat chest room or black market
nil spawn_transition() Spawns the transition tunnel and players in it
nil post_transition() Handles loading the next level screen from a transition screen
nil spawn_players() Spawns the players with inventory at state.level_gen.spawn_x/y. Also shop and kali background and probably other stuff for some stupid reason.
nil spawn_effects() Sets the camera bounds and position. Spawns jelly and orbs and the flag in coop. Sets timers/conditions for more jellies and ghosts. Enables the special fog/ember/ice etc particle effects.
string get_level_file() Returns: The .lvl file to load (e.g. dwelling = dwellingarea.lvl except when level == 4 (cavebossarea.lvl))
int get_theme_id() Returns: THEME, or subtheme in CO
int get_base_id() Returns: THEME, or logical base THEME for special levels (Abzu->Tide Pool etc)
ENT_TYPE get_floor_spreading_type() Returns: ENT_TYPE used for floor spreading (generic or one of the styled floors)
ENT_TYPE get_floor_spreading_type2() Returns: ENT_TYPE used for floor spreading (stone or one of the styled floors)
bool get_transition_styled_floor() Returns: true if transition should use styled floor
int get_transition_floor_modifier() Determines the types of FLOOR_TUNNEL_NEXT/CURRENT (depending on where you are transitioning from/to)
Returns: 85 by default, except for: olmec: 15, cog: 23
ENT_TYPE get_transition_styled_floor_type() Returns: ENT_TYPE used for the transition floor
ENT_TYPE get_backwall_type() Returns: ENT_TYPE used for the backwall (BG_LEVEL_BACKWALL by default)
ENT_TYPE get_border_type() Returns: ENT_TYPE to use for the border tiles
ENT_TYPE get_critter_type() Returns: ENT_TYPE for theme specific critter
float get_liquid_gravity() Returns: gravity used to initialize liquid pools (-1..1)
bool get_player_damage() Returns: false to disable most player damage and the usage of bombs and ropes. Enabled in parts of base camp.
bool get_explosion_soot() Returns: true if explosions should spawn background soot
int get_backlayer_lut() Returns: TEXTURE for the LUT to be applied to the special back layer, e.g. vlad's castle
float get_backlayer_light_level() Returns: dynamic backlayer light level (0..1)
bool get_loop() Returns: true if the loop rendering should be enabled (Combine with the right get_border_type)
int get_vault_level() Returns: highest y-level a vault can spawn
bool get_theme_flag(int index) Returns: allow_beehive or allow_leprechaun flag
Params: index: 0 or 1
TEXTURE get_dynamic_texture(DYNAMIC_TEXTURE texture_id) Returns: TEXTURE based on texture_id
Params: DYNAMIC_TEXTURE texture_id
nil pre_transition() Sets state.level_next, world_next and theme_next (or state.win_state) based on level number. Runs when exiting a level.
int get_exit_room_y_level() Returns: usually state.height - 1. For special levels fixed heights are returned.
int get_shop_chance() Returns: inverse shop chance
nil spawn_decoration() Spawns some specific decoration, e.g. Vlad's big banner
nil spawn_decoration2() Spawns some other specific decorations, e.g. grass, flowers, udjat room decal
nil spawn_extra() Spawns specific extra entities and decorations, like gold key, seaweed, lanterns, banners, signs, wires...
nil do_procedural_spawn(SpawnInfo info) Spawns a single procedural entity, used in spawn_procedural (mostly monsters, scarab in dark levels etc.)
CallbackId set_pre_virtual(THEME_OVERRIDE entry, function fun) Hooks before the virtual function at index entry.
CallbackId set_post_virtual(THEME_OVERRIDE entry, function fun) Hooks after the virtual function at index entry.
nil clear_virtual(CallbackId callback_id) Clears the hook given by callback_id, alternatively use clear_callback() inside the hook.
CallbackId set_pre_dtor(function fun) Hooks before the virtual function.
The callback signature is nil dtor(ThemeInfo self)
CallbackId set_post_dtor(function fun) Hooks after the virtual function.
The callback signature is nil dtor(ThemeInfo self)
CallbackId set_pre_reset_theme_flags(function fun) Hooks before the virtual function.
The callback signature is bool reset_theme_flags(ThemeInfo self)
Virtual function docs:
Sets the beehive and leprechaun flags
CallbackId set_post_reset_theme_flags(function fun) Hooks after the virtual function.
The callback signature is nil reset_theme_flags(ThemeInfo self)
Virtual function docs:
Sets the beehive and leprechaun flags
CallbackId set_pre_init_flags(function fun) Hooks before the virtual function.
The callback signature is bool init_flags(ThemeInfo self)
Virtual function docs:
Initializes some flags in the LevelGenSystem, also dark level flag in state.level_flags.
CallbackId set_post_init_flags(function fun) Hooks after the virtual function.
The callback signature is nil init_flags(ThemeInfo self)
Virtual function docs:
Initializes some flags in the LevelGenSystem, also dark level flag in state.level_flags.
CallbackId set_pre_init_level(function fun) Hooks before the virtual function.
The callback signature is bool init_level(ThemeInfo self)
Virtual function docs:
Adds the entrance room and sets spawn_room_x/y. Sets the level size and toast for echoes feeling. Sets some other level_flags, shop related flags and shop_type.
CallbackId set_post_init_level(function fun) Hooks after the virtual function.
The callback signature is nil init_level(ThemeInfo self)
Virtual function docs:
Adds the entrance room and sets spawn_room_x/y. Sets the level size and toast for echoes feeling. Sets some other level_flags, shop related flags and shop_type.
CallbackId set_pre_init_rooms(function fun) Hooks before the virtual function.
The callback signature is bool init_rooms(ThemeInfo self)
CallbackId set_post_init_rooms(function fun) Hooks after the virtual function.
The callback signature is nil init_rooms(ThemeInfo self)
CallbackId set_pre_generate_path(function fun) Hooks before the virtual function.
The callback signature is bool generate_path(ThemeInfo self, bool reset)
Virtual function docs:
Generates and adds the path rooms and exit room
Params: reset to start over from the beginning if other rooms didn't fit
CallbackId set_post_generate_path(function fun) Hooks after the virtual function.
The callback signature is nil generate_path(ThemeInfo self, bool reset)
Virtual function docs:
Generates and adds the path rooms and exit room
Params: reset to start over from the beginning if other rooms didn't fit
CallbackId set_pre_special_rooms(function fun) Hooks before the virtual function.
The callback signature is bool special_rooms(ThemeInfo self)
CallbackId set_post_special_rooms(function fun) Hooks after the virtual function.
The callback signature is nil special_rooms(ThemeInfo self)
CallbackId set_pre_player_coffin(function fun) Hooks before the virtual function.
The callback signature is bool player_coffin(ThemeInfo self)
CallbackId set_post_player_coffin(function fun) Hooks after the virtual function.
The callback signature is nil player_coffin(ThemeInfo self)
CallbackId set_pre_dirk_coffin(function fun) Hooks before the virtual function.
The callback signature is bool dirk_coffin(ThemeInfo self)
CallbackId set_post_dirk_coffin(function fun) Hooks after the virtual function.
The callback signature is nil dirk_coffin(ThemeInfo self)
CallbackId set_pre_idol(function fun) Hooks before the virtual function.
The callback signature is bool idol(ThemeInfo self)
CallbackId set_post_idol(function fun) Hooks after the virtual function.
The callback signature is nil idol(ThemeInfo self)
CallbackId set_pre_vault(function fun) Hooks before the virtual function.
The callback signature is bool vault(ThemeInfo self)
CallbackId set_post_vault(function fun) Hooks after the virtual function.
The callback signature is nil vault(ThemeInfo self)
CallbackId set_pre_coffin(function fun) Hooks before the virtual function.
The callback signature is bool coffin(ThemeInfo self)
CallbackId set_post_coffin(function fun) Hooks after the virtual function.
The callback signature is nil coffin(ThemeInfo self)
CallbackId set_pre_feeling(function fun) Hooks before the virtual function.
The callback signature is bool feeling(ThemeInfo self)
CallbackId set_post_feeling(function fun) Hooks after the virtual function.
The callback signature is nil feeling(ThemeInfo self)
CallbackId set_pre_spawn_level(function fun) Hooks before the virtual function.
The callback signature is bool spawn_level(ThemeInfo self)
Virtual function docs:
Calls many other theme functions to spawn the floor, enemies, items etc, but not background and players. (Disable this to only spawn background and players.)
CallbackId set_post_spawn_level(function fun) Hooks after the virtual function.
The callback signature is nil spawn_level(ThemeInfo self)
Virtual function docs:
Calls many other theme functions to spawn the floor, enemies, items etc, but not background and players. (Disable this to only spawn background and players.)
CallbackId set_pre_spawn_border(function fun) Hooks before the virtual function.
The callback signature is bool spawn_border(ThemeInfo self)
Virtual function docs:
Spawns the border entities (some floor or teleportingborder)
CallbackId set_post_spawn_border(function fun) Hooks after the virtual function.
The callback signature is nil spawn_border(ThemeInfo self)
Virtual function docs:
Spawns the border entities (some floor or teleportingborder)
CallbackId set_pre_post_process_level(function fun) Hooks before the virtual function.
The callback signature is bool post_process_level(ThemeInfo self)
Virtual function docs:
Theme specific specialties like randomizing ushabti and Coco coffin location, spawns impostor lakes
CallbackId set_post_post_process_level(function fun) Hooks after the virtual function.
The callback signature is nil post_process_level(ThemeInfo self)
Virtual function docs:
Theme specific specialties like randomizing ushabti and Coco coffin location, spawns impostor lakes
CallbackId set_pre_spawn_traps(function fun) Hooks before the virtual function.
The callback signature is bool spawn_traps(ThemeInfo self)
Virtual function docs:
Spawns theme specific random traps, pushblocks and critters. Sets special exit doors.
CallbackId set_post_spawn_traps(function fun) Hooks after the virtual function.
The callback signature is nil spawn_traps(ThemeInfo self)
Virtual function docs:
Spawns theme specific random traps, pushblocks and critters. Sets special exit doors.
CallbackId set_pre_post_process_entities(function fun) Hooks before the virtual function.
The callback signature is bool post_process_entities(ThemeInfo self)
Virtual function docs:
Fixes textures on pleasure palace ladders, adds some decorations
CallbackId set_post_post_process_entities(function fun) Hooks after the virtual function.
The callback signature is nil post_process_entities(ThemeInfo self)
Virtual function docs:
Fixes textures on pleasure palace ladders, adds some decorations
CallbackId set_pre_spawn_procedural(function fun) Hooks before the virtual function.
The callback signature is bool spawn_procedural(ThemeInfo self)
Virtual function docs:
Adds legs under platforms, random pots, goldbars, monsters, compass indicator, random shadows...
CallbackId set_post_spawn_procedural(function fun) Hooks after the virtual function.
The callback signature is nil spawn_procedural(ThemeInfo self)
Virtual function docs:
Adds legs under platforms, random pots, goldbars, monsters, compass indicator, random shadows...
CallbackId set_pre_spawn_background(function fun) Hooks before the virtual function.
The callback signature is bool spawn_background(ThemeInfo self)
Virtual function docs:
Adds the main level background , e.g. CO stars / Duat moon / Plain backwall for other themes
CallbackId set_post_spawn_background(function fun) Hooks after the virtual function.
The callback signature is nil spawn_background(ThemeInfo self)
Virtual function docs:
Adds the main level background , e.g. CO stars / Duat moon / Plain backwall for other themes
CallbackId set_pre_spawn_lights(function fun) Hooks before the virtual function.
The callback signature is bool spawn_lights(ThemeInfo self)
Virtual function docs:
Adds room lights to udjat chest room or black market
CallbackId set_post_spawn_lights(function fun) Hooks after the virtual function.
The callback signature is nil spawn_lights(ThemeInfo self)
Virtual function docs:
Adds room lights to udjat chest room or black market
CallbackId set_pre_spawn_transition(function fun) Hooks before the virtual function.
The callback signature is bool spawn_transition(ThemeInfo self)
Virtual function docs:
Spawns the transition tunnel and players in it
CallbackId set_post_spawn_transition(function fun) Hooks after the virtual function.
The callback signature is nil spawn_transition(ThemeInfo self)
Virtual function docs:
Spawns the transition tunnel and players in it
CallbackId set_pre_post_transition(function fun) Hooks before the virtual function.
The callback signature is bool post_transition(ThemeInfo self)
Virtual function docs:
Handles loading the next level screen from a transition screen
CallbackId set_post_post_transition(function fun) Hooks after the virtual function.
The callback signature is nil post_transition(ThemeInfo self)
Virtual function docs:
Handles loading the next level screen from a transition screen
CallbackId set_pre_spawn_players(function fun) Hooks before the virtual function.
The callback signature is bool spawn_players(ThemeInfo self)
Virtual function docs:
Spawns the players with inventory at state.level_gen.spawn_x/y. Also shop and kali background and probably other stuff for some stupid reason.
CallbackId set_post_spawn_players(function fun) Hooks after the virtual function.
The callback signature is nil spawn_players(ThemeInfo self)
Virtual function docs:
Spawns the players with inventory at state.level_gen.spawn_x/y. Also shop and kali background and probably other stuff for some stupid reason.
CallbackId set_pre_spawn_effects(function fun) Hooks before the virtual function.
The callback signature is bool spawn_effects(ThemeInfo self)
Virtual function docs:
Sets the camera bounds and position. Spawns jelly and orbs and the flag in coop. Sets timers/conditions for more jellies and ghosts. Enables the special fog/ember/ice etc particle effects.
CallbackId set_post_spawn_effects(function fun) Hooks after the virtual function.
The callback signature is nil spawn_effects(ThemeInfo self)
Virtual function docs:
Sets the camera bounds and position. Spawns jelly and orbs and the flag in coop. Sets timers/conditions for more jellies and ghosts. Enables the special fog/ember/ice etc particle effects.
CallbackId set_pre_theme_id(function fun) Hooks before the virtual function.
The callback signature is optional<int> theme_id(ThemeInfo self)
CallbackId set_post_theme_id(function fun) Hooks after the virtual function.
The callback signature is nil theme_id(ThemeInfo self)
CallbackId set_pre_base_id(function fun) Hooks before the virtual function.
The callback signature is optional<int> base_id(ThemeInfo self)
CallbackId set_post_base_id(function fun) Hooks after the virtual function.
The callback signature is nil base_id(ThemeInfo self)
CallbackId set_pre_ent_floor_spreading(function fun) Hooks before the virtual function.
The callback signature is optional<int> ent_floor_spreading(ThemeInfo self)
CallbackId set_post_ent_floor_spreading(function fun) Hooks after the virtual function.
The callback signature is nil ent_floor_spreading(ThemeInfo self)
CallbackId set_pre_ent_floor_spreading2(function fun) Hooks before the virtual function.
The callback signature is optional<int> ent_floor_spreading2(ThemeInfo self)
CallbackId set_post_ent_floor_spreading2(function fun) Hooks after the virtual function.
The callback signature is nil ent_floor_spreading2(ThemeInfo self)
CallbackId set_pre_transition_styled_floor(function fun) Hooks before the virtual function.
The callback signature is optional<bool> transition_styled_floor(ThemeInfo self)
CallbackId set_post_transition_styled_floor(function fun) Hooks after the virtual function.
The callback signature is nil transition_styled_floor(ThemeInfo self)
CallbackId set_pre_transition_modifier(function fun) Hooks before the virtual function.
The callback signature is optional<int> transition_modifier(ThemeInfo self)
CallbackId set_post_transition_modifier(function fun) Hooks after the virtual function.
The callback signature is nil transition_modifier(ThemeInfo self)
CallbackId set_pre_ent_transition_styled_floor(function fun) Hooks before the virtual function.
The callback signature is optional<int> ent_transition_styled_floor(ThemeInfo self)
CallbackId set_post_ent_transition_styled_floor(function fun) Hooks after the virtual function.
The callback signature is nil ent_transition_styled_floor(ThemeInfo self)
CallbackId set_pre_ent_backwall(function fun) Hooks before the virtual function.
The callback signature is optional<int> ent_backwall(ThemeInfo self)
CallbackId set_post_ent_backwall(function fun) Hooks after the virtual function.
The callback signature is nil ent_backwall(ThemeInfo self)
CallbackId set_pre_ent_border(function fun) Hooks before the virtual function.
The callback signature is optional<int> ent_border(ThemeInfo self)
CallbackId set_post_ent_border(function fun) Hooks after the virtual function.
The callback signature is nil ent_border(ThemeInfo self)
CallbackId set_pre_ent_critter(function fun) Hooks before the virtual function.
The callback signature is optional<int> ent_critter(ThemeInfo self)
CallbackId set_post_ent_critter(function fun) Hooks after the virtual function.
The callback signature is nil ent_critter(ThemeInfo self)
CallbackId set_pre_gravity(function fun) Hooks before the virtual function.
The callback signature is optional<float> gravity(ThemeInfo self)
CallbackId set_post_gravity(function fun) Hooks after the virtual function.
The callback signature is nil gravity(ThemeInfo self)
CallbackId set_pre_player_damage(function fun) Hooks before the virtual function.
The callback signature is optional<bool> player_damage(ThemeInfo self)
CallbackId set_post_player_damage(function fun) Hooks after the virtual function.
The callback signature is nil player_damage(ThemeInfo self)
CallbackId set_pre_soot(function fun) Hooks before the virtual function.
The callback signature is optional<bool> soot(ThemeInfo self)
CallbackId set_post_soot(function fun) Hooks after the virtual function.
The callback signature is nil soot(ThemeInfo self)
CallbackId set_pre_texture_backlayer_lut(function fun) Hooks before the virtual function.
The callback signature is optional<int> texture_backlayer_lut(ThemeInfo self)
CallbackId set_post_texture_backlayer_lut(function fun) Hooks after the virtual function.
The callback signature is nil texture_backlayer_lut(ThemeInfo self)
CallbackId set_pre_backlayer_light_level(function fun) Hooks before the virtual function.
The callback signature is optional<float> backlayer_light_level(ThemeInfo self)
CallbackId set_post_backlayer_light_level(function fun) Hooks after the virtual function.
The callback signature is nil backlayer_light_level(ThemeInfo self)
CallbackId set_pre_loop(function fun) Hooks before the virtual function.
The callback signature is optional<bool> loop(ThemeInfo self)
CallbackId set_post_loop(function fun) Hooks after the virtual function.
The callback signature is nil loop(ThemeInfo self)
CallbackId set_pre_vault_level(function fun) Hooks before the virtual function.
The callback signature is optional<int> vault_level(ThemeInfo self)
CallbackId set_post_vault_level(function fun) Hooks after the virtual function.
The callback signature is nil vault_level(ThemeInfo self)
CallbackId set_pre_theme_flag(function fun) Hooks before the virtual function.
The callback signature is optional<bool> theme_flag(ThemeInfo self, int)
CallbackId set_post_theme_flag(function fun) Hooks after the virtual function.
The callback signature is nil theme_flag(ThemeInfo self, int)
CallbackId set_pre_texture_dynamic(function fun) Hooks before the virtual function.
The callback signature is optional<int> texture_dynamic(ThemeInfo self, int)
CallbackId set_post_texture_dynamic(function fun) Hooks after the virtual function.
The callback signature is nil texture_dynamic(ThemeInfo self, int)
CallbackId set_pre_pre_transition(function fun) Hooks before the virtual function.
The callback signature is bool pre_transition(ThemeInfo self)
Virtual function docs:
Sets state.level_next, world_next and theme_next (or state.win_state) based on level number. Runs when exiting a level.
CallbackId set_post_pre_transition(function fun) Hooks after the virtual function.
The callback signature is nil pre_transition(ThemeInfo self)
Virtual function docs:
Sets state.level_next, world_next and theme_next (or state.win_state) based on level number. Runs when exiting a level.
CallbackId set_pre_exit_room_y_level(function fun) Hooks before the virtual function.
The callback signature is optional<int> exit_room_y_level(ThemeInfo self)
CallbackId set_post_exit_room_y_level(function fun) Hooks after the virtual function.
The callback signature is nil exit_room_y_level(ThemeInfo self)
CallbackId set_pre_shop_chance(function fun) Hooks before the virtual function.
The callback signature is optional<int> shop_chance(ThemeInfo self)
CallbackId set_post_shop_chance(function fun) Hooks after the virtual function.
The callback signature is nil shop_chance(ThemeInfo self)
CallbackId set_pre_spawn_decoration(function fun) Hooks before the virtual function.
The callback signature is bool spawn_decoration(ThemeInfo self)
Virtual function docs:
Spawns some specific decoration, e.g. Vlad's big banner
CallbackId set_post_spawn_decoration(function fun) Hooks after the virtual function.
The callback signature is nil spawn_decoration(ThemeInfo self)
Virtual function docs:
Spawns some specific decoration, e.g. Vlad's big banner
CallbackId set_pre_spawn_decoration2(function fun) Hooks before the virtual function.
The callback signature is bool spawn_decoration2(ThemeInfo self)
Virtual function docs:
Spawns some other specific decorations, e.g. grass, flowers, udjat room decal
CallbackId set_post_spawn_decoration2(function fun) Hooks after the virtual function.
The callback signature is nil spawn_decoration2(ThemeInfo self)
Virtual function docs:
Spawns some other specific decorations, e.g. grass, flowers, udjat room decal
CallbackId set_pre_spawn_extra(function fun) Hooks before the virtual function.
The callback signature is bool spawn_extra(ThemeInfo self)
Virtual function docs:
Spawns specific extra entities and decorations, like gold key, seaweed, lanterns, banners, signs, wires...
CallbackId set_post_spawn_extra(function fun) Hooks after the virtual function.
The callback signature is nil spawn_extra(ThemeInfo self)
Virtual function docs:
Spawns specific extra entities and decorations, like gold key, seaweed, lanterns, banners, signs, wires...
CallbackId set_pre_do_procedural_spawn(function fun) Hooks before the virtual function.
The callback signature is bool do_procedural_spawn(ThemeInfo self, SpawnInfo info)
Virtual function docs:
Spawns a single procedural entity, used in spawn_procedural (mostly monsters, scarab in dark levels etc.)
CallbackId set_post_do_procedural_spawn(function fun) Hooks after the virtual function.
The callback signature is nil do_procedural_spawn(ThemeInfo self, SpawnInfo info)
Virtual function docs:
Spawns a single procedural entity, used in spawn_procedural (mostly monsters, scarab in dark levels etc.)

Entity types

Background entities

BGBackLayerDoor

Derived from Entity

Type Name Description
Illumination illumination1
Illumination illumination2

BGEggshipRoom

Derived from Entity

Type Name Description
SoundMeta sound
Entity fx_shell
Entity fx_door
Entity platform_left
Entity platform_middle
Entity platform_right
bool player_in

BGFloatingDebris

Derived from Entity BGSurfaceLayer

Type Name Description
float distance Distance it travels up and down from spawn position
float speed
float sine_angle

BGMovingStar

Derived from Entity BGSurfaceStar

Type Name Description
float falling_speed Can make it rise if set to negative

BGRelativeElement

Derived from Entity

Type Name Description
float relative_x
float relative_y

BGShootingStar

Derived from Entity BGRelativeElement

Type Name Description
float x_increment
float y_increment
int timer
int max_timer
float size Gets smaller as the timer gets close to the max_timer

BGShopEntrance

Derived from Entity

Type Name Description
bool on_entering

BGShopKeeperPrime

Derived from Entity

Type Name Description
float normal_y
float sine_pos
int bubbles_timer
bool bubble_spawn_trigger
int bubble_spawn_delay

BGSurfaceLayer

Derived from Entity BGRelativeElement

Type Name Description
float relative_offset_x
float relative_offset_y

BGSurfaceStar

Derived from Entity

Type Name Description
int blink_timer
float relative_x
float relative_y

BGTutorialSign

Derived from Entity

Type Name Description
bool is_shown

DestructibleBG

Derived from Entity

Type Name Description

Effect entities

BurningRopeEffect

Derived from Entity

Type Name Description
Illumination illumination
SoundMeta sound

CursedEffect

Derived from Entity

Type Name Description
ParticleEmitterInfo particle
SoundMeta sound

FrostBreathEffect

Derived from Entity

Type Name Description
int timer

OnFireEffect

Derived from Entity

Type Name Description
ParticleEmitterInfo particle_smoke
ParticleEmitterInfo particle_flame
Illumination illumination

PoisonedEffect

Derived from Entity

Type Name Description
ParticleEmitterInfo particle_burst
ParticleEmitterInfo particle_base
int burst_timer
bool burst_active If forced to false, it will not play the sound or spawn burst particles

WetEffect

Derived from Entity

Type Name Description
ParticleEmitterInfo particle

Floor entities

Altar

Derived from Entity Floor

Type Name Description
int timer for normal altar: counts from 0 to 20 then 0, then 1 then 0 and sacrifice happens

Arrowtrap

Derived from Entity Floor

Type Name Description
bool arrow_shot
nil rearm()
nil trigger(int who_uid) The uid must be movable entity for ownership transfers

BigSpearTrap

Derived from Entity Floor

Type Name Description
int spear_uid
bool left_part setting the left part to 0 or right part to 1 destroys the trap
nil trigger(int who_uid, bool left) The uid must be movable entity for ownership transfers, has to be called on the left part of the trap,

CityOfGoldDoor

Derived from Entity Floor Door ExitDoor DecoratedDoor

Type Name Description
bool unlocked

ConveyorBelt

Derived from Entity Floor TransferFloor

Type Name Description
int timer

DecoratedDoor

Derived from Entity Floor Door ExitDoor

Type Name Description
Entity special_bg

Door

--If you want the locked door to look like the closed exit door at Hundun

function close_hundun_door(door)
    door:unlock(false)
    for _, uid in pairs(get_entities_overlapping_grid(door.x, door.y, door.layer)) do
        ent = get_entity(uid)
        if ent.type.id == ENT_TYPE.BG_DOOR then
            ent:set_texture(TEXTURE.DATA_TEXTURES_DECO_EGGPLANT_0)
            return
        end
    end
end


Derived from Entity Floor

Type Name Description
int counter
Entity fx_button
int enter(Entity who) Returns the entity state / behavior id to set the entity to after the entering animation.
float light_level() Returns the darkest light level used to fade the entity when entering or exiting. 0 = black, 1 = no change
bool is_unlocked() Should we display the button prompt when collided by player. Will always return true for exits, layers and others that the game never locks, even if you lock it with unlock function
bool can_enter(Entity player) Can the door actually be entered by player. Overrides the button prompt too if false.
nil unlock(bool unlock) Lock/Unlock doors
CallbackId set_pre_virtual(ENTITY_OVERRIDE entry, function fun) Hooks before the virtual function at index entry.
CallbackId set_post_virtual(ENTITY_OVERRIDE entry, function fun) Hooks after the virtual function at index entry.
nil clear_virtual(CallbackId callback_id) Clears the hook given by callback_id, alternatively use clear_callback() inside the hook.
CallbackId set_pre_enter_attempt(function fun) Hooks before the virtual function.
The callback signature is optional<float> enter_attempt(Door self, Entity)
CallbackId set_post_enter_attempt(function fun) Hooks after the virtual function.
The callback signature is nil enter_attempt(Door self, Entity)
CallbackId set_pre_hide_hud(function fun) Hooks before the virtual function.
The callback signature is optional<float> hide_hud(Door self, Entity)
CallbackId set_post_hide_hud(function fun) Hooks after the virtual function.
The callback signature is nil hide_hud(Door self, Entity)
CallbackId set_pre_enter(function fun) Hooks before the virtual function.
The callback signature is optional<int> enter(Door self, Entity who)
Virtual function docs:
Returns the entity state / behavior id to set the entity to after the entering animation.
CallbackId set_post_enter(function fun) Hooks after the virtual function.
The callback signature is nil enter(Door self, Entity who)
Virtual function docs:
Returns the entity state / behavior id to set the entity to after the entering animation.
CallbackId set_pre_light_level(function fun) Hooks before the virtual function.
The callback signature is optional<float> light_level(Door self)
Virtual function docs:
Returns the darkest light level used to fade the entity when entering or exiting. 0 = black, 1 = no change
CallbackId set_post_light_level(function fun) Hooks after the virtual function.
The callback signature is nil light_level(Door self)
Virtual function docs:
Returns the darkest light level used to fade the entity when entering or exiting. 0 = black, 1 = no change
CallbackId set_pre_is_unlocked(function fun) Hooks before the virtual function.
The callback signature is optional<bool> is_unlocked(Door self)
Virtual function docs:
Should we display the button prompt when collided by player. Will always return true for exits, layers and others that the game never locks, even if you lock it with unlock function
CallbackId set_post_is_unlocked(function fun) Hooks after the virtual function.
The callback signature is nil is_unlocked(Door self)
Virtual function docs:
Should we display the button prompt when collided by player. Will always return true for exits, layers and others that the game never locks, even if you lock it with unlock function
CallbackId set_pre_can_enter(function fun) Hooks before the virtual function.
The callback signature is optional<bool> can_enter(Door self, Entity player)
Virtual function docs:
Can the door actually be entered by player. Overrides the button prompt too if false.
CallbackId set_post_can_enter(function fun) Hooks after the virtual function.
The callback signature is nil can_enter(Door self, Entity player)
Virtual function docs:
Can the door actually be entered by player. Overrides the button prompt too if false.

EggShipDoor

Derived from Entity Floor Door

Type Name Description
int timer

EggShipDoorS

Derived from Entity Floor Door EggShipDoor

Type Name Description
bool entered

ExitDoor

Derived from Entity Floor Door

Type Name Description
bool entered if true entering it does not load the transition
bool special_door use provided world/level/theme
int level
int timer
int world
int theme

Floor

Derived from Entity

Type Name Description
int deco_top
int deco_bottom
int deco_left
int deco_right
nil fix_border_tile_animation() Sets animation_frame of the floor for types FLOOR_BORDERTILE, FLOOR_BORDERTILE_METAL and FLOOR_BORDERTILE_OCTOPUS.
nil fix_decorations(bool fix_also_neighbors, bool fix_styled_floor) Used to add decoration to a floor entity after it was spawned outside of level gen, is not necessary when spawning during level gen.
Set fix_also_neighbors to true to fix the neighboring floor tile decorations on the border of the two tiles.
Set fix_styled_floor to true to fix decorations on FLOORSTYLED_* entities, those usually only have decorations when broken.
nil add_decoration(FLOOR_SIDE side) Explicitly add a decoration on the given side. Corner decorations only exist for FLOOR_BORDERTILE and FLOOR_BORDERTILE_OCTOPUS.
nil remove_decoration(FLOOR_SIDE side) Explicitly remove a decoration on the given side. Corner decorations only exist for FLOOR_BORDERTILE and FLOOR_BORDERTILE_OCTOPUS.
nil decorate_internal()
ENT_TYPE get_floor_type() Returns it's ENT_TYPE except for FLOOR_PEN (returns FLOORSTYLED_MINEWOOD) and FLOOR_QUICKSAND, FLOOR_TOMB, FLOOR_EMPRESS_GRAVE which return FLOOR_GENERIC
CallbackId set_pre_virtual(ENTITY_OVERRIDE entry, function fun) Hooks before the virtual function at index entry.
CallbackId set_post_virtual(ENTITY_OVERRIDE entry, function fun) Hooks after the virtual function at index entry.
nil clear_virtual(CallbackId callback_id) Clears the hook given by callback_id, alternatively use clear_callback() inside the hook.
CallbackId set_pre_floor_update(function fun) Hooks before the virtual function.
The callback signature is bool floor_update(Floor self)
CallbackId set_post_floor_update(function fun) Hooks after the virtual function.
The callback signature is nil floor_update(Floor self)

ForceField

Derived from Entity Floor

Type Name Description
Entity first_item_beam
Entity fx
SoundMeta sound
Illumination emitted_light
bool is_on
nil activate_laserbeam(bool turn_on)

Generator

Derived from Entity Floor

Type Name Description
int spawned_uid
int set_timer
int timer
int start_counter Applicable only for ENT_TYPE.FLOOR_SUNCHALLENGE_GENERATOR
bool on_off Applicable only for ENT_TYPE.FLOOR_SUNCHALLENGE_GENERATOR

HorizontalForceField

Derived from Entity Floor

Type Name Description
Entity first_item_beam
Entity fx
SoundMeta sound
int timer
bool is_on

JungleSpearTrap

Derived from Entity Floor

Type Name Description
nil trigger(int who_uid, int direction) The uid must be movable entity for ownership transfers, direction: 1 = left, 2 = right, 3 = up, 4 = down

LaserTrap

Derived from Entity Floor

Type Name Description
Illumination emitted_light
int timer counts up from 0 after triggering, cannot shoot again until 360
nil trigger(int who_uid) The uid must be movable entity for ownership transfers

LockedDoor

Derived from Entity Floor Door

Type Name Description
bool unlocked

MainExit

Derived from Entity Floor Door ExitDoor

Type Name Description
SoundMeta sound
Entity door_blocker Normally FX_MAIN_EXIT_DOOR but setting any entity here will block the door

MotherStatue

Derived from Entity Floor

Type Name Description
array<bool, 4> players_standing Table of player1_standing, player2_standing, ... etc.
bool player1_standing
bool player2_standing
bool player3_standing
bool player4_standing
array<bool, 4> players_health_received Table of player1_health_received, player2_health_received, ... etc.
bool player1_health_received
bool player2_health_received
bool player3_health_received
bool player4_health_received
array<int, 4> players_health_timer Table of player1_health_timer, player2_health_timer, ... etc.
int player1_health_timer
int player2_health_timer
int player3_health_timer
int player4_health_timer
int eggplantchild_timer
bool eggplantchild_detected

Pipe

Derived from Entity Floor

Type Name Description
int direction_type 3 - straight_horizontal, 4 - blocked, 5 - down_left_turn, 6 - down_right_turn, 8 - blocked, 9 - up_left_turn, 10 - up_right_turn, 12 - straight_vertical
bool end_pipe

PoleDeco

Derived from Entity Floor

Type Name Description
int deco_up
int deco_down

QuickSand

Derived from Entity Floor

Type Name Description

SlidingWallCeiling

Derived from Entity Floor

Type Name Description
Entity attached_piece
int active_floor_part_uid
int state 1 - going up / is at the top, 2 - pause
SoundMeta ball_rise
SoundMeta ball_drop

SparkTrap

Derived from Entity Floor

Type Name Description
Illumination emitted_light
int spark_uid

SpikeballTrap

Derived from Entity Floor

Type Name Description
SoundMeta sound
Entity chain
Entity end_piece
int state 0 - none, 1 - start, 2 - going_down, 3 - going_up, 4 - pause; going_up is only right when timer is 0, otherwise it just sits at the bottom
int timer for the start and retract

StickyTrap

Derived from Entity Floor

Type Name Description
SoundMeta sound
int attached_piece_uid
int ball_uid
int state 0 - none, 1 - start, 2 - going down, 3 - is at the bottom, 4 - going up, 5 - pause
int timer

TeleportingBorder

Derived from Entity Floor

Type Name Description
int direction 0 - right, 1 - left, 2 - bottom, 3 - top, 4 - disable

TentacleBottom

Derived from Entity Floor

Type Name Description
int attached_piece_uid
int tentacle_uid
int state 0 - none, 1 - start, 2 - moving up, 3 - at the top, 4 - moving down 5 - pause

TimedForceField

Derived from Entity Floor ForceField

Type Name Description
int timer
bool pause

TotemTrap

Derived from Entity Floor

Type Name Description
ENT_TYPE spawn_entity_type
int first_sound_id
nil trigger(int who_uid, bool left) The uid must be movable entity for ownership transfers

TransferFloor

Derived from Entity Floor

Type Name Description
map<int, int> transferred_entities Index is the uid, value is frame the entity entered the floor (time_level), use pairs to loop thru

Generic entities

BoulderSpawner

Derived from Entity

Type Name Description
int timer Can be set negative for longer time period, spawns boulder at 150, setting it higher with count to overflow
SoundMeta sound

CameraFlash

Derived from Entity

Type Name Description
Illumination illumination1
Illumination illumination2
int timer

CinematicAnchor

Derived from Entity

Type Name Description
Entity blackbar_top
Entity blackbar_bottom
float roll_in 0.0 to 1.0

CrossBeam

Derived from Entity

Type Name Description
int attached_to_side_uid
int attached_to_top_uid

DMAlienBlast

Derived from Entity

Type Name Description
int owner_uid
int timer
SoundMeta sound
Entity reticule_internal
Entity reticule_external

DMSpawning

Derived from Entity

Type Name Description
float spawn_x
float spawn_y
float sine_pos
int timer

DecoRegeneratingBlock

Derived from Entity

Type Name Description

DustWallApep

Derived from Entity

Type Name Description
ParticleEmitterInfo particle

EggplantThrower

Derived from Entity

Type Name Description

Entity

Type Name Description
EntityDB type Type of the entity, contains special properties etc. If you want to edit them just for this entity look at the EntityDB
Entity overlay
ENT_FLAG flags see flags.hpp entity_flags
ENT_MORE_FLAG more_flags see flags.hpp more_flags
int uid Unique id of the entity, save it to variable to check this entity later (don't use the whole Entity type as it will be replaced with a different one when this is destroyed)
int animation_frame Number (id) of the sprite in the texture
int draw_depth Depth level that this entity is drawn on.
Don't edit this directly, use set_draw_depth function
float x Position of the entity in the world, or relative to overlay if attached to something. Use get_position to get real position of anything in the game world.
float y Position of the entity in the world, or relative to overlay if attached to something. Use get_position to get real position of anything in the game world.
float abs_x Absolute position in the world, even if overlaid. Should be the same as get_position. Read only.
float abs_y Absolute position in the world, even if overlaid. Should be the same as get_position. Read only.
int layer Use set_layer to change
float width Width of the sprite
float height Height of the sprite
float special_offsetx Special offset used for entities attached to others (or picked by others) that need to flip to the other side when the parent flips sides
float special_offsety Special offset used for entities attached to others (or picked by others) that need to flip to the other side when the parent flips sides
float tile_width Size of the sprite in the texture
float tile_height Size of the sprite in the texture
float angle
Color color
float hitboxx Half of the width of the hitbox
float hitboxy Half of the height of the hitbox
SHAPE shape
bool hitbox_enabled
float offsetx Offset of the hitbox in relation to the entity position
float offsety Offset of the hitbox in relation to the entity position
RenderInfo rendering_info
any user_data You can put any arbitrary lua object here for custom entities or player stats, which is then saved across level transitions for players and carried items, mounts etc... This field is local to the script and multiple scripts can write different things in the same entity. The data is saved right before ON.PRE_LOAD_SCREEN from a level and loaded right before ON.POST_LOAD_SCREEN to a level or transition. It is not available yet in post_entity_spawn, but that is a good place to initialize it for new custom entities. See example for more.
Entity topmost()
Entity topmost_mount()
bool overlaps_with(AABB hitbox)
bool overlaps_with(float rect_left, float rect_bottom, float rect_right, float rect_top) Deprecated
Use overlaps_with(AABB hitbox) instead
bool overlaps_with(Entity other)
TEXTURE get_texture()
bool set_texture(TEXTURE texture_id) Changes the entity texture, check the textures.txt for available vanilla textures or use define_texture to make custom one
nil set_draw_depth(int draw_depth)
nil set_enable_turning(bool enabled)
nil liberate_from_shop()
Entity get_held_entity()
nil set_layer(LAYER layer) Moves the entity to specified layer, nothing else happens, so this does not emulate a door transition
nil apply_layer() Adds the entity to its own layer, to add it to entity lookup tables without waiting for a state update
nil remove() Moves the entity to the limbo-layer where it can later be retrieved from again via respawn
nil respawn(LAYER layer_to) Moves the entity from the limbo-layer (where it was previously put by remove) to layer
nil kill(bool destroy_corpse, Entity responsible) Kills the entity, you can set responsible to nil to ignore it
nil destroy() Completely removes the entity from existence
nil activate(Entity activator) Activates a button prompt (with the Use door/Buy button), e.g. buy shop item, activate drill, read sign, interact in camp, ... get_entity(<udjat socket uid>):activate(players[1]) (make sure player 1 has the udjat eye though)
nil perform_teleport(int delta_x, int delta_y) Performs a teleport as if the entity had a teleporter and used it. The delta coordinates are where you want the entity to teleport to relative to its current position, in tiles (so integers, not floats). Positive numbers = to the right and up, negative left and down.
bool trigger_action(Entity user) Triggers weapons and other held items like teleportter, mattock etc. You can check the virtual-availability.md, if entity has open in the on_open you can use this function, otherwise it does nothing. Returns false if action could not be performed (cooldown is not 0, no arrow loaded in etc. the animation could still be played thou)
int get_metadata() e.g. for turkey: stores health, poison/curse state, for mattock: remaining swings (returned value is transferred)
nil apply_metadata(int metadata)
nil set_invisible(bool value)
vector<int> get_items()
bool is_in_liquid() Returns true if entity is in water/lava
bool is_cursed()
nil kill_recursive(bool destroy_corpse, Entity responsible, optional mask, array ent_types, RECURSIVE_MODE rec_mode) Kill entity along with all entities attached to it. Be aware that for example killing push block with this function will also kill anything on top of it, any items, players, monsters etc.
To avoid that, you can inclusively or exclusively limit certain MASK and ENT_TYPE. Note: the function will first check mask, if the entity doesn't match, it will look in the provided ENT_TYPE's
destroy_corpse and responsible are the standard parameters for the kill function
nil kill_recursive(bool destroy_corpse, Entity responsible) Short for using RECURSIVE_MODE.NONE
nil destroy_recursive(optional mask, array ent_types, RECURSIVE_MODE rec_mode) Destroy entity along with all entities attached to it. Be aware that for example destroying push block with this function will also destroy anything on top of it, any items, players, monsters etc.
To avoid that, you can inclusively or exclusively limit certain MASK and ENT_TYPE. Note: the function will first check the mask, if the entity doesn't match, it will look in the provided ENT_TYPE's
nil destroy_recursive() Short for using RECURSIVE_MODE.NONE
nil update()
CallbackId set_pre_virtual(ENTITY_OVERRIDE entry, function fun) Hooks before the virtual function at index entry.
CallbackId set_post_virtual(ENTITY_OVERRIDE entry, function fun) Hooks after the virtual function at index entry.
nil clear_virtual(CallbackId callback_id) Clears the hook given by callback_id, alternatively use clear_callback() inside the hook.
CallbackId set_pre_dtor(function fun) Hooks before the virtual function.
The callback signature is nil dtor(Entity self)
CallbackId set_post_dtor(function fun) Hooks after the virtual function.
The callback signature is nil dtor(Entity self)
CallbackId set_pre_create_rendering_info(function fun) Hooks before the virtual function.
The callback signature is bool create_rendering_info(Entity self)
CallbackId set_post_create_rendering_info(function fun) Hooks after the virtual function.
The callback signature is nil create_rendering_info(Entity self)
CallbackId set_pre_update_state_machine(function fun) Hooks before the virtual function.
The callback signature is bool update_state_machine(Entity self)
CallbackId set_post_update_state_machine(function fun) Hooks after the virtual function.
The callback signature is nil update_state_machine(Entity self)
CallbackId set_pre_kill(function fun) Hooks before the virtual function.
The callback signature is bool kill(Entity self, bool destroy_corpse, Entity responsible)
Virtual function docs:
Kills the entity, you can set responsible to nil to ignore it
CallbackId set_post_kill(function fun) Hooks after the virtual function.
The callback signature is nil kill(Entity self, bool destroy_corpse, Entity responsible)
Virtual function docs:
Kills the entity, you can set responsible to nil to ignore it
CallbackId set_pre_on_collision1(function fun) Hooks before the virtual function.
The callback signature is bool on_collision1(Entity self, Entity other_entity)
CallbackId set_post_on_collision1(function fun) Hooks after the virtual function.
The callback signature is nil on_collision1(Entity self, Entity other_entity)
CallbackId set_pre_destroy(function fun) Hooks before the virtual function.
The callback signature is bool destroy(Entity self)
Virtual function docs:
Completely removes the entity from existence
CallbackId set_post_destroy(function fun) Hooks after the virtual function.
The callback signature is nil destroy(Entity self)
Virtual function docs:
Completely removes the entity from existence
CallbackId set_pre_can_be_pushed(function fun) Hooks before the virtual function.
The callback signature is optional<bool> can_be_pushed(Entity self)
CallbackId set_post_can_be_pushed(function fun) Hooks after the virtual function.
The callback signature is nil can_be_pushed(Entity self)
CallbackId set_pre_is_in_liquid(function fun) Hooks before the virtual function.
The callback signature is optional<bool> is_in_liquid(Entity self)
Virtual function docs:
Returns true if entity is in water/lava
CallbackId set_post_is_in_liquid(function fun) Hooks after the virtual function.
The callback signature is nil is_in_liquid(Entity self)
Virtual function docs:
Returns true if entity is in water/lava
CallbackId set_pre_set_invisible(function fun) Hooks before the virtual function.
The callback signature is bool set_invisible(Entity self, bool value)
CallbackId set_post_set_invisible(function fun) Hooks after the virtual function.
The callback signature is nil set_invisible(Entity self, bool value)
CallbackId set_pre_friction(function fun) Hooks before the virtual function.
The callback signature is optional<float> friction(Entity self)
CallbackId set_post_friction(function fun) Hooks after the virtual function.
The callback signature is nil friction(Entity self)
CallbackId set_pre_get_held_entity(function fun) Hooks before the virtual function.
The callback signature is optional<Entity> get_held_entity(Entity self)
CallbackId set_post_get_held_entity(function fun) Hooks after the virtual function.
The callback signature is nil get_held_entity(Entity self)
CallbackId set_pre_trigger_action(function fun) Hooks before the virtual function.
The callback signature is optional<bool> trigger_action(Entity self, Entity user)
Virtual function docs:
Triggers weapons and other held items like teleportter, mattock etc. You can check the virtual-availability.md, if entity has open in the on_open you can use this function, otherwise it does nothing. Returns false if action could not be performed (cooldown is not 0, no arrow loaded in etc. the animation could still be played thou)
CallbackId set_post_trigger_action(function fun) Hooks after the virtual function.
The callback signature is nil trigger_action(Entity self, Entity user)
Virtual function docs:
Triggers weapons and other held items like teleportter, mattock etc. You can check the virtual-availability.md, if entity has open in the on_open you can use this function, otherwise it does nothing. Returns false if action could not be performed (cooldown is not 0, no arrow loaded in etc. the animation could still be played thou)
CallbackId set_pre_activate(function fun) Hooks before the virtual function.
The callback signature is bool activate(Entity self, Entity activator)
Virtual function docs:
Activates a button prompt (with the Use door/Buy button), e.g. buy shop item, activate drill, read sign, interact in camp, ... get_entity(<udjat socket uid>):activate(players[1]) (make sure player 1 has the udjat eye though)
CallbackId set_post_activate(function fun) Hooks after the virtual function.
The callback signature is nil activate(Entity self, Entity activator)
Virtual function docs:
Activates a button prompt (with the Use door/Buy button), e.g. buy shop item, activate drill, read sign, interact in camp, ... get_entity(<udjat socket uid>):activate(players[1]) (make sure player 1 has the udjat eye though)
CallbackId set_pre_on_collision2(function fun) Hooks before the virtual function.
The callback signature is bool on_collision2(Entity self, Entity other_entity)
CallbackId set_post_on_collision2(function fun) Hooks after the virtual function.
The callback signature is nil on_collision2(Entity self, Entity other_entity)
CallbackId set_pre_get_metadata(function fun) Hooks before the virtual function.
The callback signature is optional<int> get_metadata(Entity self)
Virtual function docs:
e.g. for turkey: stores health, poison/curse state, for mattock: remaining swings (returned value is transferred)
CallbackId set_post_get_metadata(function fun) Hooks after the virtual function.
The callback signature is nil get_metadata(Entity self)
Virtual function docs:
e.g. for turkey: stores health, poison/curse state, for mattock: remaining swings (returned value is transferred)
CallbackId set_pre_apply_metadata(function fun) Hooks before the virtual function.
The callback signature is bool apply_metadata(Entity self, int metadata)
CallbackId set_post_apply_metadata(function fun) Hooks after the virtual function.
The callback signature is nil apply_metadata(Entity self, int metadata)
CallbackId set_pre_walked_on(function fun) Hooks before the virtual function.
The callback signature is bool walked_on(Entity self, Entity)
CallbackId set_post_walked_on(function fun) Hooks after the virtual function.
The callback signature is nil walked_on(Entity self, Entity)
CallbackId set_pre_walked_off(function fun) Hooks before the virtual function.
The callback signature is bool walked_off(Entity self, Entity)
CallbackId set_post_walked_off(function fun) Hooks after the virtual function.
The callback signature is nil walked_off(Entity self, Entity)
CallbackId set_pre_ledge_grab(function fun) Hooks before the virtual function.
The callback signature is bool ledge_grab(Entity self, Entity)
CallbackId set_post_ledge_grab(function fun) Hooks after the virtual function.
The callback signature is nil ledge_grab(Entity self, Entity)
CallbackId set_pre_stood_on(function fun) Hooks before the virtual function.
The callback signature is bool stood_on(Entity self, Entity)
CallbackId set_post_stood_on(function fun) Hooks after the virtual function.
The callback signature is nil stood_on(Entity self, Entity)
CallbackId set_pre_init(function fun) Hooks before the virtual function.
The callback signature is bool init(Entity self)
CallbackId set_post_init(function fun) Hooks after the virtual function.
The callback signature is nil init(Entity self)

IceSlidingSound

Derived from Entity LogicalSound

Type Name Description

JungleTrapTrigger

Derived from Entity LogicalTrapTrigger

Type Name Description

Lava

Derived from Entity Liquid

Type Name Description
Illumination emitted_light

LimbAnchor

Derived from Entity

Type Name Description
int move_timer
bool flip_vertical

Liquid

Derived from Entity

Type Name Description
Entity fx_surface
int get_liquid_flags()
nil set_liquid_flags(int flags)

MummyFliesSound

Derived from Entity LogicalSound

Type Name Description
int mummy_uid
int flies Numbers of flies spawned

OuroboroCameraAnchor

Derived from Entity

Type Name Description
float target_x
float target_y
float velocity_x
float velocity_y

OuroboroCameraZoomin

Derived from Entity

Type Name Description
float zoomin_level Can be set to negative, seams to trigger the warp at some value

PalaceSign

Derived from Entity

Type Name Description
SoundMeta sound The neon buzz sound
Illumination illumination
Illumination arrow_illumination
int arrow_change_timer

PipeTravelerSound

Derived from Entity LogicalSound

Type Name Description
bool enter_exit

Portal

Derived from Entity

Type Name Description
Illumination emitted_light
int transition_timer
int level
int world
int theme
int timer

QuickSandSound

Derived from Entity LogicalSound

Type Name Description

RoomLight

Derived from Entity

Type Name Description
Illumination illumination

ShootingStarSpawner

Derived from Entity

Type Name Description
int timer

SplashBubbleGenerator

Derived from Entity

Type Name Description
int timer

Logical entities

LogicalAnchovyFlock

Derived from Entity

Type Name Description
float current_speed Increases until max_speed reached
float max_speed
int timer

LogicalConveyorbeltSound

Derived from Entity LogicalSound

Type Name Description

LogicalDoor

Derived from Entity

Type Name Description
ENT_TYPE door_type Spawns this entity when not covered by floor. Must be initialized to valid ENT_TYPE before revealed, or crashes the game.
ENT_TYPE platform_type Spawns this entity below when tile below is uncovered. Doesn't spawn anything if it was never covered by floor, unless platform_spawned is set to false. Must be initialized to valid ENT_TYPE before revealed, or crashes the game.
bool visible Set automatically when not covered by floor.
bool platform_spawned Set automatically when tile below is not covered by floor. Unset to force the platform to spawn if it was never covered in the first place.

LogicalDrain

Derived from Entity

Type Name Description
int timer Little delay between pulling blob of liquid thru

LogicalLiquidStreamSound

Derived from Entity LogicalSound LogicalStaticSound

Type Name Description

LogicalMiniGame

Derived from Entity

Type Name Description
int timer Delay between spawning ufo

LogicalRegeneratingBlock

Derived from Entity

Type Name Description
int timer

LogicalSound

Derived from Entity

Type Name Description
SoundMeta sound

LogicalStaticSound

Derived from Entity LogicalSound

Type Name Description

LogicalTrapTrigger

Derived from Entity

Type Name Description
int min_empty_distance Used in BigSpearTrap when it has to have minimum 2 free spaces to be able to trigger, value in tiles
int trigger_distance Value in tiles
bool vertical

Monsters, Inc.

Alien

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int jump_timer

Ammit

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int walk_pause_timer
ParticleEmitterInfo particle

Anubis

Derived from Entity Movable PowerupCapable Monster

Type Name Description
float spawn_x
float spawn_y
float attack_proximity_y
float attack_proximity_x
int ai_timer
int next_attack_timer
int psychic_orbs_counter
bool awake

ApepHead

Derived from Entity Movable PowerupCapable Monster ApepPart

Type Name Description
SoundMeta sound1
SoundMeta sound2
float distance_traveled
int tail_uid
int fx_mouthpiece1_uid
int fx_mouthpiece2_uid

ApepPart

Derived from Entity Movable PowerupCapable Monster

Type Name Description
float y_pos
float sine_angle
int sync_timer or pause timer, used to sync the body parts moving up and down

Axolotl

Derived from Entity Movable PowerupCapable Mount

Type Name Description
int attack_cooldown
bool can_teleport

Bat

Derived from Entity Movable PowerupCapable Monster

Type Name Description
float spawn_x
float spawn_y

Bee

Derived from Entity Movable PowerupCapable Monster

Type Name Description
bool can_rest
SoundMeta sound
int fly_hang_timer
int targeting_timer
int walk_start_time
int walk_end_time
float wobble_x
float wobble_y

Beg

Derived from Entity Movable PowerupCapable Monster NPC

Type Name Description
int walk_pause_timer
int disappear_timer

Bodyguard

Derived from Entity Movable PowerupCapable Monster NPC

Type Name Description
int position_state 0 - none, 1 - Tusk dice shop, 2 - Entrance to pleasure palace, 3 - Basement entrance to pleasure palace
bool message_shown

CatMummy

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int ai_state
int attack_timer

Caveman

Derived from Entity Movable PowerupCapable Monster WalkingMonster

Type Name Description
int wake_up_timer
int can_pick_up_timer 0 = can pick something up, when holding forced to 179, after tripping and regaining consciousness counts down to 0
int aggro_timer keeps resetting when angry and a player is nearby

CavemanShopkeeper

Derived from Entity Movable PowerupCapable Monster WalkingMonster

Type Name Description
bool tripping
bool shop_entered

Cobra

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int spit_timer

Crabman

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int walk_pause_timer
int invincibility_timer
int poison_attack_timer
int attacking_claw_uid
bool at_maximum_attack

Critter

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int last_picked_up_by_uid
int holding_state

CritterBeetle

Derived from Entity Movable PowerupCapable Monster Critter

Type Name Description
bool pause used when he's getting eaten

CritterButterfly

Derived from Entity Movable PowerupCapable Monster Critter

Type Name Description
int change_direction_timer
int vertical_flight_direction

CritterCrab

Derived from Entity Movable PowerupCapable Monster Critter

Type Name Description
int walk_pause_timer
bool walking_left
bool unfriendly moves away from its target instead of towards it

CritterDrone

Derived from Entity Movable PowerupCapable Monster Critter

Type Name Description
Illumination emitted_light
SoundMeta sound
float applied_hor_momentum
float applied_ver_momentum
bool unfriendly moves away from its target instead of towards it
int move_timer

CritterFirefly

Derived from Entity Movable PowerupCapable Monster Critter

Type Name Description
float sine_amplitude
float sine_frequency
float sine_angle
int change_direction_timer
int sit_timer
int sit_cooldown_timer

CritterFish

Derived from Entity Movable PowerupCapable Monster Critter

Type Name Description
int swim_pause_timer
bool player_in_proximity

CritterLocust

Derived from Entity Movable PowerupCapable Monster Critter

Type Name Description
SoundMeta sound
int jump_timer

CritterPenguin

Derived from Entity Movable PowerupCapable Monster Critter

Type Name Description
int walk_pause_timer
int jump_timer

CritterSlime

Derived from Entity Movable PowerupCapable Monster Critter

Type Name Description
float x_direction
float y_direction
float pos_x
float pos_y
float rotation_center_x
float rotation_center_y
float rotation_angle
float rotation_speed
int walk_pause_timer

CritterSnail

Derived from Entity Movable PowerupCapable Monster Critter

Type Name Description
float x_direction
float y_direction
float pos_x
float pos_y
float rotation_center_x
float rotation_center_y
float rotation_angle
float rotation_speed

Crocman

Derived from Entity Movable PowerupCapable Monster WalkingMonster

Type Name Description
int teleport_cooldown

EggplantMinister

Derived from Entity Movable PowerupCapable Monster

Type Name Description
SoundMeta sound
int walk_pause_timer
int squish_timer

FireFrog

Derived from Entity Movable PowerupCapable Monster Frog

Type Name Description
SoundMeta sound

Firebug

Derived from Entity Movable PowerupCapable Monster

Type Name Description
SoundMeta sound
int fire_timer
bool going_up
bool detached_from_chain

FirebugUnchained

Derived from Entity Movable PowerupCapable Monster

Type Name Description
SoundMeta sound
float max_flight_height
int ai_timer
int walking_timer

Fish

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int change_direction_timer

ForestSister

Derived from Entity Movable PowerupCapable Monster NPC

Type Name Description
int walk_pause_timer

Frog

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int grub_being_eaten_uid
int jump_timer
bool pause

Ghist

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int body_uid
int idle_timer
SoundMeta sound
int transparency
int fadeout

Ghost

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int split_timer for SMALL_HAPPY this is also the sequence timer of its various states
int wobble_timer
int pace_timer Controls ghost pacing when all players are dead.
float velocity_multiplier
GHOST_BEHAVIOR ghost_behaviour
Illumination emitted_light
Entity linked_ghost
SoundMeta sound
bool blown_by_player
bool happy_dancing_clockwise
float target_dist_visibility_factor
float target_layer_visibility_factor

GiantFish

Derived from Entity Movable PowerupCapable Monster

Type Name Description
SoundMeta sound
int change_direction_timer when bouncing into a wall
int lose_interest_timer delay in-between attacks

GiantFly

Derived from Entity Movable PowerupCapable Monster

Type Name Description
Entity head_entity
SoundMeta sound
ParticleEmitterInfo particle
float sine_amplitude
float sine_frequency
float delta_y_angle
int sine_counter

GiantFrog

Derived from Entity Movable PowerupCapable Monster

Type Name Description
Entity door_front_layer
Entity door_back_layer
Entity platform
int attack_timer
int frogs_ejected_in_cycle
int invincibility_timer
int mouth_close_timer
bool mouth_open_trigger opens the mouth and starts mouth_close_timer, used when detecting grub in the mouth area

GoldMonkey

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int jump_timer
int poop_timer
int poop_count

Grub

Derived from Entity Movable PowerupCapable Monster

Type Name Description
float rotation_delta
bool drop
int looking_for_new_direction_timer used when he touches floor/wall/ceiling
int walk_pause_timer
int turn_into_fly_timer
ParticleEmitterInfo particle
SoundMeta sound

HangSpider

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int dangle_jump_timer
float ceiling_pos_x
float ceiling_pos_y

Hermitcrab

Derived from Entity Movable PowerupCapable Monster

Type Name Description
ENT_TYPE carried_entity_type
int carried_entity_uid
int walk_spit_timer
bool is_active whether it is hidden behind the carried block or not, if true you can damage him
bool is_inactive
bool spawn_new_carried_item defaults to true, when toggled to false, a new carried item spawns

HornedLizard

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int eaten_uid dungbeetle being eaten
int walk_pause_timer alternates between walking and pausing when timer reaches zero
int attack_cooldown_timer won't attack until timer reaches zero
int blood_squirt_timer
SoundMeta sound
ParticleEmitterInfo particle

Hundun

Derived from Entity Movable PowerupCapable Monster

Type Name Description
float applied_hor_velocity
float applied_ver_velocity
int birdhead_entity_uid
int snakehead_entity_uid
float y_level current floor level
int bounce_timer
int fireball_timer
bool birdhead_defeated
bool snakehead_defeated
int hundun_flags 1: Will move to the left, 2: Birdhead emerged, 3: Snakehead emerged, 4: Top level arena reached, 5: Birdhead shot last - to alternate the heads shooting fireballs
float y_limit This is custom variable, you need activate_hundun_hack to use it
float rising_speed_x This is custom variable, you need activate_hundun_hack to use it
float rising_speed_y This is custom variable, you need activate_hundun_hack to use it
float bird_head_spawn_y This is custom variable, you need activate_hundun_hack to use it
float snake_head_spawn_y This is custom variable, you need activate_hundun_hack to use it

HundunHead

Derived from Entity Movable PowerupCapable Monster

Type Name Description
float attack_position_x Position where the head will move on attack
float attack_position_y
int egg_crack_effect_uid
int targeted_player_uid
int looking_for_target_timer also cooldown before attack
int invincibility_timer

Imp

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int carrying_uid
float patrol_y_level

Jiangshi

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int wait_timer wait time between jumps
int jump_counter only female aka assassin: when 0 will jump up into ceiling
bool on_ceiling only female aka assassin

JumpDog

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int walk_pause_timer
int squish_timer

Kingu

Derived from Entity Movable PowerupCapable Monster

Type Name Description
SoundMeta sound1 initialized when breaking the shell (sliding down sound maybe?)
SoundMeta sound2 Turning into stone sound
float climb_direction_x
float climb_direction_y
int climb_pause_timer
int shell_invincibility_timer
int monster_spawn_timer
int initial_shell_health Excalibur wipes out immediately, bombs take off 11 points, when 0 vulnerable to whip
bool player_seen_by_kingu

Lahamu

Derived from Entity Movable PowerupCapable Monster

Type Name Description
SoundMeta sound
Entity eyeball
int attack_cooldown_timer

Lamassu

Derived from Entity Movable PowerupCapable Monster

Type Name Description
SoundMeta sound
Entity attack_effect_entity
ParticleEmitterInfo particle
Illumination emitted_light
int walk_pause_timer
int flight_timer
int attack_timer
float attack_angle

Lavamander

Derived from Entity Movable PowerupCapable Monster

Type Name Description
Illumination emitted_light
int shoot_lava_timer when this timer reaches zero, it appears on the surface/shoots lava, triggers on player proximity
int jump_pause_timer
int lava_detection_timer
bool is_hot
int player_detect_state 0 - didnt_saw_player, 1 - saw_player, 2 - spited_lava; probably used so he won't spit imminently after seeing the player

Leprechaun

Derived from Entity Movable PowerupCapable Monster WalkingMonster

Type Name Description
SoundMeta sound
int hump_timer
int target_in_sight_timer
int gold amount of gold he picked up, will be drooped on death
int timer_after_humping

MagmaMan

Derived from Entity Movable PowerupCapable Monster

Type Name Description
Illumination emitted_light
SoundMeta sound
ParticleEmitterInfo particle
int jump_timer
int alive_timer

Mantrap

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int walk_pause_timer alternates between walking and pausing every time it reaches zero
int eaten_uid the uid of the entity the mantrap has eaten, in case it can break out, like a shopkeeper

Mech

Derived from Entity Movable PowerupCapable Mount

Type Name Description
SoundMeta crouch_walk_sound
SoundMeta explosion_sound
int gun_cooldown
bool walking
bool breaking_wall

MegaJellyfish

Derived from Entity Movable PowerupCapable Monster

Type Name Description
Entity flipper1
Entity flipper2
SoundMeta sound
int orb_uid game checks if this uid, and two following exist, if not, the Jellyfish starts chasing player
int tail_bg_uid
float applied_velocity
float wagging_tail_counter
int flipper_distance only applies to door-blocking one
int velocity_application_timer

Mole

Derived from Entity Movable PowerupCapable Monster

Type Name Description
SoundMeta burrowing_sound
SoundMeta nonburrowing_sound
ParticleEmitterInfo burrowing_particle
float burrow_dir_x
float burrow_dir_y
int burrowing_in_uid stores the last uid as well
int counter_burrowing
int counter_nonburrowing
int countdown_for_appearing
int digging_state 0 - non_burrowed, 1 - unknown, 2 - burrowed, 3 - state_change

Monkey

Derived from Entity Movable PowerupCapable Monster

Type Name Description
SoundMeta sound
int jump_timer
bool on_vine

Monster

Derived from Entity Movable PowerupCapable

Type Name Description
int chased_target_uid
int target_selection_timer

Mosquito

Derived from Entity Movable PowerupCapable Monster

Type Name Description
float direction_x
float direction_y
float stuck_rel_pos_x
float stuck_rel_pos_y
SoundMeta sound
int timer

Mount

Derived from Entity Movable PowerupCapable

Type Name Description
int rider_uid
SoundMeta sound
bool can_doublejump
bool tamed
int walk_pause_timer
int taming_timer
bool used_double_jump()
nil remove_rider()
nil carry(Movable rider)
nil tame(bool value)

Mummy

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int walk_pause_timer

NPC

Derived from Entity Movable PowerupCapable Monster

Type Name Description
float climb_direction
int target_in_sight_timer
int ai_state
bool aggro for bodyguard and shopkeeperclone it spawns a weapon as well

Necromancer

Derived from Entity Movable PowerupCapable Monster WalkingMonster

Type Name Description
SoundMeta sound
float red_skeleton_spawn_x
float red_skeleton_spawn_y
int resurrection_uid
int resurrection_timer

Octopus

Derived from Entity Movable PowerupCapable Monster WalkingMonster

Type Name Description

Olmite

Derived from Entity Movable PowerupCapable Monster WalkingMonster

Type Name Description
bool armor_on
bool in_stack disables the attack, stun, lock's looking left flag between stack
bool in_stack2 is set to false couple frame after being detached from stack
int on_top_uid
float y_offset
int attack_cooldown_timer

OsirisHand

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int attack_cooldown_timer

OsirisHead

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int right_hand_uid right from his perspective
int left_hand_uid
bool moving_left
int targeting_timer
int invincibility_timer

Pet

Derived from Entity Movable PowerupCapable Monster

Type Name Description
Entity fx_button
int petting_by_uid person whos petting it, only in the camp
int yell_counter counts up to 400 (6.6 sec), when 0 the pet yells out
int func_timer used when free running in the camp
int active_state -1 = sitting and yelling, 0 = either running, dead or picked up
int petted_counter number of times petted in the camp

Player

Derived from Entity Movable PowerupCapable

Type Name Description
Inventory inventory
Illumination emitted_light
int linked_companion_parent entity uid
int linked_companion_child entity uid
Ai ai
PlayerSlot input
Entity basecamp_button_entity Used in base camp to talk with the NPC's
SoundMeta special_sound For Lise System walking and looking up sounds
int jump_lock_timer Increases when holding jump button in the air, set to max while jumping. If this isn't 0, a jump will only be
registered if the jump button was not held on the previous frame.
int coyote_timer can jump while airborne if greater than 0
int swim_timer Timer between strokes when holding jump button in water.
int hired_hand_name 0-25 alphabetical index of hired hand names.
nil set_jetpack_fuel(int fuel)
int kapala_blood_amount()
string get_name() Get the full name of the character, this will be the modded name not only the vanilla name.
string get_short_name() Get the short name of the character, this will be the modded name not only the vanilla name.
Color get_heart_color() Get the heart color of the character, this will be the modded heart color not only the vanilla heart color.
bool is_female() Check whether the character is female, will be true if the character was modded to be female as well.
nil set_heart_color(Color hcolor) Set the heart color the character.
nil let_go() Drops from ladders, ropes and ledge grabs

PowerupCapable

Derived from Entity Movable

Type Name Description
nil remove_powerup(ENT_TYPE powerup_type) Removes a currently applied powerup. Specify ENT_TYPE.ITEM_POWERUP_xxx, not ENT_TYPE.ITEM_PICKUP_xxx! Removing the Eggplant crown does not seem to undo the throwing of eggplants, the other powerups seem to work.
nil give_powerup(ENT_TYPE powerup_type) Gives the player/monster the specified powerup. Specify ENT_TYPE.ITEM_POWERUP_xxx, not ENT_TYPE.ITEM_PICKUP_xxx! Giving true crown to a monster crashes the game.
bool has_powerup(ENT_TYPE powerup_type) Checks whether the player/monster has a certain powerup
vector<ENT_TYPE> get_powerups() Return all powerups that the entity has
nil unequip_backitem() Unequips the currently worn backitem
int worn_backitem() Returns the uid of the currently worn backitem, or -1 if wearing nothing

ProtoShopkeeper

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int movement_state 1: "Headpulse/explosion related, 2: Walking, 3: Headpulse/explosion related, 4: Crawling, 6: Headpulse/explosion related
int walk_pause_explode_timer
int walking_speed 0 = slow, 4 = fast

Qilin

Derived from Entity Movable PowerupCapable Mount

Type Name Description
SoundMeta fly_gallop_sound
int attack_cooldown

Quillback

Derived from Entity Movable PowerupCapable Monster WalkingMonster

Type Name Description
SoundMeta sound
ParticleEmitterInfo particle
bool seen_player

Robot

Derived from Entity Movable PowerupCapable Monster WalkingMonster

Type Name Description
SoundMeta sound
Illumination emitted_light_explosion

Rockdog

Derived from Entity Movable PowerupCapable Mount

Type Name Description
int attack_cooldown

RoomOwner

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int room_index
float climb_y_direction
int ai_state
int patrol_timer
int lose_interest_timer
int countdown_timer can't shot when the timer is running
bool is_patrolling
bool aggro_trigger setting this makes him angry, if it's shopkeeper you get 2 aggro points
bool was_hurt also is set true if you set aggro to true, get's trigger even when whipping

Scarab

Derived from Entity Movable PowerupCapable Monster

Type Name Description
SoundMeta sound
Illumination emitted_light
int timer how long to stay in current position

Scorpion

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int walk_pause_timer
int jump_cooldown_timer

Shopkeeper

Derived from Entity Movable PowerupCapable Monster RoomOwner

Type Name Description
int name 0 - Ali, 1 - Bob, 2 - Comso ... and so one, anything above 28 is just random string, can crash the game
int shotgun_attack_delay can't shot when the timer is running
bool has_key will drop key after stun/kill
bool is_ear
bool shop_owner

Skeleton

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int explosion_timer -1 = never explodes

Sorceress

Derived from Entity Movable PowerupCapable Monster WalkingMonster

Type Name Description
int inbetween_attack_timer
float in_air_timer
Illumination halo_emitted_light
Entity fx_entity
SoundMeta sound
int hover_timer

Spider

Derived from Entity Movable PowerupCapable Monster

Type Name Description
float ceiling_pos_x
float ceiling_pos_y
int jump_timer For the giant spider, some times he shot web instead of jumping
float trigger_distance only in the x coordinate

Tadpole

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int acceleration_timer
bool player_spotted

Terra

Derived from Entity Movable PowerupCapable Monster

Type Name Description
Entity fx_button
float x_pos
int abuse_speechbubble_timer

Tiamat

Derived from Entity Movable PowerupCapable Monster

Type Name Description
SoundMeta sound Turning into stone sound
int fx_tiamat_head
int fx_tiamat_arm_right1
int fx_tiamat_arm_right2
int frown_timer
int damage_timer
int attack_timer
float tail_angle
float tail_radian
float tail_move_speed
float right_arm_angle
float attack_x This is custom variable, you need activate_tiamat_position_hack to use it
float attack_y This is custom variable, you need activate_tiamat_position_hack to use it

Tun

Derived from Entity Movable PowerupCapable Monster RoomOwner

Type Name Description
int arrows_left
int reload_timer when 0, a new arrow is loaded into the bow; resets when she finds an arrow on the ground
bool challenge_fee_paid affect only the speech bubble
bool congrats_challenge congrats message shown after exiting a challenge
bool murdered
bool shop_entered
bool tiamat_encounter if set to false, greets you with 'you've done well to reach this place'

UFO

Derived from Entity Movable PowerupCapable Monster

Type Name Description
SoundMeta sound
int patrol_distance
int attack_cooldown_timer
bool is_falling

Vampire

Derived from Entity Movable PowerupCapable Monster

Type Name Description
float jump_trigger_distance_x
float jump_trigger_distance_y
float sleep_pos_x
float sleep_pos_y
int walk_pause_timer

VanHorsing

Derived from Entity Movable PowerupCapable Monster NPC

Type Name Description
bool show_text if set to true, he will say "I've been hunting this fiend a long time!" when on screen
bool special_message_shown one way door message has been shown

Vlad

Derived from Entity Movable PowerupCapable Monster Vampire

Type Name Description
int teleport_timer triggers when Vlad teleports, when timer running he can't teleport and will stun when hit
bool aggro or is awake

Waddler

Derived from Entity Movable PowerupCapable Monster RoomOwner

Type Name Description
bool player_detected
bool on_the_ground
int air_timer

WalkingMonster

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int chatting_to_uid
int walk_pause_timer alternates between walking and pausing every time it reaches zero
int cooldown_timer used for chatting with other monsters, attack cooldowns etc.

WitchDoctor

Derived from Entity Movable PowerupCapable Monster WalkingMonster

Type Name Description
SoundMeta sound
int skull_regen_timer

WitchDoctorSkull

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int witch_doctor_uid
Illumination emitted_light
SoundMeta sound
float rotation_angle

Yama

Derived from Entity Movable PowerupCapable Monster

Type Name Description
bool message_shown

Yang

Derived from Entity Movable PowerupCapable Monster RoomOwner

Type Name Description
set<int> turkeys_in_den Table of uid's of the turkeys, goes only up to 3, is nil when yang is angry
bool first_message_shown I'm looking for turkeys, wanna help?
bool quest_incomplete Is set to false when the quest is over (Yang dead or second turkey delivered)
bool special_message_shown Tusk palace/black market/one way door - message shown

YetiKing

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int walk_pause_timer
Illumination emitted_light
ParticleEmitterInfo particle_fog
ParticleEmitterInfo particle_dust
ParticleEmitterInfo particle_sparkles

YetiQueen

Derived from Entity Movable PowerupCapable Monster

Type Name Description
int walk_pause_timer

Movable entities

AcidBubble

Derived from Entity Movable

Type Name Description
float speed_x
float speed_y
float float_counter

AnkhPowerup

Derived from Entity Movable Powerup

Type Name Description
SoundMeta sound
Entity player
Entity fx_glow
int timer1
int timer2
int timer3
bool music_on_off

Arrow

Derived from Entity Movable Purchasable

Type Name Description
int flame_uid
bool is_on_fire
bool is_poisoned
bool shot_from_trap
nil poison_arrow(bool poisoned)
nil light_up(bool lit)

AxolotlShot

Derived from Entity Movable Projectile

Type Name Description
int trapped_uid
float size
float swing
float swing_periodicity
float distance_after_capture

Backpack

Derived from Entity Movable

Type Name Description
bool explosion_trigger More like on fire trigger, the explosion happens when the timer reaches > 29
int explosion_timer
nil trigger_explosion()

Birdies

Derived from Entity Movable

Type Name Description

Bomb

Derived from Entity Movable

Type Name Description
SoundMeta sound
float scale_hor 1.25 = default regular bomb, 1.875 = default giant bomb, > 1.25 generates ENT_TYPE_FX_POWEREDEXPLOSION
float scale_ver
bool is_big_bomb is bomb from powerpack

BoneBlock

Derived from Entity Movable

Type Name Description

Boombox

Derived from Entity Movable

Type Name Description
Entity fx_button
ParticleEmitterInfo music_note1
ParticleEmitterInfo music_note2
float spawn_y
int station
int station_change_delay
int jump_timer
int jump_state

Boomerang

Derived from Entity Movable Purchasable

Type Name Description
SoundMeta sound
ParticleEmitterInfo trail
float distance
float rotation
int returns_to_uid

Boulder

Derived from Entity Movable

Type Name Description
int is_rolling is set to 1 when the boulder first hits the ground

Bow

Derived from Entity Movable Purchasable

Type Name Description
float get_arrow_special_offset()

Bullet

Derived from Entity Movable Projectile

Type Name Description

Button

Derived from Entity Movable

Type Name Description
int button_sprite Only one can be set:
1 - pad: A, key: Z
2 - pad: X, key: X
4 - pad: B, key: C
8 - pad: Y, key: D
16 - pad: LB, key: L Shift
32 - pad: RB, key: A
64 - pad: menu?, key: (none)
128 - pad: copy?, key: Tab
float visibility
bool is_visible It's false for selldialog used in shops
bool player_trigger It's set true even if player does not see the button, like the drill or COG door
int seen
-1 - hasn't been seen
0 - last seen by player 1
1 - last seen by player 2
2 - last seen by player 3
3 - last seen by player 4

Cape

Derived from Entity Movable Backpack

Type Name Description
bool floating_down

Chain

Derived from Entity Movable

Type Name Description
int attached_to_uid
int timer

ChainedPushBlock

Derived from Entity Movable PushBlock

Type Name Description
bool is_chained

Chest

Derived from Entity Movable

Type Name Description
bool leprechaun
bool bomb size of the bomb is random, if set both true only leprechaun spawns

ClamBase

Derived from Entity Movable

Type Name Description
ENT_TYPE treasure_type
int treasure_uid
float treasure_x_pos
float treasure_y_pos
int top_part_uid

Claw

Derived from Entity Movable

Type Name Description
int crabman_uid
float spawn_x
float spawn_y

ClimbableRope

Derived from Entity Movable

Type Name Description
int segment_nr_inverse
int burn_timer entity is killed after 20
Entity above_part
Entity below_part
int segment_nr

CloneGunShot

Derived from Entity Movable Projectile LightShot

Type Name Description
int timer
float spawn_y

Coffin

Derived from Entity Movable

Type Name Description
ENT_TYPE inside
int timer
bool player_respawn

Coin

Derived from Entity Movable

Type Name Description
int nominal_price

Container

Derived from Entity Movable

Type Name Description
ENT_TYPE inside

CookFire

Derived from Entity Movable Torch

Type Name Description
Illumination emitted_light
ParticleEmitterInfo particles_smoke
ParticleEmitterInfo particles_flames
ParticleEmitterInfo particles_warp
SoundMeta sound

CrushElevator

Derived from Entity Movable

Type Name Description
float y_limit This is custom variable, you need activate_crush_elevator_hack to use it
float speed This is custom variable, you need activate_crush_elevator_hack to use it

Crushtrap

Derived from Entity Movable

Type Name Description
float dirx
float diry
int timer counts from 30 to 0 before moving, after it stops, counts from 60 to 0 before it can be triggered again
int bounce_back_timer counts from 7 to 0 after it hits the wall and moves away until the timer hits 0, then moves back and counts from 255 until it hits the wall again, if needed it will start the counter again for another bounce

CursedPot

Derived from Entity Movable

Type Name Description
ParticleEmitterInfo smoke
ParticleEmitterInfo smoke2

CustomMovableBehavior

Opaque handle to a custom movable behavior from a script mod Derived from MovableBehavior

Type Name Description
VanillaMovableBehavior base_behavior
nil set_force_state(function force_state) Set the force_state function of a CustomMovableBehavior, this will be called every frame when
the movable is updated. If an force_state is already set it will be overridden. The signature
of the function is bool force_state(Movable movable, function base_fun), when the function returns true the movable will
enter this behavior. If no base behavior is set base_fun will be nil.
nil set_on_enter(function on_enter) Set the on_enter function of a CustomMovableBehavior, this will be called when the movable
enters the state. If an on_enter is already set it will be overridden. The signature of the
function is nil on_enter(Movable movable, function base_fun)). If no base behavior is set base_fun will be nil.
nil set_on_exit(function on_exit) Set the on_exit function of a CustomMovableBehavior, this will be called when the movable
leaves the state. If an on_exit is already set it will be overridden. The signature of the
function is nil on_exit(Movable movable, function base_fun)). If no base behavior is set base_fun will be nil.
nil set_update_logic(function update_logic) Set the update_logic function of a CustomMovableBehavior, this will be called every frame when
the movable is updated. If an update_logic is already set it will be overridden. The signature
of the function is nil update_logic(Movable movable, function base_fun)), use it to change the color, texture,
some timers, etc. of the movable. If no base behavior is set base_fun will be nil.
nil set_update_world(function update_world) Set the update_world function of a CustomMovableBehavior, this will be called every frame when
the movable is updated. If an update_world is already set it will be overridden. The signature
of the function is nil update_world(Movable movable, function base_fun)), use this to update the move, velocity,
current_animation, etc. of the movable, then call mov:generic_update_world to update the movable. If no
base behavior is set base_fun will be nil.
nil set_get_next_state_id(function get_next_state_id) Set the get_next_state_id function of a CustomMovableBehavior, this will be called every frame when
the movable is updated. If an get_next_state_id is already set it will be overridden. The signature
of the function is int get_next_state_id(Movable movable, function base_fun)), use this to move to another state, return nil.
or this behaviors state_id to remain in this behavior. If no base behavior is set base_fun will be nil.

Drill

Derived from Entity Movable

Type Name Description
SoundMeta sound1
SoundMeta sound2
Entity top_chain_piece
nil trigger(optional play_sound_effect)

DummyPurchasableEntity

Derived from Entity Movable Purchasable

Type Name Description

EggSac

Derived from Entity Movable

Type Name Description
int timer

EggshipCenterJetFlame

Derived from Entity Movable

Type Name Description
SoundMeta sound
Illumination emitted_light
ParticleEmitterInfo particle
bool smoke_on

Elevator

Derived from Entity Movable

Type Name Description
Illumination emitted_light
int timer pause timer, counts down 60 to 0
bool moving_up

EmpressGrave

Derived from Entity Movable

Type Name Description
Entity fx_button
Entity ghost

Excalibur

Derived from Entity Movable

Type Name Description
bool in_stone

Explosion

Derived from Entity Movable

Type Name Description
Illumination emitted_light

FallingPlatform

Derived from Entity Movable

Type Name Description
int timer
float shaking_factor
float y_pos

Fireball

Derived from Entity Movable Projectile LightShot SoundShot

Type Name Description
ParticleEmitterInfo particle

Flame

Derived from Entity Movable

Type Name Description
SoundMeta sound
Illumination emitted_light

FlameSize

Derived from Entity Movable Flame

Type Name Description
float flame_size if changed, gradually goes down (0.03 per frame) to the default size, it's the base value for entity.width and entity.height

Fly

Derived from Entity Movable

Type Name Description
int timer

FlyHead

Derived from Entity Movable

Type Name Description
int vored_entity_uid

FrozenLiquid

Derived from Entity Movable

Type Name Description

FxAlienBlast

Derived from Entity Movable

Type Name Description

FxAnkhBrokenPiece

Derived from Entity Movable

Type Name Description

FxAnkhRotatingSpark

Derived from Entity Movable

Type Name Description
float radius
float inclination
float speed 0 - 1.0
float sine_angle
float size

FxCompass

Derived from Entity Movable

Type Name Description
float sine_angle Counts form 0 to 2*pi, responsible for moving back and forth
float visibility
bool is_active Player has compass

FxEmpress

Derived from Entity Movable

Type Name Description
float sine_angle

FxFireflyLight

Derived from Entity Movable

Type Name Description
Illumination illumination
int light_timer
int cooldown_timer Timer between light flashes

FxHundunNeckPiece

Derived from Entity Movable

Type Name Description
int kill_timer Short timer after the head is dead

FxJellyfishStar

Derived from Entity Movable

Type Name Description
float rotation_angle
float radius
float speed

FxJetpackFlame

Derived from Entity Movable

Type Name Description
ParticleEmitterInfo particle_smoke
ParticleEmitterInfo particle_flame
SoundMeta sound
Illumination illumination

FxKinguSliding

Derived from Entity Movable

Type Name Description
ParticleEmitterInfo particle

FxLamassuAttack

Derived from Entity Movable

Type Name Description
float attack_angle

FxMainExitDoor

Derived from Entity Movable

Type Name Description
Illumination emitted_light
int timer When breaking open in tutorial

FxNecromancerANKH

Derived from Entity Movable

Type Name Description

FxOuroboroDragonPart

Derived from Entity Movable

Type Name Description
float speed
int timer
ParticleEmitterInfo particle

FxOuroboroOccluder

Derived from Entity Movable

Type Name Description

FxPickupEffect

Derived from Entity Movable

Type Name Description
float spawn_y
float visibility

FxPlayerIndicator

Derived from Entity Movable

Type Name Description
int attached_to
float pos_x
float pos_y

FxQuickSand

Derived from Entity Movable

Type Name Description

FxSaleContainer

Derived from Entity Movable

Type Name Description
Entity fx_value
Entity fx_icon
Entity fx_button
float shake_amplitude For effect when you don't have enough money
bool sound_trigger Also sound_played, keeps re-triggering from time to time
int pop_in_out_procentage

FxShotgunBlast

Derived from Entity Movable

Type Name Description
Illumination illumination

FxSorceressAttack

Derived from Entity Movable

Type Name Description
float size

FxSparkSmall

Derived from Entity Movable

Type Name Description
int timer

FxSpringtrapRing

Derived from Entity Movable

Type Name Description
int timer
Illumination illumination

FxTiamatHead

Derived from Entity Movable

Type Name Description
int timer

FxTiamatTail

Derived from Entity Movable

Type Name Description
float angle_two Added _two just to not shadow angle in entity, it's angle but the pivot point is at the edge
float x_pos
float y_pos

FxTiamatTorso

Derived from Entity Movable

Type Name Description
int timer
float torso_target_size Slowly increases/decreases to the given value

FxTornJournalPage

Derived from Entity Movable

Type Name Description
int page_number Only in tutorial

FxUnderwaterBubble

Derived from Entity Movable

Type Name Description
int bubble_source_uid
int direction 1 / -1
bool pop Setting it true makes it disappear/fade away
bool inverted

FxVatBubble

Derived from Entity Movable

Type Name Description
float max_y

FxWaterDrop

Derived from Entity Movable

Type Name Description
bool inverted
int droplet_source_uid

FxWebbedEffect

Derived from Entity Movable

Type Name Description
bool visible

FxWitchdoctorHint

Derived from Entity Movable

Type Name Description

GhostBreath

Derived from Entity Movable Projectile

Type Name Description
int timer
bool big_cloud

GiantClamTop

Derived from Entity Movable

Type Name Description
int close_timer
int open_timer

Goldbar

Derived from Entity Movable

Type Name Description

Gun

Derived from Entity Movable Purchasable

Type Name Description
int cooldown
int shots used only for webgun
int shots2 used only for clonegun
int in_chamber Only for webgun, uid of the webshot entity

HangAnchor

Derived from Entity Movable

Type Name Description
int spider_uid

HangStrand

Derived from Entity Movable

Type Name Description
float start_pos_y

Honey

Derived from Entity Movable

Type Name Description
int wiggle_timer

Hoverpack

Derived from Entity Movable Backpack

Type Name Description
SoundMeta sound
bool is_on

HundunChest

Derived from Entity Movable Treasure

Type Name Description
int timer

Idol

Derived from Entity Movable

Type Name Description
bool trap_triggered if you set it to true for the ice caves or volcano idol, the trap won't trigger
int touch changes to 0 when first picked up by player and back to -1 if HH picks it up
float spawn_x
float spawn_y

Jetpack

Derived from Entity Movable Backpack

Type Name Description
bool flame_on
int fuel

JungleSpearCosmetic

Derived from Entity Movable

Type Name Description
float move_x
float move_y

KapalaPowerup

Derived from Entity Movable Powerup

Type Name Description
int amount_of_blood

LampFlame

Derived from Entity Movable Flame

Type Name Description
ParticleEmitterInfo flame_particle

Landmine

Derived from Entity Movable LightEmitter

Type Name Description
int timer explodes at 57, if you set it to 58 will count to overflow

LaserBeam

Derived from Entity Movable

Type Name Description
ParticleEmitterInfo sparks
Illumination emitted_light

Leaf

Derived from Entity Movable

Type Name Description
float fade_away_counter counts to 100.0 then the leaf fades away
int swing_direction
bool fade_away_trigger

LightArrow

Derived from Entity Movable Purchasable Arrow

Type Name Description
Illumination emitted_light

LightArrowPlatform

Derived from Entity Movable

Type Name Description
Illumination emitted_light

LightEmitter

Derived from Entity Movable

Type Name Description
Illumination emitted_light

LightShot

Derived from Entity Movable Projectile

Type Name Description
Illumination emitted_light

LiquidSurface

Derived from Entity Movable

Type Name Description
float glow_radius
float sine_pos
float sine_pos_increment

Mattock

Derived from Entity Movable Purchasable

Type Name Description
int remaining

MegaJellyfishEye

Derived from Entity Movable

Type Name Description
int timer

MiniGameAsteroid

Derived from Entity Movable

Type Name Description
float spin_speed

MiniGameShip

Derived from Entity Movable

Type Name Description
SoundMeta sound
float velocity_x
float velocity_y
float swing
float up_down_normal 0.0 - down, 1.0 - up, 0.5 - idle

MiniGameShipOffset

Derived from Entity Movable

Type Name Description
float offset_x
float offset_y
float normal_y_offset Is added to offset_y

Movable

Derived from Entity

Type Name Description
Vec2 move {movex, movey}
float movex Move directions (-1.0 to 1.0) that represent in whit direction the entity want's to move
float movey Move directions (-1.0 to 1.0) that represent in whit direction the entity want's to move
BUTTON buttons
BUTTON buttons_previous
int stand_counter
float jump_height_multiplier EntityDB.jump gets multiplied by this to get the jump
int owner_uid
int last_owner_uid
Animation current_animation
int idle_counter
int standing_on_uid
float velocityx speed, can be relative to the platform you standing on (pushblocks, elevators), use get_velocity to get accurate speed in the game world
float velocityy speed, can be relative to the platform you standing on (pushblocks, elevators), use get_velocity to get accurate speed in the game world
int holding_uid
int state
int last_state
int move_state
int health
int stun_timer
int stun_state
int lock_input_timer Related to taking damage, also drops you from ladder/rope, can't be set while on the ground unless you're on a mount
int wet_effect_timer
int poison_tick_timer Used to apply damage from poison, can be set to -1 to cure poison, to set poison use poison_entity
int falling_timer
bool is_poisoned()
int dark_shadow_timer
int onfire_effect_timer
int exit_invincibility_timer
int invincibility_frames_timer
int frozen_timer
bool is_button_pressed(BUTTON button)
bool is_button_held(BUTTON button)
bool is_button_released(BUTTON button)
int price
nil stun(int framecount)
nil freeze(int framecount)
nil light_on_fire(int time) Does not damage entity
nil set_cursed(bool b, optional effect) effect = true - plays the sound and spawn particle above entity
nil drop(Entity entity_to_drop) Called when dropping or throwing
nil pick_up(Entity entity_to_pick_up)
bool can_jump() Return true if the entity is allowed to jump, even midair. Return false and can't jump, except from ladders apparently.
Entity standing_on()
nil collect_treasure(int value, ENT_TYPE treasure) Adds or subtracts the specified amount of money to the movable's (player's) inventory. Shows the calculation animation in the HUD. Adds treasure to the inventory list shown on transition. Use the global add_money to add money without adding specific treasure.
bool is_on_fire()
bool damage(Entity damage_dealer, int damage_amount, DAMAGE_TYPE damage_flags, Vec2 velocity, int unknown_damage_phase, int stun_amount, int iframes, bool unknown_is_final) Damage the movable by the specified amount, stuns and gives it invincibility for the specified amount of frames and applies the velocities. damage_dealer can be set to nil.
Returns: true if entity was affected, damage_dealer should break etc. false if the event should be ignored by damage_dealer?
vector<int> get_all_behaviors() Get all available behavior ids
bool set_behavior(int behavior_id) Set behavior, this is more than just state as it's an active function, for example climbing ladder is a behavior and it doesn't actually need ladder/rope entity
Returns false if entity doesn't have this behavior id
int get_behavior() Get the current behavior id
nil set_gravity(float gravity) Force the gravity for this entity. Will override anything set by special states like swimming too, unless you reset it. Default 1.0
nil reset_gravity() Remove the gravity hook and reset to defaults
nil set_position(float to_x, float to_y) Set the absolute position of an entity and offset all rendering related things accordingly to teleport without any interpolation or graphical glitches. If the camera is focused on the entity, it is also moved.
nil process_input()
CutsceneBehavior cutscene
nil clear_cutscene()
VanillaMovableBehavior get_base_behavior(int state_id) Gets a vanilla behavior from this movable, needs to be called before clear_behaviors
but the returned values are still valid after a call to clear_behaviors
nil add_behavior(MovableBehavior behavior) Add a behavior to this movable, can be either a VanillaMovableBehavior or a
CustomMovableBehavior
nil clear_behavior(MovableBehavior behavior) Clear a specific behavior of this movable, can be either a VanillaMovableBehavior or a
CustomMovableBehavior, a behavior with this behaviors state_id may be required to
run this movables statemachine without crashing, so add a new one if you are not sure
nil clear_behaviors() Clears all behaviors of this movable, need to call add_behavior to avoid crashing
nil generic_update_world(bool disable_gravity) Move a movable according to its velocity, can disable gravity
Will also update movable.animation_frame and various timers and counters
nil generic_update_world() Move a movable according to its velocity, update physics, gravity, etc.
Will also update movable.animation_frame and various timers and counters
nil generic_update_world(Vec2 move, float sprint_factor, bool disable_gravity, bool on_rope) Move a movable according to its velocity and move, if the movables BUTTON.RUN is
held apply sprint_factor on move.x, can disable gravity or lock its horizontal
movement via on_rope. Use this for example to update a custom enemy type.
Will also update movable.animation_frame and various timers and counters
CallbackId set_pre_virtual(ENTITY_OVERRIDE entry, function fun) Hooks before the virtual function at index entry.
CallbackId set_post_virtual(ENTITY_OVERRIDE entry, function fun) Hooks after the virtual function at index entry.
nil clear_virtual(CallbackId callback_id) Clears the hook given by callback_id, alternatively use clear_callback() inside the hook.
CallbackId set_pre_can_jump(function fun) Hooks before the virtual function.
The callback signature is optional<bool> can_jump(Movable self)
Virtual function docs:
Return true if the entity is allowed to jump, even midair. Return false and can't jump, except from ladders apparently.
CallbackId set_post_can_jump(function fun) Hooks after the virtual function.
The callback signature is nil can_jump(Movable self)
Virtual function docs:
Return true if the entity is allowed to jump, even midair. Return false and can't jump, except from ladders apparently.
CallbackId set_pre_stomp_damage(function fun) Hooks before the virtual function.
The callback signature is optional<int> stomp_damage(Movable self)
CallbackId set_post_stomp_damage(function fun) Hooks after the virtual function.
The callback signature is nil stomp_damage(Movable self)
CallbackId set_pre_is_on_fire(function fun) Hooks before the virtual function.
The callback signature is optional<bool> is_on_fire(Movable self)
CallbackId set_post_is_on_fire(function fun) Hooks after the virtual function.
The callback signature is nil is_on_fire(Movable self)
CallbackId set_pre_damage(function fun) Hooks before the virtual function.
The callback signature is optional<bool> damage(Movable self, Entity damage_dealer, int damage_amount, DAMAGE_TYPE damage_flags, Vec2 velocity, int unknown_damage_phase, int stun_amount, int iframes, bool unknown_is_final)
Virtual function docs:
Damage the movable by the specified amount, stuns and gives it invincibility for the specified amount of frames and applies the velocities. damage_dealer can be set to nil.
Returns: true if entity was affected, damage_dealer should break etc. false if the event should be ignored by damage_dealer?
CallbackId set_post_damage(function fun) Hooks after the virtual function.
The callback signature is nil damage(Movable self, Entity damage_dealer, int damage_amount, DAMAGE_TYPE damage_flags, Vec2 velocity, int unknown_damage_phase, int stun_amount, int iframes, bool unknown_is_final)
Virtual function docs:
Damage the movable by the specified amount, stuns and gives it invincibility for the specified amount of frames and applies the velocities. damage_dealer can be set to nil.
Returns: true if entity was affected, damage_dealer should break etc. false if the event should be ignored by damage_dealer?
CallbackId set_pre_on_hit(function fun) Hooks before the virtual function.
The callback signature is bool on_hit(Movable self, Entity damage_dealer)
Virtual function docs:
Hit by broken arrows etc that don't deal damage, calls on_damage with 0 damage.
CallbackId set_post_on_hit(function fun) Hooks after the virtual function.
The callback signature is nil on_hit(Movable self, Entity damage_dealer)
Virtual function docs:
Hit by broken arrows etc that don't deal damage, calls on_damage with 0 damage.
CallbackId set_pre_stun(function fun) Hooks before the virtual function.
The callback signature is bool stun(Movable self, int framecount)
CallbackId set_post_stun(function fun) Hooks after the virtual function.
The callback signature is nil stun(Movable self, int framecount)
CallbackId set_pre_freeze(function fun) Hooks before the virtual function.
The callback signature is bool freeze(Movable self, int framecount)
CallbackId set_post_freeze(function fun) Hooks after the virtual function.
The callback signature is nil freeze(Movable self, int framecount)
CallbackId set_pre_light_on_fire(function fun) Hooks before the virtual function.
The callback signature is bool light_on_fire(Movable self, int time)
Virtual function docs:
Does not damage entity
CallbackId set_post_light_on_fire(function fun) Hooks after the virtual function.
The callback signature is nil light_on_fire(Movable self, int time)
Virtual function docs:
Does not damage entity
CallbackId set_pre_set_cursed(function fun) Hooks before the virtual function.
The callback signature is bool set_cursed(Movable self, bool b, bool effect)
CallbackId set_post_set_cursed(function fun) Hooks after the virtual function.
The callback signature is nil set_cursed(Movable self, bool b, bool effect)
CallbackId set_pre_web_collision(function fun) Hooks before the virtual function.
The callback signature is bool web_collision(Movable self)
CallbackId set_post_web_collision(function fun) Hooks after the virtual function.
The callback signature is nil web_collision(Movable self)
CallbackId set_pre_check_out_of_bounds(function fun) Hooks before the virtual function.
The callback signature is bool check_out_of_bounds(Movable self)
CallbackId set_post_check_out_of_bounds(function fun) Hooks after the virtual function.
The callback signature is nil check_out_of_bounds(Movable self)
CallbackId set_pre_standing_on(function fun) Hooks before the virtual function.
The callback signature is optional<Entity> standing_on(Movable self)
CallbackId set_post_standing_on(function fun) Hooks after the virtual function.
The callback signature is nil standing_on(Movable self)
CallbackId set_pre_stomped_by(function fun) Hooks before the virtual function.
The callback signature is bool stomped_by(Movable self, Entity)
CallbackId set_post_stomped_by(function fun) Hooks after the virtual function.
The callback signature is nil stomped_by(Movable self, Entity)
CallbackId set_pre_thrown_by(function fun) Hooks before the virtual function.
The callback signature is bool thrown_by(Movable self, Entity)
CallbackId set_post_thrown_by(function fun) Hooks after the virtual function.
The callback signature is nil thrown_by(Movable self, Entity)
CallbackId set_pre_cloned_to(function fun) Hooks before the virtual function.
The callback signature is bool cloned_to(Movable self, Entity)
CallbackId set_post_cloned_to(function fun) Hooks after the virtual function.
The callback signature is nil cloned_to(Movable self, Entity)
CallbackId set_pre_pick_up(function fun) Hooks before the virtual function.
The callback signature is bool pick_up(Movable self, Entity entity_to_pick_up)
CallbackId set_post_pick_up(function fun) Hooks after the virtual function.
The callback signature is nil pick_up(Movable self, Entity entity_to_pick_up)
CallbackId set_pre_picked_up_by(function fun) Hooks before the virtual function.
The callback signature is bool picked_up_by(Movable self, Entity)
CallbackId set_post_picked_up_by(function fun) Hooks after the virtual function.
The callback signature is nil picked_up_by(Movable self, Entity)
CallbackId set_pre_drop(function fun) Hooks before the virtual function.
The callback signature is bool drop(Movable self, Entity entity_to_drop)
Virtual function docs:
Called when dropping or throwing
CallbackId set_post_drop(function fun) Hooks after the virtual function.
The callback signature is nil drop(Movable self, Entity entity_to_drop)
Virtual function docs:
Called when dropping or throwing
CallbackId set_pre_collect_treasure(function fun) Hooks before the virtual function.
The callback signature is bool collect_treasure(Movable self, int value, ENT_TYPE treasure)
Virtual function docs:
Adds or subtracts the specified amount of money to the movable's (player's) inventory. Shows the calculation animation in the HUD. Adds treasure to the inventory list shown on transition. Use the global add_money to add money without adding specific treasure.
CallbackId set_post_collect_treasure(function fun) Hooks after the virtual function.
The callback signature is nil collect_treasure(Movable self, int value, ENT_TYPE treasure)
Virtual function docs:
Adds or subtracts the specified amount of money to the movable's (player's) inventory. Shows the calculation animation in the HUD. Adds treasure to the inventory list shown on transition. Use the global add_money to add money without adding specific treasure.
CallbackId set_pre_initialize(function fun) Hooks before the virtual function.
The callback signature is bool initialize(Movable self)
CallbackId set_post_initialize(function fun) Hooks after the virtual function.
The callback signature is nil initialize(Movable self)
CallbackId set_pre_process_input(function fun) Hooks before the virtual function.
The callback signature is bool process_input(Movable self)
CallbackId set_post_process_input(function fun) Hooks after the virtual function.
The callback signature is nil process_input(Movable self)
CallbackId set_pre_picked_up(function fun) Hooks before the virtual function.
The callback signature is bool picked_up(Movable self)
CallbackId set_post_picked_up(function fun) Hooks after the virtual function.
The callback signature is nil picked_up(Movable self)
CallbackId set_pre_fall(function fun) Hooks before the virtual function.
The callback signature is bool fall(Movable self)
CallbackId set_post_fall(function fun) Hooks after the virtual function.
The callback signature is nil fall(Movable self)
CallbackId set_pre_apply_friction(function fun) Hooks before the virtual function.
The callback signature is bool apply_friction(Movable self)
CallbackId set_post_apply_friction(function fun) Hooks after the virtual function.
The callback signature is nil apply_friction(Movable self)
CallbackId set_pre_crush(function fun) Hooks before the virtual function.
The callback signature is bool crush(Movable self, Entity)
CallbackId set_post_crush(function fun) Hooks after the virtual function.
The callback signature is nil crush(Movable self, Entity)

MovingIcon

Derived from Entity Movable

Type Name Description
int movement_timer Used to move it up and down in sync with others

Olmec

Derived from Entity Movable

Type Name Description
SoundMeta sound
int target_uid
int attack_phase 0 = stomp, 1 = bombs, 2 = stomp+ufos, 3 = in lava
int attack_timer in phase 0/2: time spent looking for player, in phase 1: time between bomb salvo
int ai_timer general timer that counts down whenever olmec is active
int move_direction -1 = left, 0 = down, 1 = right, phase 0/2: depends on target, phase 1: travel direction
int jump_timer
int phase1_amount_of_bomb_salvos
int unknown_attack_state
int broken_floaters()

OlmecCannon

Derived from Entity Movable

Type Name Description
int timer
int bombs_left

OlmecFloater

Derived from Entity Movable

Type Name Description
bool both_floaters_intact
bool on_breaking

OlmecShip

Derived from Entity Movable

Type Name Description
SoundMeta sound
Entity door_fx
ParticleEmitterInfo smoke
int flight_time
bool has_spawned_jetflames

Orb

Derived from Entity Movable

Type Name Description
SoundMeta sound
int timer

ParachutePowerup

Derived from Entity Movable Powerup

Type Name Description
int falltime_deploy this gets compared with entity's falling_timer
bool deployed
nil deploy()
int gold_timer Timer for spawning a single gold nugget.
int gold_spawning_time Time until gold nuggets stop spawning.

PlayerBag

Derived from Entity Movable

Type Name Description
int bombs
int ropes

PlayerGhost

Derived from Entity Movable LightEmitter

Type Name Description
ParticleEmitterInfo sparkles_particle
PlayerSlot player_inputs
Inventory inventory
SoundMeta sound
int body_uid Is not set to -1 when crushed
int shake_timer
int boost_timer

Pot

Derived from Entity Movable Purchasable

Type Name Description
ENT_TYPE inside
bool dont_transfer_dmg

Powerup

Derived from Entity Movable

Type Name Description

Present

Derived from Entity Movable Purchasable

Type Name Description
ENT_TYPE inside

PrizeDispenser

Derived from Entity Movable

Type Name Description
array<int, 6> item_ids Id's of the items (not types), by default 0-24, look at change_diceshop_prizes for the list of default prizes
so for example: id 0 equals ITEM_PICKUP_BOMBBAG, id 1 equals ITEM_PICKUP_BOMBBOX etc. Game generates 6 but uses max 5 for Tusk dice shop
int prizes_spawned

Projectile

Derived from Entity Movable

Type Name Description

PunishBall

Derived from Entity Movable

Type Name Description
int attached_to_uid
int timer counts down from 20 while the ball is eligible to break a floor and tries to break it at 0
float x_pos
float y_pos

Purchasable

Derived from Entity Movable

Type Name Description

PushBlock

Derived from Entity Movable

Type Name Description
SoundMeta sound
ParticleEmitterInfo dust_particle
float dest_pos_x

RegenBlock

Derived from Entity Movable

Type Name Description
bool on_breaking

RollingItem

Derived from Entity Movable Purchasable

Type Name Description
float roll_speed

Rubble

Derived from Entity Movable

Type Name Description

ScepterShot

Derived from Entity Movable LightEmitter

Type Name Description
SoundMeta sound
float speed
int idle_timer short timer before it goes after target

Shield

Derived from Entity Movable Purchasable

Type Name Description
float shake

SkullDropTrap

Derived from Entity Movable

Type Name Description
SoundMeta sound
int left_skull_uid
int middle_skull_uid
int right_skull_uid
int left_skull_drop_time
int middle_skull_drop_time
int right_skull_drop_time
int timer counts from 60 to 0, 3 times, the last time dropping the skulls, then random longer timer for reset

SleepBubble

Derived from Entity Movable

Type Name Description
int show_hide_timer

SnapTrap

Derived from Entity Movable

Type Name Description
int bait_uid
int reload_timer

SoundShot

Derived from Entity Movable Projectile LightShot

Type Name Description
SoundMeta sound

Spark

Derived from Entity Movable Flame

Type Name Description
ParticleEmitterInfo particle
Entity fx_entity
float rotation_center_x
float rotation_center_y
float rotation_angle
float size slowly goes down to default 1.0, is 0.0 when not on screen
float size_multiply 0.0 when not on screen
float next_size width and height will be set to next_size * size_multiply next frame
int size_change_timer very short timer before next size change, giving a pulsing effect
float speed This is custom variable, you need activate_sparktraps_hack to use it
float distance This is custom variable, you need activate_sparktraps_hack to use it

Spear

Derived from Entity Movable

Type Name Description
int sound_id

SpecialShot

Derived from Entity Movable LightEmitter

Type Name Description
float target_x
float target_y

StretchChain

Derived from Entity Movable

Type Name Description
int at_end_of_chain_uid
float dot_offset
int position_in_chain
int inverse_doubled_position_in_chain
bool is_dot_hidden

Switch

Derived from Entity Movable

Type Name Description
int timer

TV

Derived from Entity Movable

Type Name Description
SoundMeta sound
Entity fx_button
Illumination emitted_light
int station

Teleporter

Derived from Entity Movable Purchasable

Type Name Description
int teleport_number

TeleporterBackpack

Derived from Entity Movable Backpack

Type Name Description
int teleport_number

Telescope

Derived from Entity Movable

Type Name Description
Entity fx_button
Entity camera_anchor
int looked_through_by_uid

Tentacle

Derived from Entity Movable Chain

Type Name Description
Entity bottom

ThinIce

Derived from Entity Movable

Type Name Description
int strength counts down when standing on, maximum is 134 as based of this value it changes animation_frame, and above that value it changes to wrong sprite

TiamatShot

Derived from Entity Movable LightEmitter

Type Name Description
SoundMeta sound

TimedPowderkeg

Derived from Entity Movable PushBlock

Type Name Description
int timer timer till explosion, -1 = pause, counts down

TimedShot

Derived from Entity Movable Projectile LightShot

Type Name Description
int timer

Torch

Derived from Entity Movable

Type Name Description
int flame_uid
bool is_lit It's used just to check, to light/extinguish use light_up function
nil light_up(bool lit)
ENT_TYPE get_flame_type()

TorchFlame

Derived from Entity Movable Flame

Type Name Description
ParticleEmitterInfo smoke_particle
ParticleEmitterInfo flame_particle
ParticleEmitterInfo warp_particle
float flame_size

TrapPart

Derived from Entity Movable

Type Name Description
Entity ceiling

Treasure

Derived from Entity Movable

Type Name Description
bool cashed spawns a dust effect and adds money for the total

TreasureHook

Derived from Entity Movable

Type Name Description
SoundMeta sound

TrueCrownPowerup

Derived from Entity Movable Powerup

Type Name Description
int timer

UdjatSocket

Derived from Entity Movable

Type Name Description
Entity fx_button

UnchainedSpikeBall

Derived from Entity Movable

Type Name Description
bool bounce

Ushabti

Derived from Entity Movable

Type Name Description
int wiggle_timer
int shine_timer

VanillaMovableBehavior

Opaque handle to a movable behavior from the vanilla game Derived from MovableBehavior

Type Name Description

VladsCape

Derived from Entity Movable Backpack Cape

Type Name Description
bool can_double_jump

WallTorch

Derived from Entity Movable Torch

Type Name Description
bool dropped_gold if false, it will drop gold when light up

Web

Derived from Entity Movable

Type Name Description
float decay_rate Is subtracted from the color alpha every frame after the stand_counter is more than 300.
Entity automatically dies when the alpha is less than 0.1

WebShot

Derived from Entity Movable Projectile

Type Name Description
bool shot if false, it's attached to the gun

WoodenlogTrap

Derived from Entity Movable

Type Name Description
int ceiling_1_uid
int ceiling_2_uid
float falling_speed

YellowCape

Derived from Entity Movable Backpack Cape

Type Name Description
SoundMeta sound

Events

Search script examples for set_callback

These events are used in set_callback to call your callback function before or after something happens in the game. The named events related to game screens generally run on the first engine update when changing to said screen. Coming back from the options screen does not fire the parent screen event though (OPTIONS to LEVEL for example). If you need more fine-grained control over the screen events, use SCREEN, PRE_LOAD_SCREEN and POST_LOAD_SCREEN with the help of the state.screen variables.

Search script examples for ON.LOGO

Runs when entering the the mossmouth logo screen.

ON.INTRO

Search script examples for ON.INTRO

Runs when entering the intro cutscene.

ON.PROLOGUE

Search script examples for ON.PROLOGUE

Runs when entering the prologue / poem.

ON.TITLE

Search script examples for ON.TITLE

Runs when entering the title screen.

ON.MENU

Search script examples for ON.MENU

Runs when entering the main menu.

ON.OPTIONS

Search script examples for ON.OPTIONS

Runs when entering the options menu.

ON.PLAYER_PROFILE

Search script examples for ON.PLAYER_PROFILE

Runs when entering the player profile screen.

ON.LEADERBOARD

Search script examples for ON.LEADERBOARD

Runs when entering the leaderboard screen.

ON.SEED_INPUT

Search script examples for ON.SEED_INPUT

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

ON.CHARACTER_SELECT

Search script examples for ON.CHARACTER_SELECT

Runs when entering the character select screen.

ON.TEAM_SELECT

Search script examples for ON.TEAM_SELECT

Runs when entering the team select screen of arena mode.

ON.CAMP

Search script examples for ON.CAMP

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

ON.LEVEL

Search script examples for ON.LEVEL

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

ON.TRANSITION

Search script examples for ON.TRANSITION

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

ON.DEATH

Search script examples for ON.DEATH

Runs when entering the death screen.

ON.SPACESHIP

Search script examples for ON.SPACESHIP

Runs when entering the olmecship cutscene after Tiamat.

ON.WIN

Search script examples for ON.WIN

Runs when entering any winning cutscene, including the constellation.

ON.CREDITS

Search script examples for ON.CREDITS

Runs when entering the credits screen.

ON.SCORES

Search script examples for ON.SCORES

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

ON.CONSTELLATION

Search script examples for ON.CONSTELLATION

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

ON.RECAP

Search script examples for ON.RECAP

Runs when entering the Dear Journal screen after final scores.

ON.ARENA_MENU

Search script examples for ON.ARENA_MENU

Runs when entering the main arena rules menu screen.

ON.ARENA_STAGES

Search script examples for ON.ARENA_STAGES

Runs when entering the arena stage selection screen.

ON.ARENA_ITEMS

Search script examples for ON.ARENA_ITEMS

Runs when entering the arena item config screen.

ON.ARENA_SELECT

Search script examples for ON.ARENA_SELECT

ON.ARENA_INTRO

Search script examples for ON.ARENA_INTRO

Runs when entering the arena VS intro screen.

ON.ARENA_MATCH

Search script examples for ON.ARENA_MATCH

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_SCORE

Search script examples for ON.ARENA_SCORE

Runs when entering the arena scores screen.

ON.ONLINE_LOADING

Search script examples for ON.ONLINE_LOADING

Runs when entering the online loading screen.

ON.ONLINE_LOBBY

Search script examples for ON.ONLINE_LOBBY

Runs when entering the online lobby screen.

ON.GUIFRAME

Search script examples for ON.GUIFRAME

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.FRAME

Search script examples for ON.FRAME

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

ON.GAMEFRAME

Search script examples for ON.GAMEFRAME

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

ON.SCREEN

Search script examples for ON.SCREEN

Runs whenever state.screen changes

ON.START

Search script examples for ON.START

Runs on the first ON.SCREEN of a run

ON.LOADING

Search script examples for ON.LOADING

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

ON.RESET

Search script examples for ON.RESET

Runs when resetting a run

ON.SAVE

Search script examples for ON.SAVE

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

ON.LOAD

Search script examples for ON.LOAD

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

ON.PRE_LOAD_LEVEL_FILES

Search script examples for ON.PRE_LOAD_LEVEL_FILES

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

ON.PRE_LEVEL_GENERATION

Search script examples for ON.PRE_LEVEL_GENERATION

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_SCREEN

Search script examples for ON.PRE_LOAD_SCREEN

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

ON.POST_ROOM_GENERATION

Search script examples for ON.POST_ROOM_GENERATION

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

ON.POST_LEVEL_GENERATION

Search script examples for ON.POST_LEVEL_GENERATION

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_SCREEN

Search script examples for ON.POST_LOAD_SCREEN

Runs right after a screen is loaded, before rendering anything

ON.PRE_GET_RANDOM_ROOM

Search script examples for ON.PRE_GET_RANDOM_ROOM

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_TILES

Search script examples for ON.PRE_HANDLE_ROOM_TILES

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 backlayer if not yet existant

ON.SCRIPT_ENABLE

Search script examples for ON.SCRIPT_ENABLE

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

ON.SCRIPT_DISABLE

Search script examples for ON.SCRIPT_DISABLE

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

ON.RENDER_PRE_HUD

Search script examples for ON.RENDER_PRE_HUD

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_POST_HUD

Search script examples for ON.RENDER_POST_HUD

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_PRE_PAUSE_MENU

Search script examples for ON.RENDER_PRE_PAUSE_MENU

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.RENDER_POST_PAUSE_MENU

Search script examples for ON.RENDER_POST_PAUSE_MENU

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_BACKGROUND

Search script examples for ON.RENDER_PRE_BLURRED_BACKGROUND

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_POST_BLURRED_BACKGROUND

-- replace journal book background with a piece of paper, drawn on top of the blurred bg
set_callback(function(ctx, blur)
    local src = Quad:new(AABB:new(0.535, 0.21, 0.85, 0.93))
    local dest = Quad:new(AABB:new(-1, 1, 1, -1))
    local col = Color:white()
    col.a = game_manager.journal_ui.opacity --or simply 'blur' to draw behind pause menu too
    ctx:draw_screen_texture(TEXTURE.DATA_TEXTURES_JOURNAL_TOP_MAIN_0, src, dest, col)
    -- hide real book offscreen, only drawing pages
    game_manager.journal_ui.book_background.y = 2
end, ON.RENDER_POST_BLURRED_BACKGROUND)

-- the previous cb is not called for death screen, default to normal book bg there
set_pre_render_screen(SCREEN.DEATH, function(ctx)
    game_manager.journal_ui.book_background.y = 0
end)

Search script examples for ON.RENDER_POST_BLURRED_BACKGROUND

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_PRE_DRAW_DEPTH

Search script examples for ON.RENDER_PRE_DRAW_DEPTH

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_POST_DRAW_DEPTH

Search script examples for ON.RENDER_POST_DRAW_DEPTH

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_PRE_JOURNAL_PAGE

Search script examples for ON.RENDER_PRE_JOURNAL_PAGE

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_POST_JOURNAL_PAGE

Search script examples for ON.RENDER_POST_JOURNAL_PAGE

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_PRE_LAYER

Search script examples for ON.RENDER_PRE_LAYER

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_POST_LAYER

Search script examples for ON.RENDER_POST_LAYER

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_PRE_LEVEL

Search script examples for ON.RENDER_PRE_LEVEL

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

ON.RENDER_POST_LEVEL

Search script examples for ON.RENDER_POST_LEVEL

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

ON.RENDER_PRE_GAME

Search script examples for ON.RENDER_PRE_GAME

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

ON.RENDER_POST_GAME

Search script examples for ON.RENDER_POST_GAME

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

ON.SPEECH_BUBBLE

Search script examples for ON.SPEECH_BUBBLE

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.TOAST

Search script examples for ON.TOAST

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.DEATH_MESSAGE

Search script examples for ON.DEATH_MESSAGE

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.PRE_LOAD_JOURNAL_CHAPTER

Search script examples for ON.PRE_LOAD_JOURNAL_CHAPTER

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.POST_LOAD_JOURNAL_CHAPTER

Search script examples for ON.POST_LOAD_JOURNAL_CHAPTER

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.PRE_GET_FEAT

Search script examples for ON.PRE_GET_FEAT

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_SET_FEAT

Search script examples for ON.PRE_SET_FEAT

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

ON.PRE_UPDATE

Search script examples for ON.PRE_UPDATE

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.POST_UPDATE

Search script examples for ON.POST_UPDATE

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

ON.USER_DATA

Search script examples for ON.USER_DATA

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.PRE_LEVEL_CREATION

Search script examples for ON.PRE_LEVEL_CREATION

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

ON.POST_LEVEL_CREATION

Search script examples for ON.POST_LEVEL_CREATION

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.PRE_LAYER_CREATION

Search script examples for ON.PRE_LAYER_CREATION

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.POST_LAYER_CREATION

Search script examples for ON.POST_LAYER_CREATION

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.PRE_LEVEL_DESTRUCTION

Search script examples for ON.PRE_LEVEL_DESTRUCTION

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.POST_LEVEL_DESTRUCTION

Search script examples for ON.POST_LEVEL_DESTRUCTION

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.PRE_LAYER_DESTRUCTION

Search script examples for ON.PRE_LAYER_DESTRUCTION

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.POST_LAYER_DESTRUCTION

Search script examples for ON.POST_LAYER_DESTRUCTION

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.PRE_PROCESS_INPUT

Search script examples for ON.PRE_PROCESS_INPUT

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.POST_PROCESS_INPUT

Search script examples for ON.POST_PROCESS_INPUT

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.PRE_GAME_LOOP

Search script examples for ON.PRE_GAME_LOOP

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

ON.POST_GAME_LOOP

Search script examples for ON.POST_GAME_LOOP

Runs right after the main engine loop.

ON.PRE_SAVE_STATE

Search script examples for ON.PRE_SAVE_STATE

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.POST_SAVE_STATE

Search script examples for ON.POST_SAVE_STATE

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.PRE_LOAD_STATE

Search script examples for ON.PRE_LOAD_STATE

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.POST_LOAD_STATE

Search script examples for ON.POST_LOAD_STATE

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.BLOCKED_UPDATE

Search script examples for ON.BLOCKED_UPDATE

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

ON.BLOCKED_GAME_LOOP

Search script examples for ON.BLOCKED_GAME_LOOP

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_INPUT

Search script examples for ON.BLOCKED_PROCESS_INPUT

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

Enums

Enums are like numbers but in text that's easier to remember.

set_callback(function()
    if state.theme == THEME.COSMIC_OCEAN then
        x, y, l = get_position(players[1].uid)
        spawn(ENT_TYPE.ITEM_JETPACK, x, y, l, 0, 0)
    end
end, ON.LEVEL)

BEG

Search script examples for BEG

Beg quest states

Name Data Description
QUEST_NOT_STARTED 0
ALTAR_DESTROYED 1
SPAWNED_WITH_BOMBBAG 2
BOMBBAG_THROWN 3
SPAWNED_WITH_TRUECROWN 4
TRUECROWN_THROWN 5

BUTTON

Search script examples for BUTTON

Name Data Description
JUMP 1
WHIP 2
BOMB 4
ROPE 8
RUN 16
DOOR 32

CAUSE_OF_DEATH

Search script examples for CAUSE_OF_DEATH

Name Data Description
DEATH 0
ENTITY 1
LONG_FALL 2
STILL_FALLING 3
MISSED 4
POISONED 5

CHAR_STATE

Search script examples for CHAR_STATE

Name Data Description
FLAILING 0
STANDING 1
SITTING 2
HANGING 4
DUCKING 5
CLIMBING 6
PUSHING 7
JUMPING 8
FALLING 9
DROPPING 10
ATTACKING 12
THROWING 17
STUNNED 18
ENTERING 19
LOADING 20
EXITING 21
DYING 22

CONST

Search script examples for CONST

Some arbitrary constants of the engine

Name Data Description
ENGINE_FPS 60 The framerate at which the engine updates, e.g. at which ON.GAMEFRAME and similar are called.
Independent of rendering framerate, so it does not correlate with the call rate of ON.GUIFRAME and similar.
ROOM_WIDTH 10 Width of a 1x1 room, both in world coordinates and in tiles.
ROOM_HEIGHT 8 Height of a 1x1 room, both in world coordinates and in tiles.
MAX_TILES_VERT g_level_max_y Maximum number of working floor tiles in vertical axis, 126 (0-125 coordinates)
Floors spawned above or below will not have any collision
MAX_TILES_HORIZ g_level_max_x Maximum number of working floor tiles in horizontal axis, 86 (0-85 coordinates)
Floors spawned above or below will not have any collision
NOF_DRAW_DEPTHS 53 Number of draw_depths, 53 (0-52)
MAX_PLAYERS 4 Just the max number of players in multiplayer

CORNER_FINISH

Search script examples for CORNER_FINISH

Name Data Description
NONE CORNER_FINISH::NONE Don't draw corner at all, will draw lines as separate pieces, overlapping etc.
REAL CORNER_FINISH::REAL Draws a real corner, no matter how far away the "peak" of the corner may end up being
CUT CORNER_FINISH::CUT Instead of drawing a sharp point at the end of the corner, it just cuts it flat
ADAPTIVE CORNER_FINISH::ADAPTIVE Default
similar to REAL but for low angles reduces the size of the "peak" of the corner

COSUBTHEME

Search script examples for COSUBTHEME

Parameter to force_co_subtheme

Name Data Description
NONE -1
RESET -1
DWELLING 0
JUNGLE 1
VOLCANA 2
TIDE_POOL 3
TEMPLE 4
ICE_CAVES 5
NEO_BABYLON 6
SUNKEN_CITY 7

DAMAGE_TYPE

Search script examples for DAMAGE_TYPE

16bit bitmask used in Movable::damage. Can be many things, like 0x2024 = hit by a burning object that was thrown by an explosion.

Name Data Description
GENERIC 0x1 enemy contact, rope hit, spikes(-1 damage), anubisshot, forcefield, dagger shot, spear trap...
WHIP 0x2
THROW 0x4 rock, bullet, monkey, yeti
ARROW 0x8
SWORD 0x10
FIRE 0x20 fire, fireball, lava
POISON 0x40 applies the status effect, not damage
POISON_TICK 0x80 actual damage from being poisoned for a while
CURSE 0x100 witchskull, catmummy directly, but not cloud
FALL 0x200
LASER 0x400 laser trap, ufo, not dagger
ICE_BREAK 0x800 damage or fall when frozen
STOMP 0x1000
EXPLOSION 0x2000 also from lava
VOODOO 0x4000

DRAW_LAYER

Search script examples for DRAW_LAYER

Name Data Description
BACKGROUND DRAW_LAYER::BACKGROUND
FOREGROUND DRAW_LAYER::FOREGROUND
WINDOW DRAW_LAYER::WINDOW

DROP

Search script examples for DROP

Name Data Description
ALTAR_DICE_CLIMBINGGLOVES 0
...see drops.cpp for a list of possible drops...
YETI_PITCHERSMITT 85

DROPCHANCE

Search script examples for DROPCHANCE

Name Data Description
BONEBLOCK_SKELETONKEY 0
...see drops.cpp for a list of possible dropchances...
YETI_PITCHERSMITT 10

DYNAMIC_TEXTURE

Search script examples for DYNAMIC_TEXTURE

Name Data Description
INVISIBLE DYNAMIC_TEXTURE::INVISIBLE
BACKGROUND DYNAMIC_TEXTURE::BACKGROUND
FLOOR DYNAMIC_TEXTURE::FLOOR
DOOR DYNAMIC_TEXTURE::DOOR
DOOR_LAYER DYNAMIC_TEXTURE::DOOR_LAYER
BACKGROUND_DECORATION DYNAMIC_TEXTURE::BACKGROUND_DECORATION
KALI_STATUE DYNAMIC_TEXTURE::KALI_STATUE
COFFIN DYNAMIC_TEXTURE::COFFIN

ENTITY_OVERRIDE

Search script examples for ENTITY_OVERRIDE

Name Data Description
DTOR 0
CREATE_RENDERING_INFO 1
UPDATE_STATE_MACHINE 2
KILL 3
ON_COLLISION1 4
DESTROY 5
CAN_BE_PUSHED 10
IS_IN_LIQUID 12
SET_INVISIBLE 15
FRICTION 17
GET_HELD_ENTITY 22
TRIGGER_ACTION 24
ACTIVATE 25
ON_COLLISION2 26
GET_METADATA 27
APPLY_METADATA 28
WALKED_ON 29
WALKED_OFF 30
LEDGE_GRAB 31
STOOD_ON 32
INIT 36
CAN_JUMP 37
STOMP_DAMAGE 43
IS_ON_FIRE 45
DAMAGE 48
ON_HIT 49
STUN 51
FREEZE 52
LIGHT_ON_FIRE 53
SET_CURSED 54
WEB_COLLISION 55
CHECK_OUT_OF_BOUNDS 58
STANDING_ON 60
STOMPED_BY 61
THROWN_BY 62
CLONED_TO 63
PICK_UP 67
PICKED_UP_BY 68
DROP 69
COLLECT_TREASURE 70
INITIALIZE 75
PROCESS_INPUT 78
PICKED_UP 80
FALL 83
APPLY_FRICTION 84
CRUSH 90
FLOOR_UPDATE 38
ENTER_ATTEMPT 40
HIDE_HUD 41
ENTER 42
LIGHT_LEVEL 44
IS_UNLOCKED 45
CAN_ENTER 46

ENT_FLAG

Search script examples for ENT_FLAG

Name Data Description
INVISIBLE 1
INDESTRUCTIBLE_OR_SPECIAL_FLOOR 2
SOLID 3
PASSES_THROUGH_OBJECTS 4
PASSES_THROUGH_EVERYTHING 5
TAKE_NO_DAMAGE 6
THROWABLE_OR_KNOCKBACKABLE 7
IS_PLATFORM 8
CLIMBABLE 9
NO_GRAVITY 10
INTERACT_WITH_WATER 11
STUNNABLE 12
COLLIDES_WALLS 13
INTERACT_WITH_SEMISOLIDS 14
CAN_BE_STOMPED 15
POWER_STOMPS 16
FACING_LEFT 17
PICKUPABLE 18
USABLE_ITEM 19
ENABLE_BUTTON_PROMPT 20
INTERACT_WITH_WEBS 21
LOCKED 22
SHOP_ITEM 23
SHOP_FLOOR 24
PASSES_THROUGH_PLAYER 25
PAUSE_AI_AND_PHYSICS 28
DEAD 29
HAS_BACKITEM 32

ENT_MORE_FLAG

Search script examples for ENT_MORE_FLAG

Name Data Description
HIRED_HAND_REVIVED 2
SWIMMING 11
HIT_GROUND 12
HIT_WALL 13
FALLING 14
CURSED_EFFECT 15
ELIXIR_BUFF 16
DISABLE_INPUT 17

ENT_TYPE

Search script examples for ENT_TYPE

Name Data Description
FLOOR_BORDERTILE 1
...check entities.txt...
LIQUID_COARSE_LAVA 915

FADE

Search script examples for FADE

Name Data Description
NONE 0
OUT 1
LOAD 2
IN 3

FLOOR_SIDE

Search script examples for FLOOR_SIDE

Name Data Description
TOP FLOOR_SIDE::TOP
BOTTOM FLOOR_SIDE::BOTTOM
LEFT FLOOR_SIDE::LEFT
RIGHT FLOOR_SIDE::RIGHT
TOP_LEFT FLOOR_SIDE::TOP_LEFT
TOP_RIGHT FLOOR_SIDE::TOP_RIGHT
BOTTOM_LEFT FLOOR_SIDE::BOTTOM_LEFT
BOTTOM_RIGHT FLOOR_SIDE::BOTTOM_RIGHT

GAMEPAD

Search script examples for GAMEPAD

Name Data Description
UP 0x0001
DOWN 0x0002
LEFT 0x0004
RIGHT 0x0008
START 0x0010
BACK 0x0020
LEFT_THUMB 0x0040
RIGHT_THUMB 0x0080
LEFT_SHOULDER 0x0100
RIGHT_SHOULDER 0x0200
A 0x1000
B 0x2000
X 0x4000
Y 0x8000

GAMEPAD_FLAG

Search script examples for GAMEPAD_FLAG

Name Data Description
UP 1
DOWN 2
LEFT 3
RIGHT 4
START 5
BACK 6
LEFT_THUMB 7
RIGHT_THUMB 8
LEFT_SHOULDER 9
RIGHT_SHOULDER 10
A 13
B 14
X 15
Y 16

GAME_SETTING

Search script examples for GAME_SETTING

Name Data Description
WINDOW_SCALE 0
...check game_settings.txt...
CROSSPROGRESS_AUTOSYNC 47

GHOST_BEHAVIOR

Search script examples for GHOST_BEHAVIOR

Name Data Description
SAD GHOST_BEHAVIOR::SAD
MEDIUM_SAD GHOST_BEHAVIOR::MEDIUM_SAD
MEDIUM_HAPPY GHOST_BEHAVIOR::MEDIUM_HAPPY
SMALL_ANGRY GHOST_BEHAVIOR::SMALL_ANGRY
SMALL_SURPRISED GHOST_BEHAVIOR::SMALL_SURPRISED
SMALL_SAD GHOST_BEHAVIOR::SMALL_SAD
SMALL_HAPPY GHOST_BEHAVIOR::SMALL_HAPPY

HOTKEY_TYPE

Search script examples for HOTKEY_TYPE

Name Data Description
NORMAL HOTKEY_TYPE::NORMAL Suppressed when the game window is inactive or inputting text in this tool instance (get_io().wantkeyboard == true). Can't detect if OL is in a text input and script is running in PL though. Use ImGuiIO if you need to do that.
GLOBAL HOTKEY_TYPE::GLOBAL Enabled even when the game window is inactive and will capture keys even from other programs.
INPUT HOTKEY_TYPE::INPUT Enabled even when inputting text and will override normal text input keys.

HUNDUNFLAGS

Search script examples for HUNDUNFLAGS

Name Data Description
WILLMOVELEFT 1
BIRDHEADEMERGED 2
SNAKEHEADEMERGED 4
TOPLEVELARENAREACHED 8
BIRDHEADSHOTLAST 16

INPUTS

Search script examples for INPUTS

Name Data Description
NONE 0x0
JUMP 0x1
WHIP 0x2
BOMB 0x4
ROPE 0x8
RUN 0x10
DOOR 0x20
MENU 0x40
JOURNAL 0x80
LEFT 0x100
RIGHT 0x200
UP 0x400
DOWN 0x800

INPUT_FLAG

Search script examples for INPUT_FLAG

Name Data Description
JUMP 1
WHIP 2
BOMB 3
ROPE 4
RUN 5
DOOR 6
MENU 7
JOURNAL 8
LEFT 9
RIGHT 10
UP 11
DOWN 12

JOURNALUI_PAGE_SHOWN

Search script examples for JOURNALUI_PAGE_SHOWN

Name Data Description
PLAYER_PROFILE 1
JOURNAL 2
PLACES 3
PEOPLE 4
BESTIARY 5
ITEMS 6
TRAPS 7
STORY 8
FEATS 9
RECAP 10
DEATH 11

JOURNALUI_STATE

Search script examples for JOURNALUI_STATE

Name Data Description
INVISIBLE 0
FADING_IN 1
STABLE 2
FLIPPING_LEFT 3
FLIPPING_RIGHT 4
FADING_OUT 5

JOURNAL_FLAG

Search script examples for JOURNAL_FLAG

Name Data Description
PACIFIST 1
VEGAN 2
VEGETARIAN 3
PETTY_CRIMINAL 4
WANTED_CRIMINAL 5
CRIME_LORD 6
KING 7
QUEEN 8
FOOL 9
EGGPLANT 10
NO_GOLD 11
LIKED_PETS 12
LOVED_PETS 13
TOOK_DAMAGE 14
ANKH 15
KINGU 16
OSIRIS 17
TIAMAT 18
HUNDUN 19
COSMOS 20
DIED 21

JOURNAL_PAGE_TYPE

Search script examples for JOURNAL_PAGE_TYPE

Name Data Description
PROGRESS JournalPageType::Progress
JOURNAL_MENU JournalPageType::JournalMenu
PLACES JournalPageType::Places
PEOPLE JournalPageType::People
BESTIARY JournalPageType::Bestiary
ITEMS JournalPageType::Items
TRAPS JournalPageType::Traps
STORY JournalPageType::Story
FEATS JournalPageType::Feats
DEATH_CAUSE JournalPageType::DeathCause
DEATH_MENU JournalPageType::DeathMenu
RECAP JournalPageType::Recap
PLAYER_PROFILE JournalPageType::PlayerProfile
LAST_GAME_PLAYED JournalPageType::LastGamePlayed

JUNGLESISTERS

Search script examples for JUNGLESISTERS

Jungle sister quest flags (angry = -1)

Name Data Description
PARSLEY_RESCUED 1
PARSNIP_RESCUED 2
PARMESAN_RESCUED 3
WARNING_ONE_WAY_DOOR 4
GREAT_PARTY_HUH 5
I_WISH_BROUGHT_A_JACKET 6

KEY

Search script examples for KEY

Name Data Description
A 65
...check lua_enums.txt...

KEY_TYPE

Search script examples for KEY_TYPE

Name Data Description
ANY KEY_TYPE::ANY
KEYBOARD KEY_TYPE::KEYBOARD
MOUSE KEY_TYPE::MOUSE

LAYER

Search script examples for LAYER

Name Data Description
FRONT 0
BACK 1
PLAYER -1
PLAYER1 -1
PLAYER2 -2
PLAYER3 -3
PLAYER4 -4
BOTH -128

LEVEL_CONFIG

Search script examples for LEVEL_CONFIG

Use with get_level_config

Name Data Description
BACK_ROOM_CHANCE 0
BACK_ROOM_INTERCONNECTION_CHANCE 1
BACK_ROOM_HIDDEN_DOOR_CHANCE 2
BACK_ROOM_HIDDEN_DOOR_CACHE_CHANCE 3
MOUNT_CHANCE 4
ALTAR_ROOM_CHANCE 5
IDOL_ROOM_CHANCE 6
FLOOR_SIDE_SPREAD_CHANCE 7
FLOOR_BOTTOM_SPREAD_CHANCE 8
BACKGROUND_CHANCE 9
GROUND_BACKGROUND_CHANCE 10
MACHINE_BIGROOM_CHANCE 11
MACHINE_WIDEROOM_CHANCE 12
MACHINE_TALLROOM_CHANCE 13
MACHINE_REWARDROOM_CHANCE 14
MAX_LIQUID_PARTICLES 15
FLAGGED_LIQUID_ROOMS 16

LIGHT_TYPE

Search script examples for LIGHT_TYPE

Name Data Description
NONE LIGHT_TYPE::NONE Normal static light, position can be edited to move it around
FOLLOW_CAMERA LIGHT_TYPE::FOLLOW_CAMERA Position is updated to the camera position, can be moved around via offset
FOLLOW_ENTITY LIGHT_TYPE::FOLLOW_ENTITY Position is updated to the entity position (from the uid field), if the uid is not found it will behave as LIGHT_TYPE.NONE, can be moved around via offset
ROOM_LIGHT LIGHT_TYPE::ROOM_LIGHT Rectangle, full brightness always uses light1, disabling light1 does nothing

LIQUID_POOL

Search script examples for LIQUID_POOL

Name Data Description
WATER 1
COARSE_WATER 2
LAVA 3
COARSE_LAVA 4
STAGNANT_LAVA 5

LOGIC

Search script examples for LOGIC

Name Data Description
TUTORIAL LOGIC::TUTORIAL
OUROBOROS LOGIC::OUROBOROS
SPEEDRUN LOGIC::SPEEDRUN
GHOST LOGIC::GHOST
GHOST_TOAST LOGIC::GHOST_TOAST
TUN_AGGRO LOGIC::TUN_AGGRO
DICESHOP LOGIC::DICESHOP
PRE_CHALLENGE LOGIC::PRE_CHALLENGE
MOON_CHALLENGE LOGIC::MOON_CHALLENGE
STAR_CHALLENGE LOGIC::STAR_CHALLENGE
SUN_CHALLENGE LOGIC::SUN_CHALLENGE
MAGMAMAN_SPAWN LOGIC::MAGMAMAN_SPAWN
WATER_BUBBLES LOGIC::WATER_BUBBLES
OLMEC_CUTSCENE LOGIC::OLMEC_CUTSCENE
TIAMAT_CUTSCENE LOGIC::TIAMAT_CUTSCENE
APEP LOGIC::APEP
COG_SACRIFICE LOGIC::COG_SACRIFICE
DUAT_BOSSES LOGIC::DUAT_BOSSES
BUBBLER LOGIC::BUBBLER
PLEASURE_PALACE LOGIC::PLEASURE_PALACE
DISCOVERY_INFO LOGIC::DISCOVERY_INFO
BLACK_MARKET LOGIC::BLACK_MARKET
JELLYFISH LOGIC::JELLYFISH
ARENA_1 LOGIC::ARENA_1
ARENA_2 LOGIC::ARENA_2
ARENA_3 LOGIC::ARENA_3
ARENA_ALIEN_BLAST LOGIC::ARENA_ALIEN_BLAST
ARENA_LOOSE_BOMBS LOGIC::ARENA_LOOSE_BOMBS

MASK

Search script examples for MASK

Name Data Description
PLAYER 0x1 All CHAR_* entities, only Player type
MOUNT 0x2 All MOUNT_* entities, only Mount type
MONSTER 0x4 All MONS_* entities, various types, all Movable
ITEM 0x8 All ITEM_* entities except: ITEM_POWERUP_*, ITEM_ROPE, ITEM_CLIMBABLE_ROPE, ITEM_UNROLLED_ROPE, ITEM_RUBBLE, ITEM_FLAMETHROWER_FIREBALL, ITEM_CURSING_CLOUD
Also includes: FX_JETPACKFLAME, FX_OLMECPART_FLOATER, FX_SMALLFLAME, FX_TELEPORTSHADOW
Various types, all Movable
EXPLOSION 0x10 Only: FX_EXPLOSION, FX_POWEREDEXPLOSION, FX_MODERNEXPLOSION
All Explosion type
ROPE 0x20 Only: ITEM_ROPE, ITEM_CLIMBABLE_ROPE, ITEM_UNROLLED_ROPE
Various types, all Movable
FX 0x40 All FX_* entities except: FX_COMPASS, FX_SPECIALCOMPASS, FX_EXPLOSION, FX_POWEREDEXPLOSION, FX_MODERNEXPLOSION, FX_JETPACKFLAME, FX_OLMECPART_FLOATER, FX_SMALLFLAME, FX_TELEPORTSHADOW, FX_LEADER_FLAG, FX_PLAYERINDICATOR, FX_PLAYERINDICATORPORTRAIT
Also includes: DECORATION_CHAINANDBLOCKS_CHAINDECORATION, DECORATION_SLIDINGWALL_CHAINDECORATION, ITEM_RUBBLE, ITEM_FLAMETHROWER_FIREBALL, ITEM_CURSING_CLOUD
Various types, all Movable
ACTIVEFLOOR 0x80 All ACTIVEFLOOR_* entities
Various types, all Movable
FLOOR 0x100 All FLOOR_* and FLOORSTYLED_* entities
Various types, all Floor
DECORATION 0x200 All DECORATION_* entities except: DECORATION_CHAINANDBLOCKS_CHAINDECORATION, DECORATION_SLIDINGWALL_CHAINDECORATION, DECORATION_PALACE_PORTRAIT
Also includes: EMBED_GOLD, ENT_TYPE_EMBED_GOLD_BIG
Various types, all Entity
BG 0x400 All MIDBG* entities and most of the BG_* entities
does not include: a lot .. check default_flags_more_flags.txt for full list
Also includes: DECORATION_PALACE_PORTRAIT
Various types, all Entity
SHADOW 0x800 All the BG_* entities excluded from BG (MASK.BG | MASK.SHADOW) will get you all BG_* entities plus one extra decoration mentioned above
Various types, all Entity
LOGICAL 0x1000 All LOGICAL_* entities
Also includes: ITEM_POWERUP_*, FX_COMPASS, FX_SPECIALCOMPASS, FX_LEADER_FLAG, FX_PLAYERINDICATOR, FX_PLAYERINDICATORPORTRAIT
Various types, all Entity
WATER 0x2000 Only: LIQUID_WATER, LIQUID_COARSE_WATER, LIQUID_IMPOSTOR_LAKE
Various types, all Entity
LAVA 0x4000 Only: LIQUID_LAVA, LIQUID_STAGNANT_LAVA, LIQUID_IMPOSTOR_LAVA, LIQUID_COARSE_LAVA
Various types, all Entity
LIQUID 0x6000 Short for (MASK.WATER | MASK.LAVA)
ANY 0x0 Value of 0, treated by all the functions as ANY mask

Search script examples for MENU_INPUT

Name Data Description
NONE 0x0
SELECT 0x1
BACK 0x2
DELETE 0x4
RANDOM 0x8
JOURNAL 0x10
LEFT 0x20
RIGHT 0x40
UP 0x80
DOWN 0x100

ON

Search script examples for ON

Name Data Description
LOGO ON::LOGO Runs when entering the the mossmouth logo screen.
INTRO ON::INTRO Runs when entering the intro cutscene.
PROLOGUE ON::PROLOGUE Runs when entering the prologue / poem.
TITLE ON::TITLE Runs when entering the title screen.
MENU ON::MENU Runs when entering the main menu.
OPTIONS ON::OPTIONS Runs when entering the options menu.
PLAYER_PROFILE ON::PLAYER_PROFILE Runs when entering the player profile screen.
LEADERBOARD ON::LEADERBOARD Runs when entering the leaderboard screen.
SEED_INPUT ON::SEED_INPUT Runs when entering the seed input screen of a seeded run.
CHARACTER_SELECT ON::CHARACTER_SELECT Runs when entering the character select screen.
TEAM_SELECT ON::TEAM_SELECT Runs when entering the team select screen of arena mode.
CAMP ON::CAMP Runs when entering the camp, after all entities have spawned, on the first level frame.
LEVEL ON::LEVEL Runs when entering any level, after all entities have spawned, on the first level frame.
TRANSITION ON::TRANSITION Runs when entering the transition screen, after all entities have spawned.
DEATH ON::DEATH Runs when entering the death screen.
SPACESHIP ON::SPACESHIP Runs when entering the olmecship cutscene after Tiamat.
WIN ON::WIN Runs when entering any winning cutscene, including the constellation.
CREDITS ON::CREDITS Runs when entering the credits screen.
SCORES ON::SCORES Runs when entering the final score celebration screen of a normal or hard ending.
CONSTELLATION ON::CONSTELLATION Runs when entering the turning into constellation cutscene after cosmic ocean.
RECAP ON::RECAP Runs when entering the Dear Journal screen after final scores.
ARENA_MENU ON::ARENA_MENU Runs when entering the main arena rules menu screen.
ARENA_STAGES ON::ARENA_STAGES Runs when entering the arena stage selection screen.
ARENA_ITEMS ON::ARENA_ITEMS Runs when entering the arena item config screen.
ARENA_SELECT ON::ARENA_SELECT
ARENA_INTRO ON::ARENA_INTRO Runs when entering the arena VS intro screen.
ARENA_MATCH ON::ARENA_MATCH Runs when entering the arena level screen, after all entities have spawned, on the first level frame, before the get ready go scene.
ARENA_SCORE ON::ARENA_SCORE Runs when entering the arena scores screen.
ONLINE_LOADING ON::ONLINE_LOADING Runs when entering the online loading screen.
ONLINE_LOBBY ON::ONLINE_LOBBY Runs when entering the online lobby screen.
GUIFRAME ON::GUIFRAME 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
FRAME ON::FRAME Runs while playing the game while the player is controllable, not in the base camp or the arena mode
GAMEFRAME ON::GAMEFRAME Runs whenever the game engine is actively running. This includes base camp, arena, level transition and death screen
SCREEN ON::SCREEN Runs whenever state.screen changes
START ON::START Runs on the first ON.SCREEN of a run
LOADING ON::LOADING Runs whenever state.loading changes and is > 0. Prefer PRE/POST_LOAD_SCREEN instead though.
RESET ON::RESET Runs when resetting a run
SAVE ON::SAVE Params: SaveContext save_ctx
Runs at the same times as ON.SCREEN, but receives the save_ctx
LOAD ON::LOAD Params: LoadContext load_ctx
Runs as soon as your script is loaded, including reloads, then never again
PRE_LOAD_LEVEL_FILES ON::PRE_LOAD_LEVEL_FILES Params: PreLoadLevelFilesContext load_level_ctx
Runs right before level files would be loaded
PRE_LEVEL_GENERATION ON::PRE_LEVEL_GENERATION 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.
PRE_LOAD_SCREEN ON::PRE_LOAD_SCREEN Runs right before loading a new screen based on screen_next. Return true from callback to block the screen from loading.
POST_ROOM_GENERATION ON::POST_ROOM_GENERATION Params: PostRoomGenerationContext room_gen_ctx
Runs right after all rooms are generated before entities are spawned
POST_LEVEL_GENERATION ON::POST_LEVEL_GENERATION 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.
POST_LOAD_SCREEN ON::POST_LOAD_SCREEN Runs right after a screen is loaded, before rendering anything
PRE_GET_RANDOM_ROOM ON::PRE_GET_RANDOM_ROOM 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.
PRE_HANDLE_ROOM_TILES ON::PRE_HANDLE_ROOM_TILES 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 backlayer if not yet existant
SCRIPT_ENABLE ON::SCRIPT_ENABLE Runs when the script is enabled from the UI or when imported by another script while disabled, but not on load.
SCRIPT_DISABLE ON::SCRIPT_DISABLE Runs when the script is disabled from the UI and also right before unloading/reloading.
RENDER_PRE_HUD ON::RENDER_PRE_HUD 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.
RENDER_POST_HUD ON::RENDER_POST_HUD 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
RENDER_PRE_PAUSE_MENU ON::RENDER_PRE_PAUSE_MENU 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.
RENDER_POST_PAUSE_MENU ON::RENDER_POST_PAUSE_MENU 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
RENDER_PRE_BLURRED_BACKGROUND ON::RENDER_PRE_BLURRED_BACKGROUND 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.
RENDER_POST_BLURRED_BACKGROUND ON::RENDER_POST_BLURRED_BACKGROUND 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)
RENDER_PRE_DRAW_DEPTH ON::RENDER_PRE_DRAW_DEPTH 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.
RENDER_POST_DRAW_DEPTH ON::RENDER_POST_DRAW_DEPTH 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
RENDER_PRE_JOURNAL_PAGE ON::RENDER_PRE_JOURNAL_PAGE 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.
RENDER_POST_JOURNAL_PAGE ON::RENDER_POST_JOURNAL_PAGE 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()
RENDER_PRE_LAYER ON::RENDER_PRE_LAYER 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.
RENDER_POST_LAYER ON::RENDER_POST_LAYER 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
RENDER_PRE_LEVEL ON::RENDER_PRE_LEVEL Params: VanillaRenderContext render_ctx, int camera_layer
Runs before the level is rendered. Return true to skip rendering.
RENDER_POST_LEVEL ON::RENDER_POST_LEVEL Params: VanillaRenderContext render_ctx, int camera_layer
Runs after the level is rendered, before hud
RENDER_PRE_GAME ON::RENDER_PRE_GAME Params: VanillaRenderContext render_ctx
Runs before the ingame part of the game is rendered. Return true to skip rendering.
RENDER_POST_GAME ON::RENDER_POST_GAME Params: VanillaRenderContext render_ctx
Runs after the level and HUD are rendered, before pause menus and blur effects
SPEECH_BUBBLE ON::SPEECH_BUBBLE 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
TOAST ON::TOAST 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
DEATH_MESSAGE ON::DEATH_MESSAGE 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.
PRE_LOAD_JOURNAL_CHAPTER ON::PRE_LOAD_JOURNAL_CHAPTER 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)
POST_LOAD_JOURNAL_CHAPTER ON::POST_LOAD_JOURNAL_CHAPTER 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 ...
PRE_GET_FEAT ON::PRE_GET_FEAT 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.
PRE_SET_FEAT ON::PRE_SET_FEAT Runs before the game sets a vanilla feat performed.
Return: true to block the default behaviour of calling Steam SetAchievement.
PRE_UPDATE ON::PRE_UPDATE 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)
POST_UPDATE ON::POST_UPDATE Runs right after the State is updated, runs always (menu, settings, camp, game, arena, online etc.) with the game engine, typically 60FPS
USER_DATA ON::USER_DATA 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.
PRE_LEVEL_CREATION ON::PRE_LEVEL_CREATION Runs right before the front layer is created. Runs in all screens that usually have entities, or when creating a layer manually.
POST_LEVEL_CREATION ON::POST_LEVEL_CREATION 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.
PRE_LAYER_CREATION ON::PRE_LAYER_CREATION Params: LAYER layer
Runs right before a layer is created. Runs in all screens that usually have entities, or when creating a layer manually.
POST_LAYER_CREATION ON::POST_LAYER_CREATION 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.
PRE_LEVEL_DESTRUCTION ON::PRE_LEVEL_DESTRUCTION 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.
POST_LEVEL_DESTRUCTION ON::POST_LEVEL_DESTRUCTION 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.
PRE_LAYER_DESTRUCTION ON::PRE_LAYER_DESTRUCTION 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.
POST_LAYER_DESTRUCTION ON::POST_LAYER_DESTRUCTION 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.
PRE_PROCESS_INPUT ON::PRE_PROCESS_INPUT 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.
POST_PROCESS_INPUT ON::POST_PROCESS_INPUT 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.
PRE_GAME_LOOP ON::PRE_GAME_LOOP Runs right before the main engine loop. Return true to block state updates and menu updates, i.e. to pause inside menus.
POST_GAME_LOOP ON::POST_GAME_LOOP Runs right after the main engine loop.
PRE_SAVE_STATE ON::PRE_SAVE_STATE 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
POST_SAVE_STATE ON::POST_SAVE_STATE 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
PRE_LOAD_STATE ON::PRE_LOAD_STATE 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
POST_LOAD_STATE ON::POST_LOAD_STATE 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
BLOCKED_UPDATE ON::BLOCKED_UPDATE Runs instead of POST_UPDATE when anything blocks a PRE_UPDATE. Even runs in Playlunky when Overlunky blocks a PRE_UPDATE.
BLOCKED_GAME_LOOP ON::BLOCKED_GAME_LOOP Runs instead of POST_GAME_LOOP when anything blocks a PRE_GAME_LOOP. Even runs in Playlunky when Overlunky blocks a PRE_GAME_LOOP.
BLOCKED_PROCESS_INPUT ON::BLOCKED_PROCESS_INPUT Runs instead of POST_PROCESS_INPUT when anything blocks a PRE_PROCESS_INPUT. Even runs in Playlunky when Overlunky blocks a PRE_PROCESS_INPUT.

PARTICLEEMITTER

Search script examples for PARTICLEEMITTER

Name Data Description
TITLE_TORCHFLAME_SMOKE 1
...check particle_emitters.txt...
MINIGAME_BROKENASTEROID_SMOKE 219

PAUSE

Search script examples for PAUSE

8bit bitmask used in state.pause

Name Data Description
MENU 0x01 Menu: Pauses the level timer and engine. Can't set, controller by the menu.
FADE 0x02 Fade/Loading: Pauses all timers and engine.
CUTSCENE 0x04 Cutscene: Pauses total/level time but not engine. Used by boss cutscenes.
FLAG4 0x08 Unknown purpose: Pauses total/level time and engine. Does not pause the global counter so set_global_interval timers still run. Might change this later!
FLAG5 0x10 Unknown purpose: Pauses total/level time and engine. Does not pause the global counter so set_global_interval timers still run. Might change this later!
ANKH 0x20 Ankh: Pauses all timers, physics and music, but not camera. Used by the ankh cutscene.

PAUSEUI_VISIBILITY

Search script examples for PAUSEUI_VISIBILITY

Name Data Description
INVISIBLE 0
SLIDING_DOWN 1
VISIBLE 2
SLIDING_UP 3

PAUSE_SCREEN

Search script examples for PAUSE_SCREEN

Used in PauseAPI

Name Data Description
NONE PAUSE_SCREEN::NONE
LOGO PAUSE_SCREEN::LOGO
INTRO PAUSE_SCREEN::INTRO
PROLOGUE PAUSE_SCREEN::PROLOGUE
TITLE PAUSE_SCREEN::TITLE
MENU PAUSE_SCREEN::MENU
OPTIONS PAUSE_SCREEN::OPTIONS
PLAYER_PROFILE PAUSE_SCREEN::PLAYER_PROFILE
LEADERBOARD PAUSE_SCREEN::LEADERBOARD
SEED_INPUT PAUSE_SCREEN::SEED_INPUT
CHARACTER_SELECT PAUSE_SCREEN::CHARACTER_SELECT
TEAM_SELECT PAUSE_SCREEN::TEAM_SELECT
CAMP PAUSE_SCREEN::CAMP
LEVEL PAUSE_SCREEN::LEVEL
TRANSITION PAUSE_SCREEN::TRANSITION
DEATH PAUSE_SCREEN::DEATH
SPACESHIP PAUSE_SCREEN::SPACESHIP
WIN PAUSE_SCREEN::WIN
CREDITS PAUSE_SCREEN::CREDITS
SCORES PAUSE_SCREEN::SCORES
CONSTELLATION PAUSE_SCREEN::CONSTELLATION
RECAP PAUSE_SCREEN::RECAP
ARENA_MENU PAUSE_SCREEN::ARENA_MENU
ARENA_STAGES PAUSE_SCREEN::ARENA_STAGES
ARENA_ITEMS PAUSE_SCREEN::ARENA_ITEMS
ARENA_SELECT PAUSE_SCREEN::ARENA_SELECT
ARENA_INTRO PAUSE_SCREEN::ARENA_INTRO
ARENA_LEVEL PAUSE_SCREEN::ARENA_LEVEL
ARENA_SCORE PAUSE_SCREEN::ARENA_SCORE
ONLINE_LOADING PAUSE_SCREEN::ONLINE_LOADING
ONLINE_LOBBY PAUSE_SCREEN::ONLINE_LOBBY
LOADING PAUSE_SCREEN::LOADING
EXIT PAUSE_SCREEN::EXIT

PAUSE_TRIGGER

Search script examples for PAUSE_TRIGGER

Used in PauseAPI

Name Data Description
NONE PAUSE_TRIGGER::NONE
FADE_START PAUSE_TRIGGER::FADE_START
FADE_END PAUSE_TRIGGER::FADE_END
SCREEN PAUSE_TRIGGER::SCREEN
ONCE PAUSE_TRIGGER::ONCE
EXIT PAUSE_TRIGGER::EXIT

PAUSE_TYPE

Search script examples for PAUSE_TYPE

Used in PauseAPI

Name Data Description
NONE PAUSE_TYPE::NONE
MENU PAUSE_TYPE::MENU
FADE PAUSE_TYPE::FADE
CUTSCENE PAUSE_TYPE::CUTSCENE
FLAG4 PAUSE_TYPE::FLAG4
FLAG5 PAUSE_TYPE::FLAG5
ANKH PAUSE_TYPE::ANKH
PRE_UPDATE PAUSE_TYPE::PRE_UPDATE
PRE_GAME_LOOP PAUSE_TYPE::PRE_GAME_LOOP
PRE_PROCESS_INPUT PAUSE_TYPE::PRE_PROCESS_INPUT
FORCE_STATE PAUSE_TYPE::FORCE_STATE

POS_TYPE

Search script examples for POS_TYPE

Name Data Description
FLOOR POS_TYPE::FLOOR On top of solid floor
CEILING POS_TYPE::CEILING Below solid ceiling
AIR POS_TYPE::AIR Is a non-solid tile (no need to explicitly add this to everything)
WALL POS_TYPE::WALL Next to a wall
ALCOVE POS_TYPE::ALCOVE Has a floor, ceiling and exactly one wall
PIT POS_TYPE::PIT Has a floor, two walls and no ceiling
HOLE POS_TYPE::HOLE Air pocket surrounded by floors
WATER POS_TYPE::WATER Is in water (otherwise assumed not in water)
LAVA POS_TYPE::LAVA Is in lava (otherwise assumed not in lava)
SAFE POS_TYPE::SAFE Avoid hazards, like certain traps, shops and any special floor
EMPTY POS_TYPE::EMPTY Has nothing but decoration and background in it
SOLID POS_TYPE::SOLID Is inside solid floor or activefloor
DEFAULT POS_TYPE::DEFAULT FLOOR
WALL_LEFT POS_TYPE::WALL_LEFT Next to a wall on the left
WALL_RIGHT POS_TYPE::WALL_RIGHT Next to a wall on the right

PRESENCE_FLAG

Search script examples for PRESENCE_FLAG

Name Data Description
UDJAT_EYE 1
BLACK_MARKET 2
VLADS_CASTLE 3
DRILL 3
MOON_CHALLENGE 9
STAR_CHALLENGE 10
SUN_CHALLENGE 11

PRNG_CLASS

Search script examples for PRNG_CLASS

Determines what class of prng is used, which in turn determines which parts of the game's future prng is affected. See more info at PRNG
For example when choosing PRNG_CLASS.PROCEDURAL_SPAWNS to generate a random number, random Tiamat spawns will not be affected.
Any integer in the range [0, 9] is a valid class, some are however not documented because of missing information.

Name Data Description
PROCEDURAL_SPAWNS PRNG::PROCEDURAL_SPAWNS Anything level gen related really, including but not limited to path, room and enemy placement.
PARTICLES PRNG::PARTICLES Direction and angle of torch flames etc, but also includes other things not related to particles at all...
ENTITY_VARIATION PRNG::ENTITY_VARIATION Some entities that have many texture to choose from on spawn
EXTRA_SPAWNS PRNG::EXTRA_SPAWNS
LEVEL_DECO PRNG::LEVEL_DECO I have no idea what this name means, cause this seems to advance every 3 or so frames even with zero entities in a level
LIQUID PRNG::LIQUID Liquid movement
AI PRNG::EXTRA_SPAWNS Monster AI decisions
LEVEL_GEN PRNG::PROCEDURAL_SPAWNS Anything level gen related really, including but not limited to path, room and enemy placement.
FX PRNG::FX Some effects, like water splashes, background stars and teleport shadow
CHAR_AI PRNG::CHAR_AI Character AI decisions

PROCEDURAL_CHANCE

Search script examples for PROCEDURAL_CHANCE

Name Data Description
ARROWTRAP_CHANCE 0
...check spawn_chances.txt...

QUEST_FLAG

Search script examples for QUEST_FLAG

Name Data Description
RESET 1
DARK_LEVEL_SPAWNED 2
VAULT_SPAWNED 3
SPAWN_OUTPOST 4
SHOP_SPAWNED 5
SHORTCUT_USED 6
SEEDED 7
DAILY 8
CAVEMAN_SHOPPIE_AGGROED 9
WADDLER_AGGROED 10
SHOP_BOUGHT_OUT 11
EGGPLANT_CROWN_PICKED_UP 12
UDJAT_EYE_SPAWNED 17
BLACK_MARKET_SPAWNED 18
DRILL_SPAWNED 19
MOON_CHALLENGE_SPAWNED 25
STAR_CHALLENGE_SPAWNED 26
SUN_CHALLENGE_SPAWNED 27

RAW_BUTTON

Search script examples for RAW_BUTTON

Name Data Description
UP 0
DOWN 1
LEFT 2
RIGHT 3
A 4
B 5
X 6
Y 7
LEFT_SHOULDER 8
RIGHT_SHOULDER 9
LEFT_TRIGGER 10
RIGHT_TRIGGER 11
LEFT_THUMB 12
RIGHT_THUMB 13
BACK 14
START 15

RAW_DUALSHOCK

Search script examples for RAW_DUALSHOCK

Name Data Description
UP 0
DOWN 1
LEFT 2
RIGHT 3
CROSS 4
CIRCLE 5
SQUARE 6
TRIANGLE 7
L1 8
R1 9
L2 10
R2 11
L3 12
R3 13
SHARE 14
OPTIONS 15

RAW_KEY

Search script examples for RAW_KEY

Name Data Description
UP 1
...check lua_enums.txt...

RECURSIVE_MODE

Search script examples for RECURSIVE_MODE

Name Data Description
EXCLUSIVE RECURSIVE_MODE::EXCLUSIVE In this mode the provided ENT_TYPE and MASK will not be affected nor will entities attached to them
INCLUSIVE RECURSIVE_MODE::INCLUSIVE In this mode the provided ENT_TYPE and MASK will be the only affected entities, anything outside of the specified mask or type will not be touched including entities attached to them
For this mode you have to specify at least one mask or ENT_TYPE, otherwise nothing will be affected
NONE RECURSIVE_MODE::NONE Ignores provided ENT_TYPE and MASK and affects all the entities

RENDER_INFO_OVERRIDE

Search script examples for RENDER_INFO_OVERRIDE

Name Data Description
DTOR 0
RENDER 3

REPEAT_TYPE

Search script examples for REPEAT_TYPE

Name Data Description
NO_REPEAT REPEAT_TYPE::NoRepeat
LINEAR REPEAT_TYPE::Linear
BACK_AND_FORTH REPEAT_TYPE::BackAndForth

ROOM_TEMPLATE

Search script examples for ROOM_TEMPLATE

Name Data Description
SIDE 0
...check room_templates.txt...

ROOM_TEMPLATE_TYPE

Search script examples for ROOM_TEMPLATE_TYPE

Use in define_room_template to declare whether a room template has any special behavior

Name Data Description
NONE 0
ENTRANCE 1
EXIT 2
SHOP 3
MACHINE_ROOM 4

SAFE_SETTING

Search script examples for SAFE_SETTING

Paramater to set_setting

Name Data Description
PET_STYLE 20
SCREEN_SHAKE 21
HUD_STYLE 23
HUD_SIZE 24
LEVEL_TIMER 25
TIMER_DETAIL 26
LEVEL_NUMBER 27
ANGRY_SHOPKEEPER 28
BUTTON_PROMPTS 30
FEAT_POPUPS 32
TEXTBOX_SIZE 33
TEXTBOX_DURATION 34
TEXTBOX_OPACITY 35
LEVEL_FEELINGS 36
DIALOG_TEXT 37
KALI_TEXT 38
GHOST_TEXT 39

SCREEN

Search script examples for SCREEN

Name Data Description
LOGO 0
INTRO 1
PROLOGUE 2
TITLE 3
MENU 4
OPTIONS 5
PLAYER_PROFILE 6
LEADERBOARD 7
SEED_INPUT 8
CHARACTER_SELECT 9
TEAM_SELECT 10
CAMP 11
LEVEL 12
TRANSITION 13
DEATH 14
SPACESHIP 15
WIN 16
CREDITS 17
SCORES 18
CONSTELLATION 19
RECAP 20
ARENA_MENU 21
ARENA_STAGES 22
ARENA_ITEMS 23
ARENA_SELECT 24
ARENA_INTRO 25
ARENA_LEVEL 26
ARENA_SCORE 27
ONLINE_LOADING 28
ONLINE_LOBBY 29

SHAPE

Search script examples for SHAPE

Name Data Description
RECTANGLE SHAPE::RECTANGLE
CIRCLE SHAPE::CIRCLE

SHOP_TYPE

Search script examples for SHOP_TYPE

Determines which kind of shop spawns in the level, if any

Name Data Description
GENERAL_STORE 0
CLOTHING_SHOP 1
WEAPON_SHOP 2
SPECIALTY_SHOP 3
HIRED_HAND_SHOP 4
PET_SHOP 5
DICE_SHOP 6
HEDJET_SHOP 8
CURIO_SHOP 9
CAVEMAN_SHOP 10
TURKEY_SHOP 11
GHIST_SHOP 12
TUSK_DICE_SHOP 13

SOUND_LOOP_MODE

Search script examples for SOUND_LOOP_MODE

Paramater to PlayingSound:set_looping(), specifies what type of looping this sound should do

Name Data Description
OFF 0
LOOP 1
BIDIRECTIONAL 2

SOUND_TYPE

Search script examples for SOUND_TYPE

Third parameter to CustomSound:play(), specifies which group the sound will be played in and thus how the player controls its volume

Name Data Description
SFX 0
MUSIC 1

SPARROW

Search script examples for SPARROW

Sparrow quest states

Name Data Description
ANGRY -2
DEAD -1
QUEST_NOT_STARTED 0
THIEF_STATUS 1
FINISHED_LEVEL_WITH_THIEF_STATUS 2
FIRST_HIDEOUT_SPAWNED_ROPE_THROW 3
FIRST_ENCOUNTER_ROPES_THROWN 4
TUSK_IDOL_STOLEN 5
SECOND_HIDEOUT_SPAWNED_NEOBAB 6
SECOND_ENCOUNTER_INTERACTED 7
MEETING_AT_TUSK_BASEMENT 8
FINAL_REWARD_THROWN 9

SPAWN_TYPE

Search script examples for SPAWN_TYPE

Name Data Description
LEVEL_GEN SPAWN_TYPE_LEVEL_GEN For any spawn happening during level generation, even if the call happened from the Lua API during a tile code callback.
LEVEL_GEN_TILE_CODE SPAWN_TYPE_LEVEL_GEN_TILE_CODE Similar to LEVEL_GEN but only triggers on tile code spawns.
LEVEL_GEN_PROCEDURAL SPAWN_TYPE_LEVEL_GEN_PROCEDURAL Similar to LEVEL_GEN but only triggers on random level spawns, like snakes or bats.
LEVEL_GEN_FLOOR_SPREADING SPAWN_TYPE_LEVEL_GEN_FLOOR_SPREADING Includes solid floor type spreading (i.e. floorstyled bleeding to existing generic floor) but also corner filling of empty tiles.
LEVEL_GEN_GENERAL SPAWN_TYPE_LEVEL_GEN_GENERAL Covers all spawns during level gen that are not covered by the other two.
SCRIPT SPAWN_TYPE_SCRIPT Runs for any spawn happening through a call from the Lua API, also during level generation.
SYSTEMIC SPAWN_TYPE_SYSTEMIC Covers all other spawns, such as items from crates or the player throwing bombs.
ANY SPAWN_TYPE_ANY Covers all of the above.

TEXTURE

Search script examples for TEXTURE

Name Data Description
DATA_TEXTURES_PLACEHOLDER_0 0
...check textures.txt...
DATA_TEXTURES_SHINE_0 388
DATA_TEXTURES_OLDTEXTURES_AI_0 389

THEME

Search script examples for THEME

Name Data Description
DWELLING 1
JUNGLE 2
VOLCANA 3
OLMEC 4
TIDE_POOL 5
TEMPLE 6
ICE_CAVES 7
NEO_BABYLON 8
SUNKEN_CITY 9
COSMIC_OCEAN 10
CITY_OF_GOLD 11
DUAT 12
ABZU 13
TIAMAT 14
EGGPLANT_WORLD 15
HUNDUN 16
BASE_CAMP 17
ARENA 18

THEME_OVERRIDE

Search script examples for THEME_OVERRIDE

Name Data Description
DTOR 0
RESET_THEME_FLAGS 1
INIT_FLAGS 2
INIT_LEVEL 3
INIT_ROOMS 4
GENERATE_PATH 5
SPECIAL_ROOMS 6
PLAYER_COFFIN 7
DIRK_COFFIN 8
IDOL 9
VAULT 10
COFFIN 11
FEELING 12
SPAWN_LEVEL 13
SPAWN_BORDER 14
POST_PROCESS_LEVEL 15
SPAWN_TRAPS 16
POST_PROCESS_ENTITIES 17
SPAWN_PROCEDURAL 18
SPAWN_BACKGROUND 19
SPAWN_LIGHTS 20
SPAWN_TRANSITION 21
POST_TRANSITION 22
SPAWN_PLAYERS 23
SPAWN_EFFECTS 24
THEME_ID 26
BASE_ID 27
ENT_FLOOR_SPREADING 28
ENT_FLOOR_SPREADING2 29
TRANSITION_STYLED_FLOOR 30
TRANSITION_MODIFIER 31
ENT_TRANSITION_STYLED_FLOOR 32
ENT_BACKWALL 33
ENT_BORDER 34
ENT_CRITTER 35
GRAVITY 36
PLAYER_DAMAGE 37
SOOT 38
TEXTURE_BACKLAYER_LUT 39
BACKLAYER_LIGHT_LEVEL 40
LOOP 41
VAULT_LEVEL 42
THEME_FLAG 43
TEXTURE_DYNAMIC 44
PRE_TRANSITION 45
EXIT_ROOM_Y_LEVEL 46
SHOP_CHANCE 47
SPAWN_DECORATION 48
SPAWN_DECORATION2 49
SPAWN_EXTRA 50
DO_PROCEDURAL_SPAWN 51

TILE_CODE

Search script examples for TILE_CODE

Name Data Description
EMPTY 0
...check tile_codes.txt...

TUSK

Search script examples for TUSK

Madame Tusk quest states

Name Data Description
ANGRY -2
DEAD -1
QUEST_NOT_STARTED 0
DICE_HOUSE_SPAWNED 1
HIGH_ROLLER_STATUS 2
PALACE_WELCOME_MESSAGE 3

VANHORSING

Search script examples for VANHORSING

Van Horsing quest states

Name Data Description
QUEST_NOT_STARTED 0
JAILCELL_SPAWNED 1
FIRST_ENCOUNTER_DIAMOND_THROWN 2
SPAWNED_IN_VLADS_CASTLE 3
SHOT_VLAD 4
TEMPLE_HIDEOUT_SPAWNED 5
SECOND_ENCOUNTER_COMPASS_THROWN 6
TUSK_CELLAR 7

VANILLA_FONT_STYLE

Search script examples for VANILLA_FONT_STYLE

Used in the render_ctx:draw_text and render_ctx:draw_text_size functions of the ON.RENDER_PRE/POST_xxx event
There are more styles, we just didn't name them all

Name Data Description
NORMAL 0
ITALIC 1
BOLD 2

VANILLA_SOUND

Search script examples for VANILLA_SOUND

Name Data Description
BGM_BGM_TITLE BGM/BGM_title
...check vanilla_sounds.txt...
FX_FX_DM_BANNER FX/FX_dm_banner

VANILLA_SOUND_CALLBACK_TYPE

Search script examples for VANILLA_SOUND_CALLBACK_TYPE

Bitmask parameter to set_vanilla_sound_callback()

Name Data Description
CREATED FMODStudio::EventCallbackType::Created Params: PlayingSound vanilla_sound
DESTROYED FMODStudio::EventCallbackType::Destroyed Params: PlayingSound vanilla_sound
STARTED FMODStudio::EventCallbackType::Started Params: PlayingSound vanilla_sound
RESTARTED FMODStudio::EventCallbackType::Restarted Params: PlayingSound vanilla_sound
STOPPED FMODStudio::EventCallbackType::Stopped Params: PlayingSound vanilla_sound
START_FAILED FMODStudio::EventCallbackType::StartFailed Params: PlayingSound vanilla_sound

VANILLA_SOUND_PARAM

Search script examples for VANILLA_SOUND_PARAM

Name Data Description
POS_SCREEN_X 0
...check vanilla_sound_params.txt...
CURRENT_LAYER2 37

VANILLA_TEXT_ALIGNMENT

Search script examples for VANILLA_TEXT_ALIGNMENT

Used in the render_ctx:draw_text and render_ctx:draw_text_size functions of the ON.RENDER_PRE/POST_xxx event

Name Data Description
LEFT 0
CENTER 1
RIGHT 2

WIN_STATE

Search script examples for WIN_STATE

After setting the WIN_STATE, the exit door on the current level will lead to the chosen ending

Name Data Description
NO_WIN 0
TIAMAT_WIN 1
HUNDUN_WIN 2
COSMIC_OCEAN_WIN 3

WORLD_SHADER

Search script examples for WORLD_SHADER

Name Data Description
COLOR WorldShader::Colors Renders a solid color
TEXTURE WorldShader::Texture Renders a texture without applying the given color
TEXTURE_ALPHA_COLOR WorldShader::TextureAlphaColor Renders a texture by interpreting its red channel as alpha and applying the given color
TEXTURE_COLOR WorldShader::TextureColor The default shader to be used, just renders a texture with transparency and the given color
TEXTURE_COLORS_WARP WorldShader::TextureColorsWarp Renders the texture, with "gamma correction" of the color channels and multiplying everything by the input color alpha only
DEFERRED_COLOR_TRANSPARENT WorldShader::DeferredColorTransparent Basically same as COLOR but goes through the deferred pipeline
DEFERRED_TEXTURE_COLOR WorldShader::DeferredTextureColor Basically same as TEXTURE_COLOR but goes through the deferred pipeline
DEFERRED_TEXTURE_COLOR_POISONED WorldShader::DeferredTextureColor_Poisoned Same as DEFERRED_TEXTURE_COLOR but applies poison color effect
DEFERRED_TEXTURE_COLOR_CURSED WorldShader::DeferredTextureColor_Cursed Same as DEFERRED_TEXTURE_COLOR but applies cursed color effect
DEFERRED_TEXTURE_COLOR_POISONED_CURSED WorldShader::DeferredTextureColor_PoisonedCursed Same as DEFERRED_TEXTURE_COLOR but applies poisoned and cursed color effect
DEFERRED_TEXTURE_COLOR_TRANSPARENT WorldShader::DeferredTextureColor_Transparent Basically same as DEFERRED_TEXTURE_COLOR
DEFERRED_TEXTURE_COLOR_TRANSPARENT_CORRECTED WorldShader::DeferredTextureColor_TransparentCorrected Same as DEFERRED_TEXTURE_COLOR_TRANSPARENT but applies gamma correction to alpha channel
DEFERRED_TEXTURE_COLOR_EMISSIVE WorldShader::DeferredTextureColor_Emissive Same as DEFERRED_TEXTURE_COLOR but renders to the emissive channel
DEFERRED_TEXTURE_COLOR_EMISSIVE_GLOW WorldShader::DeferredTextureColor_EmissiveGlow Same as DEFERRED_TEXTURE_COLOR but renders to the emissive channel with glow
DEFERRED_TEXTURE_COLOR_EMISSIVE_GLOW_HEAVY WorldShader::DeferredTextureColor_EmissiveGlowHeavy Same as DEFERRED_TEXTURE_COLOR_EMISSIVE_GLOW but renders to the emissive channel with heavy glow
DEFERRED_TEXTURE_COLOR_EMISSIVE_GLOW_BRIGHTNESS WorldShader::DeferredTextureColor_EmissiveGlowBrightness Same as DEFERRED_TEXTURE_COLOR_EMISSIVE_GLOW_HEAVY but renders glow on top of the texture
DEFERRED_TEXTURE_COLOR_EMISSIVE_COLORIZED_GLOW WorldShader::DeferredTextureColor_EmissiveColorizedGlow Same as DEFERRED_TEXTURE_COLOR but renders heavy glow behind the texture
DEFERRED_TEXTURE_COLOR_EMISSIVE_COLORIZED_GLOW_DYNAMIC_GLOW WorldShader::DeferredTextureColor_EmissiveColorizedGlow_DynamicGlow Basically same as DEFERRED_TEXTURE_COLOR_EMISSIVE_COLORIZED_GLOW
DEFERRED_TEXTURE_COLOR_EMISSIVE_COLORIZED_GLOW_SATURATION WorldShader::DeferredTextureColor_EmissiveColorizedGlow_Saturation Same as DEFERRED_TEXTURE_COLOR_EMISSIVE_COLORIZED_GLOW but renders texture as solid color

YANG

Search script examples for YANG

Yang quest states

Name Data Description
ANGRY -1
QUEST_NOT_STARTED 0
TURKEY_PEN_SPAWNED 2
BOTH_TURKEYS_DELIVERED 3
TURKEY_SHOP_SPAWNED 4
ONE_TURKEY_BOUGHT 5
TWO_TURKEYS_BOUGHT 6
THREE_TURKEYS_BOUGHT 7

Automatic casting of entities

When using get_entity() the returned entity will automatically be of the correct type. It is not necessary to use the as_<typename> functions.

To figure out what type of entity you get back, consult the entity hierarchy list.

You can also use the types (uppercase <typename>) as ENT_TYPE.<typename> in get_entities functions and pre/post spawn callbacks

For reference, the available as_<typename> functions are listed below: