diff --git a/.github/workflows/docs_verify.yml b/.github/workflows/docs_verify.yml new file mode 100644 index 000000000..b84950f8e --- /dev/null +++ b/.github/workflows/docs_verify.yml @@ -0,0 +1,21 @@ +name: Docs validator + +on: + push: + branches: [main] + pull_request: + branches: [main] + workflow_dispatch: + +jobs: + check: + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - uses: actions/setup-python@v4 + - name: Checking if all the types are documented in the API doc + run: | + cd docs + python validator.py diff --git a/docs/game_data/spel2.lua b/docs/game_data/spel2.lua index 6bf3b1e20..e25d07c15 100644 --- a/docs/game_data/spel2.lua +++ b/docs/game_data/spel2.lua @@ -77,7 +77,7 @@ function messpect(...) end ---@param any any ---@param depth integer? ---@return table -function dump(object, depth) end +function dump(any, depth) end ---Adds a command that can be used in the console. ---@param name string ---@param cmd function @@ -987,7 +987,7 @@ function change_string(id, str) end ---@param str string ---@return STRINGID function add_string(str) end ----Get localized name of an entity, pass `fallback_strategy` as `true` to fall back to the `ENT_TYPE.` enum name +---Get localized name of an entity, pass `fallback_strategy` as `true` to fall back to the `ENT_TYPE.*` enum name ---if the entity has no localized name ---@param type ENT_TYPE ---@param fallback_strategy boolean? @@ -1185,7 +1185,7 @@ function list_dir(dir) end ---@param dir string? ---@return nil function list_data_dir(dir) end ----List all char.png files recursively from Mods/Packs. Returns table of file paths. +---List all char_*.png files recursively from Mods/Packs. Returns table of file paths. ---@return nil function list_char_mods() end ---Approximate bounding box of the player hud element for player index 1..4 based on user settings and player count @@ -1552,13 +1552,13 @@ function grow_chainandblocks(x, y) end ---@return nil function load_screen() end ---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. ----@param e customthem +---@param customtheme CustomTheme|ThemeInfo|THEME ---@return nil -function force_custom_theme(e) end +function force_custom_theme(customtheme) end ---Force current subtheme used in the CO theme. You can pass a CustomTheme, ThemeInfo or THEME. Not to be confused with force_co_subtheme. ----@param e customthem +---@param customtheme CustomTheme|ThemeInfo|THEME ---@return nil -function force_custom_subtheme(e) end +function force_custom_subtheme(customtheme) end ---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 ---@param path string ---@return CustomSound? @@ -1739,13 +1739,13 @@ function show_journal(chapter, page) end ---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. ---@param host string ----@param port in_port_t +---@param port integer ---@param cb function ---@return UdpServer function udp_listen(host, port, cb) end ---Send data to specified UDP address. Requires unsafe mode. ---@param host string ----@param port in_port_t +---@param port integer ---@param msg string ---@return nil function udp_send(host, port, msg) end @@ -1760,7 +1760,7 @@ function http_get(url) end ---The callback signature is nil on_data(string response, string error) ---@param url string ---@param on_data fun(response: string, error: string): nil ----@return HttpRequest +---@return nil function http_get_async(url, on_data) end ---Check if the user has performed a feat (Real Steam achievement or a hooked one). Returns: `bool unlocked, bool hidden, string name, string description` ---@param feat FEAT @@ -2036,7 +2036,7 @@ do ---@field speechbubble_timer integer ---@field speechbubble_owner integer ---@field level_gen LevelGenSystem @Entrance and exit coordinates, shop types and all themes - ---@field correct_ushabti integer @See `get_correct_ushabti`. == anim_frame - (2 floor(anim_frame/12)) + ---@field correct_ushabti integer @See `get_correct_ushabti`. == anim_frame - (2 * floor(anim_frame/12)) ---@field items Items @Has the current player count, player inventories and character selections ---@field camera_layer integer @The currently drawn layer, can't be changed ---@field layer_transition_timer integer @@ -2097,7 +2097,7 @@ do ---@field light1 LightParams ---@field light2 LightParams ---@field light3 LightParams - ---@field light4 LightParams @It's rendered on anys around, not as an actual bright spot + ---@field light4 LightParams @It's rendered on objects around, not as an actual bright spot ---@field brightness number ---@field brightness_multiplier number ---@field light_pos_x number @@ -2223,8 +2223,8 @@ do ---@field random_chance fun(self, inverse_chance: integer, type: PRNG_CLASS): boolean @Returns true with a chance of `1/inverse_chance` ---@field random_index fun(self, i: integer, type: PRNG_CLASS): integer? @Generate a integer number in the range `[1, i]` or `nil` if `i < 1` ---@field random_int fun(self, min: integer, max: integer, type: PRNG_CLASS): integer? @Generate a integer number in the range `[min, max]` or `nil` if `max < min` - ---@field get_pair any @&PRNG::get_pair - ---@field set_pair any @&PRNG::set_pair + ---@field get_pair fun(self, type: PRNG_CLASS): integer, integer + ---@field set_pair fun(self, type: PRNG_CLASS, first: integer, second: integer): nil local PRNG = nil ---Drop-in replacement for `math.random()` ---@return number @@ -2306,7 +2306,7 @@ function PRNG:random(min, max) end ---@field facing_left boolean ---@field render_inactive boolean ---@field texture_num integer - ---@field get_entity fun(self): class Entity + ---@field get_entity fun(self): Entity ---@field set_normal_map_texture fun(self, texture_id: TEXTURE): boolean @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) ---@field get_second_texture TEXTURE? ---@field get_third_texture TEXTURE? @@ -2403,14 +2403,14 @@ function PRNG:random(min, max) end ---@field set_post_activate fun(self, fun: fun(self: Entity, activator: Entity): boolean): CallbackId @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():activate(players[1])` (make sure player 1 has the udjat eye though) ---@field set_pre_on_collision2 fun(self, fun: fun(self: Entity, other_entity: Entity): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool on_collision2(Entity self, Entity other_entity)` ---@field set_post_on_collision2 fun(self, fun: fun(self: Entity, other_entity: Entity): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil on_collision2(Entity self, Entity other_entity)` - ---@field set_pre_walked_on fun(self, fun: fun(self: Entity, Entity*: ): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool walked_on(Entity self, Entity*)` - ---@field set_post_walked_on fun(self, fun: fun(self: Entity, Entity*: ): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil walked_on(Entity self, Entity*)` - ---@field set_pre_walked_off fun(self, fun: fun(self: Entity, Entity*: ): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool walked_off(Entity self, Entity*)` - ---@field set_post_walked_off fun(self, fun: fun(self: Entity, Entity*: ): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil walked_off(Entity self, Entity*)` - ---@field set_pre_ledge_grab fun(self, fun: fun(self: Entity, Entity*: ): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool ledge_grab(Entity self, Entity*)` - ---@field set_post_ledge_grab fun(self, fun: fun(self: Entity, Entity*: ): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil ledge_grab(Entity self, Entity*)` - ---@field set_pre_stood_on fun(self, fun: fun(self: Entity, Entity*: ): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool stood_on(Entity self, Entity*)` - ---@field set_post_stood_on fun(self, fun: fun(self: Entity, Entity*: ): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil stood_on(Entity self, Entity*)` + ---@field set_pre_walked_on fun(self, fun: fun(self: Entity, Entity: ): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool walked_on(Entity self, Entity)` + ---@field set_post_walked_on fun(self, fun: fun(self: Entity, Entity: ): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil walked_on(Entity self, Entity)` + ---@field set_pre_walked_off fun(self, fun: fun(self: Entity, Entity: ): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool walked_off(Entity self, Entity)` + ---@field set_post_walked_off fun(self, fun: fun(self: Entity, Entity: ): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil walked_off(Entity self, Entity)` + ---@field set_pre_ledge_grab fun(self, fun: fun(self: Entity, Entity: ): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool ledge_grab(Entity self, Entity)` + ---@field set_post_ledge_grab fun(self, fun: fun(self: Entity, Entity: ): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil ledge_grab(Entity self, Entity)` + ---@field set_pre_stood_on fun(self, fun: fun(self: Entity, Entity: ): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool stood_on(Entity self, Entity)` + ---@field set_post_stood_on fun(self, fun: fun(self: Entity, Entity: ): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil stood_on(Entity self, Entity)` ---@field set_pre_init fun(self, fun: fun(self: Entity): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool init(Entity self)` ---@field set_post_init fun(self, fun: fun(self: Entity): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil init(Entity self)` local Entity = nil @@ -2429,7 +2429,7 @@ function Entity:overlaps_with(rect_left, rect_bottom, rect_right, rect_top) end ---@return boolean function Entity:overlaps_with(other) end ---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 a 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 +---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 funciton ---@param destroy_corpse boolean ---@param responsible Entity @@ -2444,7 +2444,7 @@ function Entity:kill_recursive(destroy_corpse, responsible, mask, ent_types, rec ---@return nil function Entity:kill_recursive(destroy_corpse, responsible) end ---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 a 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 +---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 ---@param mask integer? ---@param ent_types ENT_TYPE[] ---@param rec_mode RECURSIVE_MODE @@ -2541,16 +2541,16 @@ function Entity:destroy_recursive() end ---@field set_post_check_out_of_bounds fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil check_out_of_bounds(Movable self)` ---@field set_pre_standing_on fun(self, fun: fun(self: Movable): Entity?): CallbackId @Hooks before the virtual function.
The callback signature is `optional standing_on(Movable self)` ---@field set_post_standing_on fun(self, fun: fun(self: Movable): Entity?): CallbackId @Hooks after the virtual function.
The callback signature is `nil standing_on(Movable self)` - ---@field set_pre_stomped_by fun(self, fun: fun(self: Movable, Entity*: ): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool stomped_by(Movable self, Entity*)` - ---@field set_post_stomped_by fun(self, fun: fun(self: Movable, Entity*: ): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil stomped_by(Movable self, Entity*)` - ---@field set_pre_thrown_by fun(self, fun: fun(self: Movable, Entity*: ): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool thrown_by(Movable self, Entity*)` - ---@field set_post_thrown_by fun(self, fun: fun(self: Movable, Entity*: ): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil thrown_by(Movable self, Entity*)` - ---@field set_pre_cloned_to fun(self, fun: fun(self: Movable, Entity*: ): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool cloned_to(Movable self, Entity*)` - ---@field set_post_cloned_to fun(self, fun: fun(self: Movable, Entity*: ): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil cloned_to(Movable self, Entity*)` + ---@field set_pre_stomped_by fun(self, fun: fun(self: Movable, Entity: ): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool stomped_by(Movable self, Entity)` + ---@field set_post_stomped_by fun(self, fun: fun(self: Movable, Entity: ): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil stomped_by(Movable self, Entity)` + ---@field set_pre_thrown_by fun(self, fun: fun(self: Movable, Entity: ): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool thrown_by(Movable self, Entity)` + ---@field set_post_thrown_by fun(self, fun: fun(self: Movable, Entity: ): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil thrown_by(Movable self, Entity)` + ---@field set_pre_cloned_to fun(self, fun: fun(self: Movable, Entity: ): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool cloned_to(Movable self, Entity)` + ---@field set_post_cloned_to fun(self, fun: fun(self: Movable, Entity: ): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil cloned_to(Movable self, Entity)` ---@field set_pre_pick_up fun(self, fun: fun(self: Movable, entity_to_pick_up: Entity): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool pick_up(Movable self, Entity entity_to_pick_up)` ---@field set_post_pick_up fun(self, fun: fun(self: Movable, entity_to_pick_up: Entity): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil pick_up(Movable self, Entity entity_to_pick_up)` - ---@field set_pre_picked_up_by fun(self, fun: fun(self: Movable, Entity*: ): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool picked_up_by(Movable self, Entity*)` - ---@field set_post_picked_up_by fun(self, fun: fun(self: Movable, Entity*: ): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil picked_up_by(Movable self, Entity*)` + ---@field set_pre_picked_up_by fun(self, fun: fun(self: Movable, Entity: ): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool picked_up_by(Movable self, Entity)` + ---@field set_post_picked_up_by fun(self, fun: fun(self: Movable, Entity: ): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil picked_up_by(Movable self, Entity)` ---@field set_pre_drop fun(self, fun: fun(self: Movable, entity_to_drop: Entity): boolean): CallbackId @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 ---@field set_post_drop fun(self, fun: fun(self: Movable, entity_to_drop: Entity): boolean): CallbackId @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 ---@field set_pre_collect_treasure fun(self, fun: fun(self: Movable, value: integer, treasure: ENT_TYPE): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool collect_treasure(Movable self, integer 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. @@ -2565,8 +2565,8 @@ function Entity:destroy_recursive() end ---@field set_post_fall fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil fall(Movable self)` ---@field set_pre_apply_friction fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool apply_friction(Movable self)` ---@field set_post_apply_friction fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil apply_friction(Movable self)` - ---@field set_pre_crush fun(self, fun: fun(self: Movable, Entity*: ): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool crush(Movable self, Entity*)` - ---@field set_post_crush fun(self, fun: fun(self: Movable, Entity*: ): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil crush(Movable self, Entity*)` + ---@field set_pre_crush fun(self, fun: fun(self: Movable, Entity: ): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool crush(Movable self, Entity)` + ---@field set_post_crush fun(self, fun: fun(self: Movable, Entity: ): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil crush(Movable self, Entity)` local Movable = nil ---Move a movable according to its velocity, update physics, gravity, etc. ---Will also update `movable.animation_frame` and various timers and counters @@ -2616,7 +2616,7 @@ function Movable:generic_update_world(move, sprint_factor, disable_gravity, on_r ---@field kills_level integer ---@field kills_total integer ---@field collected_money_total integer @Total money collected during previous levels (so excluding the current one) - ---@field collected_money_count integer @Count/size for the `collected_money` Arrays + ---@field collected_money_count integer @Count/size for the `collected_money` arrays ---@field collected_money ENT_TYPE[] @size: 512 @Types of gold/gems collected during this level, used later to display during the transition ---@field collected_money_values integer[] @size: 512 @Values of gold/gems collected during this level, used later to display during the transition ---@field killed_enemies ENT_TYPE[] @size: 256 @Types of enemies killed during this level, used later to display during the transition @@ -2667,7 +2667,7 @@ function Movable:generic_update_world(move, sprint_factor, disable_gravity, on_r ---@field deco_left integer ---@field deco_right integer ---@field fix_border_tile_animation fun(self): nil @Sets `animation_frame` of the floor for types `FLOOR_BORDERTILE`, `FLOOR_BORDERTILE_METAL` and `FLOOR_BORDERTILE_OCTOPUS`. - ---@field fix_decorations fun(self, fix_also_neighbors: boolean, fix_styled_floor: boolean): nil @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_neighbours` to `true` to fix the neighbouring 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. + ---@field fix_decorations fun(self, fix_also_neighbors: boolean, fix_styled_floor: boolean): nil @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_neighbours` to `true` to fix the neighbouring 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. ---@field add_decoration fun(self, side: FLOOR_SIDE): nil @Explicitly add a decoration on the given side. Corner decorations only exist for `FLOOR_BORDERTILE` and `FLOOR_BORDERTILE_OCTOPUS`. ---@field remove_decoration fun(self, side: FLOOR_SIDE): nil @Explicitly remove a decoration on the given side. Corner decorations only exist for `FLOOR_BORDERTILE` and `FLOOR_BORDERTILE_OCTOPUS`. ---@field decorate_internal fun(self): nil @@ -2689,10 +2689,10 @@ function Movable:generic_update_world(move, sprint_factor, disable_gravity, on_r ---@field set_pre_virtual fun(self, entry: ENTITY_OVERRIDE, fun: function): CallbackId @Hooks before the virtual function at index `entry`. ---@field set_post_virtual fun(self, entry: ENTITY_OVERRIDE, fun: function): CallbackId @Hooks after the virtual function at index `entry`. ---@field clear_virtual fun(self, callback_id: CallbackId): nil @Clears the hook given by `callback_id`, alternatively use `clear_callback()` inside the hook. - ---@field set_pre_enter_attempt fun(self, fun: fun(self: Door, Entity*: ): number?): CallbackId @Hooks before the virtual function.
The callback signature is `optional enter_attempt(Door self, Entity*)` - ---@field set_post_enter_attempt fun(self, fun: fun(self: Door, Entity*: ): number?): CallbackId @Hooks after the virtual function.
The callback signature is `nil enter_attempt(Door self, Entity*)` - ---@field set_pre_hide_hud fun(self, fun: fun(self: Door, Entity*: ): number?): CallbackId @Hooks before the virtual function.
The callback signature is `optional hide_hud(Door self, Entity*)` - ---@field set_post_hide_hud fun(self, fun: fun(self: Door, Entity*: ): number?): CallbackId @Hooks after the virtual function.
The callback signature is `nil hide_hud(Door self, Entity*)` + ---@field set_pre_enter_attempt fun(self, fun: fun(self: Door, Entity: ): number?): CallbackId @Hooks before the virtual function.
The callback signature is `optional enter_attempt(Door self, Entity)` + ---@field set_post_enter_attempt fun(self, fun: fun(self: Door, Entity: ): number?): CallbackId @Hooks after the virtual function.
The callback signature is `nil enter_attempt(Door self, Entity)` + ---@field set_pre_hide_hud fun(self, fun: fun(self: Door, Entity: ): number?): CallbackId @Hooks before the virtual function.
The callback signature is `optional hide_hud(Door self, Entity)` + ---@field set_post_hide_hud fun(self, fun: fun(self: Door, Entity: ): number?): CallbackId @Hooks after the virtual function.
The callback signature is `nil hide_hud(Door self, Entity)` ---@field set_pre_enter fun(self, fun: fun(self: Door, who: Entity): integer?): CallbackId @Hooks before the virtual function.
The callback signature is `optional enter(Door self, Entity who)`
Virtual function docs:
Returns the entity state / behavior id to set the entity to after the entering animation. ---@field set_post_enter fun(self, fun: fun(self: Door, who: Entity): integer?): CallbackId @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. ---@field set_pre_light_level fun(self, fun: fun(self: Door): number?): CallbackId @Hooks before the virtual function.
The callback signature is `optional 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 @@ -3658,7 +3658,7 @@ function Movable:generic_update_world(move, sprint_factor, disable_gravity, on_r ---@field rotation_angle number ---@field size number @slowly goes down to default 1.0, is 0.0 when not on screen ---@field size_multiply number @0.0 when not on screen - ---@field next_size number @width and height will be set to `next_size size_multiply` next frame + ---@field next_size number @width and height will be set to `next_size * size_multiply` next frame ---@field size_change_timer integer @very short timer before next size change, giving a pulsing effect ---@field speed number @This is custom variable, you need [activate_sparktraps_hack](#activate_sparktraps_hack) to use it ---@field distance number @This is custom variable, you need [activate_sparktraps_hack](#activate_sparktraps_hack) to use it @@ -4000,7 +4000,7 @@ function Movable:generic_update_world(move, sprint_factor, disable_gravity, on_r ---@class Rubble : Movable ---@class FxCompass : Movable - ---@field sine_angle number @Counts form 0 to 2pi, responsible for moving back and forth + ---@field sine_angle number @Counts form 0 to 2*pi, responsible for moving back and forth ---@field visibility number ---@field is_active boolean @Player has compass @@ -4458,7 +4458,7 @@ function MovableBehavior:get_state_id() end ---@field spawn_decoration fun(self): nil @Spawns some specific decoration, e.g. Vlad's big banner ---@field spawn_decoration2 fun(self): nil @Spawns some other specific decorations, e.g. grass, flowers, udjat room decal ---@field spawn_extra fun(self): nil @Spawns specific extra entities and decorations, like gold key, seaweed, lanterns, banners, signs, wires... - ---@field do_procedural_spawn fun(self, info: SpawnInfo): nil @Spawns a single procedural entity, used in spawn_procedural + ---@field do_procedural_spawn fun(self, info: SpawnInfo): nil @Spawns a single procedural entity, used in spawn_procedural (mostly monsters, scarb in dark levels etc.) ---@field set_pre_virtual fun(self, entry: THEME_OVERRIDE, fun: function): CallbackId @Hooks before the virtual function at index `entry`. ---@field set_post_virtual fun(self, entry: THEME_OVERRIDE, fun: function): CallbackId @Hooks after the virtual function at index `entry`. ---@field clear_virtual fun(self, callback_id: CallbackId): nil @Clears the hook given by `callback_id`, alternatively use `clear_callback()` inside the hook. @@ -4562,8 +4562,8 @@ function MovableBehavior:get_state_id() end ---@field set_post_spawn_decoration2 fun(self, fun: fun(self: ThemeInfo): boolean): CallbackId @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 ---@field set_pre_spawn_extra fun(self, fun: fun(self: ThemeInfo): boolean): CallbackId @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... ---@field set_post_spawn_extra fun(self, fun: fun(self: ThemeInfo): boolean): CallbackId @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... - ---@field set_pre_do_procedural_spawn fun(self, fun: fun(self: ThemeInfo, info: SpawnInfo): boolean): CallbackId @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 - ---@field set_post_do_procedural_spawn fun(self, fun: fun(self: ThemeInfo, info: SpawnInfo): boolean): CallbackId @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 + ---@field set_pre_do_procedural_spawn fun(self, fun: fun(self: ThemeInfo, info: SpawnInfo): boolean): CallbackId @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, scarb in dark levels etc.) + ---@field set_post_do_procedural_spawn fun(self, fun: fun(self: ThemeInfo, info: SpawnInfo): boolean): CallbackId @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, scarb in dark levels etc.) ---@class CustomTheme : ThemeInfo ---@field level_file string @Level file to load. Probably doesn't do much in custom themes, especially if you're forcing them in PRE_LOAD_LEVEL_FILES. @@ -4644,7 +4644,7 @@ function MovableBehavior:get_state_id() end ---@field spawn_y number ---@field spawn_room_x integer ---@field spawn_room_y integer - ---@field exit_doors custom_Array + ---@field exit_doors Vec2[] ---@field themes ThemeInfo[] @size: 18 ---@field flags integer ---@field flags2 integer @@ -4753,6 +4753,12 @@ function MovableBehavior:get_state_id() end ---@field from integer ---@field to integer +---@class SpawnInfo + ---@field room_template ROOM_TEMPLATE + ---@field grid_entity Entity @Grid entity at this position, will only try to spawn procedural if this is nil + ---@field x number + ---@field y number + ---@class CustomSound ---@field get_parameters fun(self): table local CustomSound = nil @@ -4783,8 +4789,8 @@ function CustomSound:play(paused, sound_type) end ---@class SoundMeta ---@field x number ---@field y number - ---@field left_channel number[] @size: 38 @Use VANILLA_SOUND_PARAM as index, warning: special case with first index at 0, loop using tuples will get you all results but the key/index will be wrong, ituples will have correct key/index but will skip the first element - ---@field right_channel number[] @size: 38 @Use VANILLA_SOUND_PARAM as index warning: special case with first index at 0, loop using tuples will get you all results but the key/index will be wrong, ituples will have correct key/index but will skip the first element + ---@field left_channel number[] @size: 38 @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 + ---@field right_channel number[] @size: 38 @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 ---@field start_over boolean @when false, current track starts from the beginning, is immediately set back to true ---@field playing boolean @set to false to turn off @@ -4841,7 +4847,7 @@ function CustomSound:play(paused, sound_type) end ---@field draw_circle_filled fun(self, x: number, y: number, radius: number, color: uColor): nil @Draws a filled circle on screen ---@field draw_text fun(self, x: number, y: number, size: number, text: string, color: uColor): nil @Draws text in screen coordinates `x`, `y`, anchored top-left. Text size 0 uses the default 18. ---@field draw_layer fun(self, layer: DRAW_LAYER): nil @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. - ---@field window fun(self, title: string, x: number, y: number, w: number, h: number, movable: boolean, callback: fun(ctx: GuiDrawContext, pos: Vec2, size: Vec2): nil): boolean @Create a new widget window. Put all win_ widgets inside the callback function. The window functions are just wrappers for the
[ImGui](https://github.com/ocornut/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) + ---@field window fun(self, title: string, x: number, y: number, w: number, h: number, movable: boolean, callback: fun(ctx: GuiDrawContext, pos: Vec2, size: Vec2): nil): boolean @Create a new widget window. Put all win_ widgets inside the callback function. The window functions are just wrappers for the
[ImGui](https://github.com/ocornut/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) ---@field win_text fun(self, text: string): nil @Add some text to window, automatically wrapped ---@field win_separator fun(self): nil @Add a separator line to window ---@field win_separator_text fun(self, text: string): nil @Add a separator text line to window @@ -4850,11 +4856,11 @@ function CustomSound:play(paused, sound_type) end ---@field win_button fun(self, text: string): boolean @Add a button ---@field win_input_text fun(self, label: string, value: string): string @Add a text field ---@field win_input_int fun(self, label: string, value: integer): integer @Add an integer field - ---@field win_input_float fun(self, label: string, value: number): number @Add a number field + ---@field win_input_float fun(self, label: string, value: number): number @Add a float field ---@field win_slider_int fun(self, label: string, value: integer, min: integer, max: integer): integer @Add an integer slider ---@field win_drag_int fun(self, label: string, value: integer, min: integer, max: integer): integer @Add an integer dragfield - ---@field win_slider_float fun(self, label: string, value: number, min: number, max: number): number @Add an number slider - ---@field win_drag_float fun(self, label: string, value: number, min: number, max: number): number @Add an number dragfield + ---@field win_slider_float fun(self, label: string, value: number, min: number, max: number): number @Add an float slider + ---@field win_drag_float fun(self, label: string, value: number, min: number, max: number): number @Add an float dragfield ---@field win_check fun(self, label: string, value: boolean): boolean @Add a checkbox ---@field win_combo fun(self, label: string, selected: integer, opts: string): integer @Add a combo box ---@field win_popid fun(self): nil @Pop unique identifier from the stack. Put after the input. @@ -4965,7 +4971,7 @@ function GuiDrawContext:win_pushid(id) end ---@field displaysize Vec2 ---@field framerate number ---@field wantkeyboard boolean - ---@field keysdown boolean[] @size: ImGuiKey_COUNT. Note: lua starts indexing at 1, you need `keysdown[string.byte('A') + 1]` to find the A key. + ---@field keysdown boolean[] @size: ImGuiKey_COUNT ---@field keydown fun(key: number | string): boolean ---@field keypressed fun(key: number | string, repeat?: boolean ): boolean ---@field keyreleased fun(key: number | string): boolean @@ -4975,16 +4981,16 @@ function GuiDrawContext:win_pushid(id) end ---@field keysuper boolean ---@field wantmouse boolean ---@field mousepos Vec2 - ---@field mousedown boolean [] @size: 5 - ---@field mouseclicked boolean [] @size: 5 - ---@field mousedoubleclicked boolean [] @size: 5 + ---@field mousedown boolean[] @size: 5 + ---@field mouseclicked boolean[] @size: 5 + ---@field mousedoubleclicked boolean[] @size: 5 ---@field mousewheel number ---@field gamepad Gamepad ---@field gamepads any @[](unsignedintindex){g_WantUpdateHasGamepad=true;returnget_gamepad(index)/**/;} ---@field showcursor boolean ---@class VanillaRenderContext - ---@field draw_text_size fun(self, text: string, scale_x: number, scale_y: number, fontstyle: integer): number, number @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 any
`draw_text_size` works by creating new TextRenderingInfo just to call `:text_size()`, which is not very optimal + ---@field draw_text_size fun(self, text: string, scale_x: number, scale_y: number, fontstyle: integer): number, number @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 ---@field set_corner_finish fun(self, c: CORNER_FINISH): nil @Set the prefered way of drawing corners for the non filled shapes ---@field draw_screen_line fun(self, A: Vec2, B: Vec2, thickness: number, color: Color): nil @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 ---@field draw_screen_rect fun(self, rect: AABB, thickness: number, color: Color, angle: number?, px: number?, py: number?): nil @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 rotatnion 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 @@ -5244,16 +5250,17 @@ function VanillaRenderContext:draw_world_poly_filled(points, color) end ---@field new any @sol::initializers(&TextRenderingInfo_ctor ---@field x number ---@field y number - ---@field text_length integer @You can also just use `#` operator on the whole any to get the text lenght + ---@field text_length integer @You can also just use `#` operator on the whole TextRenderingInfo to get the text lenght ---@field width number ---@field height number ---@field special_texture_id integer @Used to draw buttons and stuff, default is -1 wich uses the buttons texture - ---@field font Texture ---@field get_dest fun(self): Letter[] @Returns refrence to the letter coordinates relative to the x,y position ---@field get_source fun(self): Letter[] @Returns refrence to the letter coordinates in the texture ---@field text_size fun(self): number, number @{width, height}, is only updated when you set/change the text. This is equivalent to draw_text_size ---@field rotate fun(self, angle: number, px: number?, py: number?): nil @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 ---@field set_text fun(self, text: string, scale_x: number, scale_y: number, alignment: VANILLA_TEXT_ALIGNMENT, fontstyle: VANILLA_FONT_STYLE): nil @Changes the text, only position stays the same, everything else (like rotation) is reset or set according to the parameters + ---@field get_font fun(self): TEXTURE + ---@field set_font fun(self, id: TEXTURE): boolean ---@class HudInventory ---@field enabled boolean @@ -5451,6 +5458,10 @@ function Quad:is_point_inside(x, y, epsilon) end ---@field music SoundMeta ---@field torch_sound SoundMeta +---@class SpearDanglerAnimFrames + ---@field column integer + ---@field row integer + ---@class ScreenMenu : Screen ---@field tunnel_background TextureRenderingInfo ---@field cthulhu_disc TextureRenderingInfo @@ -5715,6 +5726,10 @@ function Quad:is_point_inside(x, y, epsilon) end ---@field ouroboros TextureRenderingInfo ---@field ouroboros_angle number +---@class OnlineLobbyScreenPlayer + ---@field character integer @0 - Ana Spelunky, 1 - Margaret Tunnel, 2 - Colin Northward, 3 - Roffy D. Sloth.. and so on. Same order as in ENT_TYPE + ---@field ready boolean + ---@class ScreenOnlineLobby : Screen ---@field woodpanels_slidein_timer number ---@field scroll_unfurl_timer number @@ -5797,7 +5812,7 @@ function Quad:is_point_inside(x, y, epsilon) end ---@field page_timer integer ---@field fade_timer integer ---@field opacity integer - ---@field pages custom_Array @Stores pages loaded into memeory. It's not cleared after the journal is closed or when you go back to the main (menu) page.
Use `:get_type()` to chcek page type and cast it correctly (see ON.[RENDER_POST_DRAW_DEPTH](#ON-RENDER_PRE_JOURNAL_PAGE)) + ---@field pages JournalPage[] @Stores pages loaded into memeory. It's not cleared after the journal is closed or when you go back to the main (menu) page.
Use `:get_type()` to chcek page type and cast it correctly (see ON.[RENDER_POST_DRAW_DEPTH](#ON-RENDER_PRE_JOURNAL_PAGE)) ---@class JournalPage ---@field background TextureRenderingInfo @@ -6085,6 +6100,8 @@ function Quad:is_point_inside(x, y, epsilon) end ---@field player_create_giblets boolean[] @size: MAX_PLAYERS ---@field next_sidepanel_slidein_timer number +---@class UdpServer + ---@class LogicList ---@field tutorial LogicTutorial @Handles dropping of the torch and rope in intro routine (first time play) ---@field ouroboros LogicOuroboros @@ -6178,7 +6195,7 @@ function LogicList:stop_logic(log) end ---@field start_countdown integer ---@class LogicMagmamanSpawn : Logic - ---@field magmaman_positions custom_Array + ---@field magmaman_positions MagmamanSpawnPosition[] local LogicMagmamanSpawn = nil ---@param x integer ---@param y integer @@ -6279,9 +6296,9 @@ function Color:purple() end ---Create a new color - defaults to black ---@return Color function Color:new() end ----@param color Color +---@param other Color ---@return Color -function Color:new(color) end +function Color:new(other) end ---@param color Color ---@return Color function Color:new(color) end @@ -6320,9 +6337,9 @@ function CustomTheme:new() end Vec2 = nil ---@return Vec2 function Vec2:new() end ----@param vec2 Vec2 +---@param other Vec2 ---@return Vec2 -function Vec2:new(vec2) end +function Vec2:new(other) end ---@param x_ number ---@param y_ number ---@return Vec2 @@ -6333,9 +6350,9 @@ AABB = nil ---@return AABB function AABB:new() end ---Copy an axis aligned bounding box ----@param aabb AABB +---@param other AABB ---@return AABB -function AABB:new(aabb) end +function AABB:new(other) end ---@param top_left Vec2 ---@param bottom_right Vec2 ---@return AABB @@ -6351,9 +6368,9 @@ function AABB:new(left_, top_, right_, bottom_) end Triangle = nil ---@return Triangle function Triangle:new() end ----@param triangle Triangle +---@param other Triangle ---@return Triangle -function Triangle:new(triangle) end +function Triangle:new(other) end ---@param _a Vec2 ---@param _b Vec2 ---@param _c Vec2 @@ -6371,9 +6388,9 @@ function Triangle:new(ax, ay, bx, by, cx, cy) end Quad = nil ---@return Quad function Quad:new() end ----@param quad Quad +---@param other Quad ---@return Quad -function Quad:new(quad) end +function Quad:new(other) end ---@param bottom_left_ Vec2 ---@param bottom_right_ Vec2 ---@param top_right_ Vec2 diff --git a/docs/generate.py b/docs/generate.py index e44df546a..7890dabb5 100644 --- a/docs/generate.py +++ b/docs/generate.py @@ -9,8 +9,9 @@ if not os.path.exists("src/includes"): os.makedirs("src/includes") - +# if you change anything in here, please update it in validator.py as well replace_table = { + # standard basic types "uint8_t": "int", "uint16_t": "int", "uint32_t": "int", @@ -20,27 +21,44 @@ "int32_t": "int", "int64_t": "int", "ImU32": "int", - "vector<": "array<", - "span<": "array<", - "unordered_map<": "map<", - "game_map<": "map<", - ", identity_hasher<>": "", - "const char*": "string", + "in_port_t": "int", + "size_t": "int", + "char*": "string", "wstring": "string", "u16string": "string", - "char16_t": "string", + "string_view": "string", + "char16_t*": "string", + "char16_t": "char", "pair<": "tuple<", + # std containers + "custom_vector<": "vector<", + "custom_map<": "map<", + "custom_unordered_map<": "map<", + "custom_set<": "set<", + "custom_unordered_set<": "set<", + "game_vector<": "vector<", + "game_map<": "map<", + "game_unordered_map<": "map<", + "game_set<": "set<", + "game_unordered_set<": "set<", + "unordered_map<": "map<", # doesn't seam to matter for lua if it's ordered or not + "unordered_set<": "set<", # doesn't seam to matter for lua if it's ordered or not + # removers + ", identity_hasher<>": "", "std::": "", "sol::": "", "void": "", "constexpr": "", + "const": "", "static": "", - "variadic_args va": "int, int...", + # special + "variadic_args va": "ENT_TYPE, ENT_TYPE...", "EmittedParticlesInfo": "array", "ImVec2": "Vec2", + "SoundCallbackFunction": "function", + "object ": "any ", } - def replace_all(text): for repl, wth in replace_table.items(): pos = text.find(repl) @@ -51,7 +69,6 @@ def replace_all(text): text = text.replace(repl, wth) return text - ps.configure_parse(replace_all, "slate.pickle") ps.run_parse() @@ -118,11 +135,11 @@ def include_example(name): def format_af(lf, af): - ret = replace_all(af["return"]) or "nil" + ret = af["return"] or "nil" ret = ret.replace("<", "<").replace(">", ">") ret = link_custom_type(ret) name = lf["name"] - param = replace_all(af["param"]) + param = af["param"].replace("vector<", "array<") param = link_custom_type(param) fun = f"{ret} {name}({param})".strip() return fun @@ -368,6 +385,45 @@ def print_lf(lf): com = link_custom_type(com) print(com) +print("# STD Library Containers") +print( + """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:""" +) +print( +""" + +Type | Name | Description +---- | ---- | -----------""" +) +print("bool | all:empty() | Returns true if container is empty, false otherwise") +print("int | aLL:size() | Same as `#container`") + +print("any | vector:at(int index) | Same as `vector[index]`") +print("any | span:at(int index) | Same as `span[index]`") +print("any | set:at(int order) | Returns elements in order, it's not an index as sets don't have one") +print("any | map:at(int order) | Returns elements in order, it's not an index as maps don't have one") + +print("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") +print("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") +print("any | set:find(any value) | Searches for the value in set, returns the value itself or nil if not found, only available for simple values that are comparable") +print("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") + +print("nil | vector:erase(int index) | Removes element at given index, the rest of elements shift down so that the vector stays contiguous") +print("nil | set:erase(any value) | Removes element from set") +print("nil | map:erase(any key) | Removes element from map by key") + +print("nil | vector:clear() | Removes all elements from vector") +print("nil | set:clear() | Removes all elements from set") +print("nil | map:clear() | Removes all elements from map") + +print("nil | vector:insert(int index, any element) | Inserts element at given index, the rest of elements shift up in index") +print("nil | set:insert(int order, any element) | The order param doesn't acutally matter and can be set to nil") +print("nil | map:insert(any key, any value) | unsure, probably easier to just use `map[key] = value`") + print("# Functions") print( @@ -504,10 +560,9 @@ def print_lf(lf): ret = "nil" param = "" if m: - ret = replace_all(m.group(2)).strip() or "nil" + ret = m.group(2) or "nil" if m or m2: param = (m or m2).group(1) - param = replace_all(param).strip() name = lf["name"] ret = link_custom_type(ret) ret = ret.replace("<", "<").replace(">", ">") @@ -549,10 +604,9 @@ def print_lf(lf): ret = "nil" param = "" if m: - ret = replace_all(m.group(2)).strip() or "nil" + ret = m.group(2) or "nil" if m or m2: param = (m or m2).group(1) - param = replace_all(param).strip() name = lf["name"] fun = f"{ret} {name}({param})".strip() search_link = "https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=" + name @@ -711,13 +765,13 @@ def print_lf(lf): if n: name = n.group(1) if n.group(2): - param = replace_all(n.group(2).strip()) + ")" + param = n.group(2) + ")" signature = name + param elif m: - ret = replace_all(m.group(1)) or "nil" + ret = m.group(1) or "nil" name = m.group(2) if m.group(3): - param = replace_all(m.group(3).strip()) + ")" + param = m.group(3).strip().replace("vector<", "array<") + ")" signature = name + param signature = signature.strip() ret = ret.replace("<", "<").replace(">", ">") diff --git a/docs/generate_emmylua.py b/docs/generate_emmylua.py index 591aab2b4..25eab9678 100644 --- a/docs/generate_emmylua.py +++ b/docs/generate_emmylua.py @@ -1,5 +1,6 @@ -from bdb import Breakpoint +#from bdb import Breakpoint import re +#from generate_util import print_console import generate_util as gu import parse_source as ps @@ -14,16 +15,16 @@ "int32_t": "integer", "int64_t": "integer", "size_t": "integer", + "in_port_t": "integer", "ImU32": "integer", "vector": "Array", "array": "Array", "unordered_map": "table", - "game_table": "table", ", identity_hasher<>": "", - "const char*": "string", + "char*": "string", "wstring": "string", "u16string": "string", - "char16_t": "string", + "char16_t*": "string", "string_view": "string", "pair": "tuple", "std::": "", @@ -32,12 +33,15 @@ "void": "", "constexpr": "", "...va:": "...ent_type:", - "// Access via": "ImGuiIO", "set<": "Array<", "span<": "Array<", - "&": "", + + "game_table": "table", + "custom_table": "table", + "game_Array": "Array", + "custom_Array": "Array", + "const ": "", - "ShopType": "SHOP_TYPE", "EmittedParticlesInfo": "Array", "object": "any", "ImVec2": "Vec2", @@ -88,9 +92,9 @@ def replace_all(text): ps.run_parse() -reGetParam = re.compile(r"(?!const)(\b[^ ]+) *([^,]+),?") +reGetParam = re.compile(r"(\b[^ ]+) *([^,]+),?") # this pattern have some issues reRemoveDefault = re.compile(r" = .*") -reHandleConst = re.compile(r"const (\w+) (\w+)") +reHandleConst = re.compile(r"(\w+) (\w+)") def get_emmylua_signature(cb_signature): @@ -127,7 +131,7 @@ def cpp_params_to_emmy_lua(params_text, cb_signatures=None): def cpp_params_to_emmy_lua_fun(params_text): - params = replace_all(params_text).strip().split(",") + params = replace_all(params_text).split(",") params = [ ": ".join([part.strip() for part in param.rsplit(" ", 1)[::-1]]) for param in params @@ -173,8 +177,6 @@ def print_af(lf, af): ret = replace_all(af["return"]) or "nil" name = lf["name"] typed_params, params = cpp_params_to_emmy_lua(af["param"]) - typed_params.strip() - typed_params = replace_all(typed_params) print_comment(lf if lf["comment"] else af) print_func(name, params, ret, typed_params) @@ -238,13 +240,12 @@ def main(): typed_params = "" params = "" if m: - ret = replace_all(m.group(2)).strip() or "nil" + ret = m.group(2) or "nil" if m or m2: params = (m or m2).group(1) typed_params, params = cpp_params_to_emmy_lua( params, lf["cb_signature"] if "cb_signature" in lf else "" ) - typed_params = replace_all(typed_params).strip() name = lf["name"] print_comment(lf) print_func(name, params, ret, typed_params) @@ -378,8 +379,6 @@ def main(): if "comment" in func and func["comment"] and "NoDoc" in func["comment"][0]: continue typed_params, params = cpp_params_to_emmy_lua(func["params"]) - typed_params.strip() - typed_params = replace_all(typed_params) new_name = f"{name}:{func['name']}" @@ -395,8 +394,6 @@ def main(): if "comment" in ctor and ctor["comment"] and "NoDoc" in ctor["comment"][0]: continue typed_params, params = cpp_params_to_emmy_lua(ctor["signature"]) - typed_params.strip() - typed_params = replace_all(typed_params) new_name = f"{name}:new" diff --git a/docs/parse_source.py b/docs/parse_source.py index 71085e855..7d58ff398 100644 --- a/docs/parse_source.py +++ b/docs/parse_source.py @@ -140,9 +140,8 @@ "prng", ] -replace_fun = None +replace_fun_import = None -reConstructorFix = re.compile(r"const (\w+)(?: \w+)?(&&|&)?") reSignature = re.compile(r"(?:\bsignature\b.*is|function) `?([\S]*) (\w*?)\((.*?)\)") @@ -168,9 +167,11 @@ def camel_case_to_snake_case(name): return re.sub(r"(?]*)>", signature_and_binder): binds = binds.group(1) - binds = replace_fun( - "{} {}".format(binds, camel_case_to_snake_case(binds)) - ) + binds = "{} {}".format(binds, camel_case_to_snake_case(binds)) else: binds = None signature = re.sub( @@ -529,9 +526,9 @@ def run_parse(): signature = re.search( r"([_a-zA-Z][_a-zA-Z0-9]*.*)\((.*)\)", signature ) - ret = replace_fun(signature.group(1).strip()) + ret = signature.group(1) args = [ - replace_fun(t.strip()) for t in signature.group(2).split(",") + t for t in signature.group(2).split(",") ] vtable_entries[name] = { "name": name, @@ -652,9 +649,8 @@ def run_parse(): if var[0].startswith("sol::constructors"): for fun in underlying_cpp_type["member_funs"][cpp_type]: - param = replace_fun(fun["param"]) - param = fix_constructor_param(param) - + param = fun["param"] + if cpp_type not in constructors: constructors[cpp_type] = [] constructors[cpp_type].append( @@ -721,7 +717,8 @@ def run_parse(): r"->([:<>\w]+){", var[1] ) # Use var[1] instead of cpp because it could be replaced on the sol::property stuff if m_return_type: - sig = f"{m_return_type[1]} {var_name}" + type = replace_fun(m_return_type[1]) + sig = f"{type} {var_name}" vars.append( {"name": var_name, "type": cpp, "signature": sig} ) @@ -770,10 +767,10 @@ def run_parse(): cpp_comment = [] if entry_name in underlying_cpp_type["member_funs"]: for fun in underlying_cpp_type["member_funs"][entry_name]: - ret = fun["return"] + ret = replace_fun(fun["return"]) ret = f"optional<{ret}>" if ret else "bool" ret = ret if entry_name != "dtor" else "nil" - args = fun["param"].strip() + args = replace_fun(fun["param"]) args = f"{name} self, {args}" if args else f"{name} self" binds = entry["binds"] if binds: @@ -785,10 +782,10 @@ def run_parse(): cpp_comment = ["Virtual function docs:"] + cpp_comment break else: - ret = entry["ret"] + ret = replace_fun(entry["ret"]) ret = f"optional<{ret}>" if ret else "bool" ret = ret if entry_name != "dtor" else "nil" - args = " ".join(entry["args"]) + args = replace_fun(" ".join(entry["args"])) args = f"{name} self, {args}" if args else f"{name} self" pre_signature = f"{ret} {entry_name}({args})" post_signature = f"nil {entry_name}({args})" @@ -838,7 +835,6 @@ def run_parse(): comment = [] data = open(file, "r").read().split("\n") for line in data: - line = line.replace("*", "") m = re.findall(r"new_usertype\<(.*?)\>", line) if m: type = m[0] diff --git a/docs/src/includes/_globals.md b/docs/src/includes/_globals.md index e1b4c9737..9543ea915 100644 --- a/docs/src/includes/_globals.md +++ b/docs/src/includes/_globals.md @@ -147,6 +147,35 @@ end, ON.LEVEL) > Search script examples for [prng](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=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 value) | 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 value) | Removes element from set +nil | map:erase(any key) | Removes element from map by key +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 element) | 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](#get_position). Draw functions use normalized [screen coordinates](#screen_position) from `-1.0 .. 1.0` where `0.0, 0.0` is the center of the screen. @@ -347,7 +376,7 @@ If you set such a callback and then play the same sound yourself you have to wai > Search script examples for [dump](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=dump) -#### table dump(object object, optional depth) +#### 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. @@ -365,7 +394,7 @@ Hook the sendto and recvfrom functions and start dumping network data to termina > Search script examples for [get_rva](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_rva) -#### string get_rva(string_view address_name) +#### string get_rva(string address_name) Get the rva for a pattern name, used for debugging. @@ -491,9 +520,9 @@ Calls the enter door function, position doesn't matter, can also enter closed do > Search script examples for [entity_get_items_by](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=entity_get_items_by) -#### array<int> entity_get_items_by(int uid, array<[ENT_TYPE](#ENT_TYPE)> entity_types, int mask) +#### vector<int> entity_get_items_by(int uid, array<[ENT_TYPE](#ENT_TYPE)> entity_types, int mask) -#### array<int> entity_get_items_by(int uid, [ENT_TYPE](#ENT_TYPE) entity_type, int mask) +#### vector<int> entity_get_items_by(int uid, [ENT_TYPE](#ENT_TYPE) entity_type, int mask) Gets uids of entities attached to given entity uid. Use `entity_type` and `mask` ([MASK](#MASK)) to filter, set them to 0 to return all attached entities. @@ -531,7 +560,7 @@ Remove item by uid from entity > Search script examples for [filter_entities](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=filter_entities) -#### array<int> filter_entities(array entities, function predicate) +#### vector<int> filter_entities(vector entities, function predicate) Returns a list of all uids in `entities` for which `predicate(get_entity(uid))` returns true @@ -567,9 +596,9 @@ Get door target `world`, `level`, `theme` > Search script examples for [get_entities_at](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_entities_at) -#### array<int> get_entities_at(array<[ENT_TYPE](#ENT_TYPE)> entity_types, int mask, float x, float y, [LAYER](#LAYER) layer, float radius) +#### vector<int> get_entities_at(array<[ENT_TYPE](#ENT_TYPE)> entity_types, int mask, float x, float y, [LAYER](#LAYER) layer, float radius) -#### array<int> get_entities_at([ENT_TYPE](#ENT_TYPE) entity_type, int mask, float x, float y, [LAYER](#LAYER) layer, float radius) +#### vector<int> get_entities_at([ENT_TYPE](#ENT_TYPE) entity_type, int mask, float x, float y, [LAYER](#LAYER) layer, float radius) Get uids of matching entities inside some radius ([ENT_TYPE](#ENT_TYPE), [MASK](#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 @@ -590,9 +619,9 @@ end > Search script examples for [get_entities_by](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_entities_by) -#### array<int> get_entities_by(array<[ENT_TYPE](#ENT_TYPE)> entity_types, int mask, [LAYER](#LAYER) layer) +#### vector<int> get_entities_by(array<[ENT_TYPE](#ENT_TYPE)> entity_types, int mask, [LAYER](#LAYER) layer) -#### array<int> get_entities_by([ENT_TYPE](#ENT_TYPE) entity_type, int mask, [LAYER](#LAYER) layer) +#### vector<int> get_entities_by([ENT_TYPE](#ENT_TYPE) entity_type, int mask, [LAYER](#LAYER) layer) Get uids of entities by some conditions ([ENT_TYPE](#ENT_TYPE), [MASK](#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 @@ -602,9 +631,9 @@ Recommended to always set the mask, even if you look for one entity type > Search script examples for [get_entities_by_draw_depth](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_entities_by_draw_depth) -#### array<int> get_entities_by_draw_depth(int draw_depth, [LAYER](#LAYER) l) +#### vector<int> get_entities_by_draw_depth(int draw_depth, [LAYER](#LAYER) l) -#### array<int> get_entities_by_draw_depth(array draw_depths, [LAYER](#LAYER) l) +#### vector<int> get_entities_by_draw_depth(array draw_depths, [LAYER](#LAYER) l) Get uids of entities by draw_depth. Can also use table of draw_depths. You can later use [filter_entities](#filter_entities) if you want specific entity @@ -626,7 +655,7 @@ end, ON.LEVEL) > Search script examples for [get_entities_by_type](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_entities_by_type) -#### array<int> get_entities_by_type(int, int...) +#### vector<int> get_entities_by_type([ENT_TYPE](#ENT_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! @@ -637,9 +666,9 @@ This function can be slower than the [get_entities_by](#get_entities_by) with th > Search script examples for [get_entities_overlapping_hitbox](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_entities_overlapping_hitbox) -#### array<int> get_entities_overlapping_hitbox(array<[ENT_TYPE](#ENT_TYPE)> entity_types, int mask, [AABB](#AABB) hitbox, [LAYER](#LAYER) layer) +#### vector<int> get_entities_overlapping_hitbox(array<[ENT_TYPE](#ENT_TYPE)> entity_types, int mask, [AABB](#AABB) hitbox, [LAYER](#LAYER) layer) -#### array<int> get_entities_overlapping_hitbox([ENT_TYPE](#ENT_TYPE) entity_type, int mask, [AABB](#AABB) hitbox, [LAYER](#LAYER) layer) +#### vector<int> get_entities_overlapping_hitbox([ENT_TYPE](#ENT_TYPE) entity_type, int mask, [AABB](#AABB) hitbox, [LAYER](#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 @@ -659,7 +688,7 @@ Get the [Entity](#Entity) behind an uid, converted to the correct type. To see w #### string get_entity_name([ENT_TYPE](#ENT_TYPE) type, optional fallback_strategy) -Get localized name of an entity, pass `fallback_strategy` as `true` to fall back to the `ENT_TYPE.` enum name +Get localized name of an entity, pass `fallback_strategy` as `true` to fall back to the `ENT_TYPE.*` enum name if the entity has no localized name ### get_entity_type @@ -1039,7 +1068,7 @@ Helper function to set the title and description strings for a [FEAT](#Aliases) > Search script examples for [get_feat](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_feat) -#### tuple<bool, bool, const string, const string> get_feat([FEAT](#Aliases) feat) +#### tuple<bool, bool, string, string> get_feat([FEAT](#Aliases) 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` @@ -1530,7 +1559,7 @@ Converts [INPUTS](#INPUTS) to (x, y, BUTTON) > Search script examples for [intersection](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=intersection) -#### [Vec2](#Vec2) intersection(const [Vec2](#Vec2) A, const [Vec2](#Vec2) B, const [Vec2](#Vec2) C, const [Vec2](#Vec2) D) +#### [Vec2](#Vec2) intersection([Vec2](#Vec2) A, [Vec2](#Vec2) B, [Vec2](#Vec2) C, [Vec2](#Vec2) D) Find intersection point of two lines [A, B] and [C, D], returns INFINITY if the lines don't intersect each other [parallel] @@ -1551,7 +1580,7 @@ Same as `Player.is_female` #### nil list_char_mods() -List all char.png files recursively from Mods/Packs. Returns table of file paths. +List all char_*.png files recursively from Mods/Packs. Returns table of file paths. ### list_data_dir @@ -2181,7 +2210,7 @@ Show a message that looks like a level feeling. > Search script examples for [make_custom_behavior](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=make_custom_behavior) -#### [CustomMovableBehavior](#CustomMovableBehavior) make_custom_behavior(string_view behavior_name, int state_id, [VanillaMovableBehavior](#VanillaMovableBehavior) base_behavior) +#### [CustomMovableBehavior](#CustomMovableBehavior) make_custom_behavior(string behavior_name, int state_id, [VanillaMovableBehavior](#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 @@ -2204,7 +2233,7 @@ Send a synchronous HTTP GET request and return response as a string or nil on an > Search script examples for [http_get_async](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=http_get_async) -#### HttpRequest http_get_async(string url, function on_data) +#### 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) @@ -2214,7 +2243,7 @@ The callback signature is nil on_data(string response, string error) > Search script examples for [udp_listen](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=udp_listen) -#### UdpServer udp_listen(string host, in_port_t port, function cb) +#### [UdpServer](#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. @@ -2224,7 +2253,7 @@ The server will be closed once the handle is released. > Search script examples for [udp_send](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=udp_send) -#### nil udp_send(string host, in_port_t port, string msg) +#### nil udp_send(string host, int port, string msg) Send data to specified UDP address. Requires unsafe mode. @@ -2267,7 +2296,7 @@ Add a button that the user can click in the UI. Sets the timestamp of last click > Search script examples for [register_option_callback](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=register_option_callback) -#### nil register_option_callback(string name, object value, function on_render) +#### 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. @@ -2685,7 +2714,7 @@ Get the room template given a certain index, returns `nil` if coordinates are ou > Search script examples for [get_room_template_name](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_room_template_name) -#### string_view get_room_template_name(int room_template) +#### 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 @@ -3267,7 +3296,7 @@ Same as `Player.get_short_name` > Search script examples for [get_string](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_string) -#### const string get_string([STRINGID](#Aliases) string_id) +#### string get_string([STRINGID](#Aliases) string_id) Get string behind [STRINGID](#Aliases), don't use stringid diretcly for vanilla string, use [hash_to_stringid](#hash_to_stringid) first Will return the string of currently choosen language @@ -3410,7 +3439,7 @@ Forces the theme of the next cosmic ocean level(s) (use e.g. `force_co_subtheme( > Search script examples for [force_custom_subtheme](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=force_custom_subtheme) -#### nil force_custom_subtheme(customtheme) +#### nil force_custom_subtheme([CustomTheme](#CustomTheme)|[ThemeInfo](#ThemeInfo)|[THEME](#THEME) customtheme) Force current subtheme used in the CO theme. You can pass a [CustomTheme](#CustomTheme), [ThemeInfo](#ThemeInfo) or [THEME](#THEME). Not to be confused with force_co_subtheme. @@ -3419,7 +3448,7 @@ Force current subtheme used in the CO theme. You can pass a [CustomTheme](#Custo > Search script examples for [force_custom_theme](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=force_custom_theme) -#### nil force_custom_theme(customtheme) +#### nil force_custom_theme([CustomTheme](#CustomTheme)|[ThemeInfo](#ThemeInfo)|[THEME](#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](#CustomTheme), [ThemeInfo](#ThemeInfo) or [THEME](#THEME). @@ -3540,7 +3569,7 @@ Same as import(). > Search script examples for [read_prng](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=read_prng) -`array read_prng()`
+`vector read_prng()`
Read the game prng state. Use [prng](#PRNG):get_pair() instead. ### force_dark_level @@ -3565,7 +3594,7 @@ Set level flag 18 on post room generation instead, to properly force every level > Search script examples for [get_entities](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_entities) -#### array<int> get_entities() +#### vector<int> get_entities() Use `get_entities_by(0, MASK.ANY, LAYER.BOTH)` instead @@ -3574,7 +3603,7 @@ Use `get_entities_by(0, MASK.ANY, LAYER.BOTH)` instead > Search script examples for [get_entities_by_mask](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_entities_by_mask) -#### array<int> get_entities_by_mask(int mask) +#### vector<int> get_entities_by_mask(int mask) Use `get_entities_by(0, mask, LAYER.BOTH)` instead @@ -3583,7 +3612,7 @@ Use `get_entities_by(0, mask, LAYER.BOTH)` instead > Search script examples for [get_entities_by_layer](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_entities_by_layer) -#### array<int> get_entities_by_layer([LAYER](#LAYER) layer) +#### vector<int> get_entities_by_layer([LAYER](#LAYER) layer) Use `get_entities_by(0, MASK.ANY, layer)` instead @@ -3592,9 +3621,9 @@ Use `get_entities_by(0, MASK.ANY, layer)` instead > Search script examples for [get_entities_overlapping](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_entities_overlapping) -#### array<int> get_entities_overlapping(array<[ENT_TYPE](#ENT_TYPE)> entity_types, int mask, float sx, float sy, float sx2, float sy2, [LAYER](#LAYER) layer) +#### vector<int> get_entities_overlapping(array<[ENT_TYPE](#ENT_TYPE)> entity_types, int mask, float sx, float sy, float sx2, float sy2, [LAYER](#LAYER) layer) -#### array<int> get_entities_overlapping([ENT_TYPE](#ENT_TYPE) entity_type, int mask, float sx, float sy, float sx2, float sy2, [LAYER](#LAYER) layer) +#### vector<int> get_entities_overlapping([ENT_TYPE](#ENT_TYPE) entity_type, int mask, float sx, float sy, float sx2, float sy2, [LAYER](#LAYER) layer) Use `get_entities_overlapping_hitbox` instead diff --git a/docs/src/includes/_types.md b/docs/src/includes/_types.md index de273e7a5..e93f99fbf 100644 --- a/docs/src/includes/_types.md +++ b/docs/src/includes/_types.md @@ -222,7 +222,7 @@ nil | [draw_image(IMAGE image, AABB rect, AABB uv_rect, uColor color)](https://g 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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_image_rotated) | 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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_image_rotated) | 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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=window) | Create a new widget window. Put all win_ widgets inside the callback function. The window functions are just wrappers for the
[ImGui](https://github.com/ocornut/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) +bool | [window(string title, float x, float y, float w, float h, bool movable, function callback)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=window) | Create a new widget window. Put all win_ widgets inside the callback function. The window functions are just wrappers for the
[ImGui](https://github.com/ocornut/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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=win_text) | Add some text to window, automatically wrapped nil | [win_separator()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=win_separator) | Add a separator line to window nil | [win_separator_text(string text)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=win_separator_text) | Add a separator text line to window @@ -282,7 +282,7 @@ Type | Name | Description ---- | ---- | ----------- optional<[SHORT_TILE_CODE](#Aliases)> | [get_short_tile_code(int tx, int ty, LAYER layer)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_short_tile_code) | 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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_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 -array<tuple<int, int, [LAYER](#LAYER)>> | [find_all_short_tile_codes(LAYER layer, SHORT_TILE_CODE short_tile_code)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=find_all_short_tile_codes) | 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 +vector<tuple<int, int, [LAYER](#LAYER)>> | [find_all_short_tile_codes(LAYER layer, SHORT_TILE_CODE short_tile_code)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=find_all_short_tile_codes) | 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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=replace_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()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=has_back_layer) | Check whether the room has a back layer nil | [add_empty_back_layer()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=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 @@ -309,45 +309,45 @@ bool | [save(string data)](https://github.com/spelunky-fyi/overlunky/search?l=Lu ### VanillaRenderContext -Used in [set_callback](#set_callback) [ON](#ON).RENDER_ callbacks, [set_post_render](#set_post_render), [set_post_render_screen](#set_post_render_screen), [set_pre_render](#set_pre_render), [set_pre_render_screen](#set_pre_render_screen) +Used in [set_callback](#set_callback) [ON](#ON).RENDER_* callbacks, [set_post_render](#set_post_render), [set_post_render_screen](#set_post_render_screen), [set_pre_render](#set_pre_render), [set_pre_render_screen](#set_pre_render_screen) Type | Name | Description ---- | ---- | ----------- -nil | [draw_text(const string& text, float x, float y, float scale_x, float scale_y, Color color, VANILLA_TEXT_ALIGNMENT alignment, VANILLA_FONT_STYLE fontstyle)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_text) | Draw text using the built-in renderer
Use in combination with [ON](#ON).RENDER_✱ events. See vanilla_rendering.lua in the example scripts. -nil | [draw_text(const TextRenderingInfo tri, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_text) | -tuple<float, float> | [draw_text_size(const string& text, float scale_x, float scale_y, int fontstyle)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_text_size) | Measure the provided text using the built-in renderer
If you can, consider creating your own [TextRenderingInfo](#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_text(string text, float x, float y, float scale_x, float scale_y, Color color, VANILLA_TEXT_ALIGNMENT alignment, VANILLA_FONT_STYLE fontstyle)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_text) | Draw text using the built-in renderer
Use in combination with [ON](#ON).RENDER_✱ events. See vanilla_rendering.lua in the example scripts. +nil | [draw_text(TextRenderingInfo tri, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_text) | +tuple<float, float> | [draw_text_size(string text, float scale_x, float scale_y, int fontstyle)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_text_size) | Measure the provided text using the built-in renderer
If you can, consider creating your own [TextRenderingInfo](#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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_texture) | Draw a texture in screen coordinates from top-left to bottom-right using the built-in renderer
Use in combination with [ON](#ON).RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events -nil | [draw_screen_texture(TEXTURE texture_id, int row, int column, const AABB& rect, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_texture) | Draw a texture in screen coordinates from top-left to bottom-right using the built-in renderer
Use in combination with [ON](#ON).RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events -nil | [draw_screen_texture(TEXTURE texture_id, int row, int column, const AABB& rect, Color color, float angle, float px, float py)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_texture) | 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 rotatnion where 0,0 is center 1,1 is top right corner etc.
Use in combination with [ON](#ON).RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events -nil | [draw_screen_texture(TEXTURE texture_id, int row, int column, const Quad& dest, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_texture) | Draw a texture in screen coordinates from top-left to bottom-right using the built-in renderer
Use in combination with [ON](#ON).RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events -nil | [draw_screen_texture(TEXTURE texture_id, const Quad& source, const Quad& dest, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_texture) | 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, int row, int column, AABB rect, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_texture) | Draw a texture in screen coordinates from top-left to bottom-right using the built-in renderer
Use in combination with [ON](#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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_texture) | 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 rotatnion where 0,0 is center 1,1 is top right corner etc.
Use in combination with [ON](#ON).RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events +nil | [draw_screen_texture(TEXTURE texture_id, int row, int column, Quad dest, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_texture) | Draw a texture in screen coordinates from top-left to bottom-right using the built-in renderer
Use in combination with [ON](#ON).RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events +nil | [draw_screen_texture(TEXTURE texture_id, Quad source, Quad dest, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_texture) | 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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_texture) | Draw a texture in screen coordinates using [TextureRenderingInfo](#TextureRenderingInfo)
Use in combination with [ON](#ON).RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events nil | [set_corner_finish(CORNER_FINISH c)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_corner_finish) | Set the prefered way of drawing corners for the non filled shapes -nil | [draw_screen_line(const Vec2& A, const Vec2& B, float thickness, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_line) | 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(const AABB& rect, float thickness, Color color, optional angle, optional px, optional py)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_rect) | 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 rotatnion 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(const AABB& rect, Color color, optional angle, optional px, optional py)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_rect_filled) | 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 rotatnion 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(const Triangle& triangle, float thickness, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_triangle) | Draw triangle in screen coordinates using the built-in renderer.
Use in combination with [ON](#ON).RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events -nil | [draw_screen_triangle_filled(const Triangle& triangle, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_triangle_filled) | Draw filled triangle in screen coordinates using the built-in renderer.
Use in combination with [ON](#ON).RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events +nil | [draw_screen_line(Vec2 A, Vec2 B, float thickness, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_line) | 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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_rect) | 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 rotatnion 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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_rect_filled) | 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 rotatnion 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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_triangle) | Draw triangle in screen coordinates using the built-in renderer.
Use in combination with [ON](#ON).RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events +nil | [draw_screen_triangle_filled(Triangle triangle, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_triangle_filled) | Draw filled triangle in screen coordinates using the built-in renderer.
Use in combination with [ON](#ON).RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events nil | [draw_screen_poly(array points, float thickness, Color color, bool closed)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_poly) | 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(const Quad& points, float thickness, Color color, bool closed)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_poly) | Draw quadrilateral in screen coordinates from top-left to bottom-right using the built-in renderer.
Use in combination with [ON](#ON).RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events +nil | [draw_screen_poly(Quad points, float thickness, Color color, bool closed)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_poly) | Draw quadrilateral in screen coordinates from top-left to bottom-right using the built-in renderer.
Use in combination with [ON](#ON).RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events nil | [draw_screen_poly_filled(array points, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_poly_filled) | 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](#ON).RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events -nil | [draw_screen_poly_filled(const Quad& points, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_poly_filled) | Draw filled quadrilateral in screen coordinates from top-left to bottom-right using the built-in renderer.
Use in combination with [ON](#ON).RENDER_✱_HUD/PAUSE_MENU/JOURNAL_PAGE events +nil | [draw_screen_poly_filled(Quad points, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_screen_poly_filled) | Draw filled quadrilateral in screen coordinates from top-left to bottom-right using the built-in renderer.
Use in combination with [ON](#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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_texture) | Draw a texture in world coordinates from top-left to bottom-right using the built-in renderer
Use in combination with [ON](#ON).RENDER_PRE_DRAW_DEPTH event
For more control use the version taking a [Quad](#Quad) instead -nil | [draw_world_texture(TEXTURE texture_id, int row, int column, const AABB& dest, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_texture) | Draw a texture in world coordinates from top-left to bottom-right using the built-in renderer
Use in combination with [ON](#ON).RENDER_PRE_DRAW_DEPTH event
For more control use the version taking a [Quad](#Quad) instead -nil | [draw_world_texture(TEXTURE texture_id, int row, int column, const AABB& dest, Color color, float angle, float px, float py)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_texture) | 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 rotatnion where 0,0 is center 1,1 is top right corner etc.
Use in combination with [ON](#ON).RENDER_PRE_DRAW_DEPTH event
For more control use the version taking a [Quad](#Quad) instead -nil | [draw_world_texture(TEXTURE texture_id, int row, int column, const Quad& dest, Color color, WORLD_SHADER shader)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_texture) | 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, const Quad& dest, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_texture) | Draw a texture in world coordinates from top-left to bottom-right using the built-in renderer
Use in combination with [ON](#ON).RENDER_PRE_DRAW_DEPTH event -nil | [draw_world_texture(TEXTURE texture_id, const Quad& source, const Quad& dest, Color color, WORLD_SHADER shader)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_texture) | 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, const Quad& source, const Quad& dest, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_texture) | 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(const Vec2& A, const Vec2& B, float thickness, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_line) | 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(const AABB& rect, float thickness, Color color, optional angle, optional px, optional py)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_rect) | 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 rotatnion 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(const AABB& rect, Color color, optional angle, optional px, optional py)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_rect_filled) | 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 rotatnion 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(const Triangle& triangle, float thickness, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_triangle) | Draw triangle in world coordinates using the built-in renderer.
Use in combination with [ON](#ON).RENDER_PRE_DRAW_DEPTH event -nil | [draw_world_triangle_filled(const Triangle& triangle, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_triangle_filled) | Draw filled triangle in world coordinates using the built-in renderer.
Use in combination with [ON](#ON).RENDER_PRE_DRAW_DEPTH event +nil | [draw_world_texture(TEXTURE texture_id, int row, int column, AABB dest, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_texture) | Draw a texture in world coordinates from top-left to bottom-right using the built-in renderer
Use in combination with [ON](#ON).RENDER_PRE_DRAW_DEPTH event
For more control use the version taking a [Quad](#Quad) instead +nil | [draw_world_texture(TEXTURE texture_id, int row, int column, AABB dest, Color color, float angle, float px, float py)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_texture) | 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 rotatnion where 0,0 is center 1,1 is top right corner etc.
Use in combination with [ON](#ON).RENDER_PRE_DRAW_DEPTH event
For more control use the version taking a [Quad](#Quad) instead +nil | [draw_world_texture(TEXTURE texture_id, int row, int column, Quad dest, Color color, WORLD_SHADER shader)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_texture) | 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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_texture) | Draw a texture in world coordinates from top-left to bottom-right using the built-in renderer
Use in combination with [ON](#ON).RENDER_PRE_DRAW_DEPTH event +nil | [draw_world_texture(TEXTURE texture_id, Quad source, Quad dest, Color color, WORLD_SHADER shader)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_texture) | 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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_texture) | 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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_line) | 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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_rect) | 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 rotatnion 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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_rect_filled) | 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 rotatnion 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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_triangle) | Draw triangle in world coordinates using the built-in renderer.
Use in combination with [ON](#ON).RENDER_PRE_DRAW_DEPTH event +nil | [draw_world_triangle_filled(Triangle triangle, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_triangle_filled) | Draw filled triangle in world coordinates using the built-in renderer.
Use in combination with [ON](#ON).RENDER_PRE_DRAW_DEPTH event nil | [draw_world_poly(array points, float thickness, Color color, bool closed)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_poly) | 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(const Quad& points, float thickness, Color color, bool closed)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_poly) | Draw quadrilateral in world coordinates from top-left to bottom-right using the built-in renderer.
Use in combination with [ON](#ON).RENDER_PRE_DRAW_DEPTH event +nil | [draw_world_poly(Quad points, float thickness, Color color, bool closed)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_poly) | Draw quadrilateral in world coordinates from top-left to bottom-right using the built-in renderer.
Use in combination with [ON](#ON).RENDER_PRE_DRAW_DEPTH event nil | [draw_world_poly_filled(array points, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_poly_filled) | 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](#ON).RENDER_PRE_DRAW_DEPTH event -nil | [draw_world_poly_filled(const Quad& points, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_poly_filled) | Draw filled quadrilateral in world coordinates from top-left to bottom-right using the built-in renderer.
Use in combination with [ON](#ON).RENDER_PRE_DRAW_DEPTH event +nil | [draw_world_poly_filled(Quad points, Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_world_poly_filled) | Draw filled quadrilateral in world coordinates from top-left to bottom-right using the built-in renderer.
Use in combination with [ON](#ON).RENDER_PRE_DRAW_DEPTH event [AABB](#AABB) | [bounding_box](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=bounding_box) | | [render_draw_depth](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=render_draw_depth) | @@ -449,7 +449,7 @@ Stores static common data for an [ENT_TYPE](#ENT_TYPE). You can also clone entit Type | Name | Description ---- | ---- | ----------- [EntityDB](#EntityDB) | [new(EntityDB other)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=EntityDB) | -[EntityDB](#EntityDB) | [new(ENT_TYPE)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=EntityDB) | +[EntityDB](#EntityDB) | [new(ENT_TYPE other)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=EntityDB) | [ENT_TYPE](#ENT_TYPE) | [id](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=id) | int | [search_flags](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=search_flags) | [MASK](#MASK) float | [width](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=width) | @@ -553,23 +553,23 @@ Axis-Aligned-Bounding-Box, represents for example a hitbox of an entity or the s Type | Name | Description ---- | ---- | ----------- [AABB](#AABB) | [new()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=AABB) | Create a new axis aligned bounding box - defaults to all zeroes -[AABB](#AABB) | [new(AABB)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=AABB) | Copy an axis aligned bounding box +[AABB](#AABB) | [new(AABB other)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=AABB) | Copy an axis aligned bounding box [AABB](#AABB) | [new(Vec2 top_left, Vec2 bottom_right)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=AABB) | [AABB](#AABB) | [new(float left_, float top_, float right_, float bottom_)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=AABB) | Create a new axis aligned bounding box by specifying its values float | [left](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=left) | float | [bottom](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=bottom) | float | [right](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=right) | float | [top](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=top) | -bool | [overlaps_with(const AABB& other)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=overlaps_with) | -[AABB](#AABB)& | [abs()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=abs) | Fixes the [AABB](#AABB) if any of the sides have negative length -[AABB](#AABB)& | [extrude(float amount)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=extrude) | Grows or shrinks the [AABB](#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](#AABB)& | [extrude(float amount_x, float amount_y)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=extrude) | Grows or shrinks the [AABB](#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](#AABB)& | [offset(float off_x, float off_y)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=offset) | Offsets the [AABB](#AABB) by the given offset. +bool | [overlaps_with(AABB other)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=overlaps_with) | +[AABB](#AABB) | [abs()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=abs) | Fixes the [AABB](#AABB) if any of the sides have negative length +[AABB](#AABB) | [extrude(float amount)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=extrude) | Grows or shrinks the [AABB](#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](#AABB) | [extrude(float amount_x, float amount_y)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=extrude) | Grows or shrinks the [AABB](#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](#AABB) | [offset(float off_x, float off_y)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=offset) | Offsets the [AABB](#AABB) by the given offset. float | [area()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=area) | Compute area of the [AABB](#AABB), can be zero if one dimension is zero or negative if one dimension is inverted. tuple<float, float> | [center()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=center) | Short for `(aabb.left + aabb.right) / 2.0f, (aabb.top + aabb.bottom) / 2.0f`. float | [width()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=width) | Short for `aabb.right - aabb.left`. float | [height()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=height) | Short for `aabb.top - aabb.bottom`. -bool | [is_point_inside(const Vec2 p)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_point_inside) | Checks if point lies between left/right and top/bottom +bool | [is_point_inside(Vec2 p)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_point_inside) | Checks if point lies between left/right and top/bottom bool | [is_point_inside(float x, float y)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_point_inside) | tuple<float, float, float, float> | [split()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=split) | @@ -613,7 +613,8 @@ prinspect(string.format("%x"), color:get_ucolor()) -- 800000ff Type | Name | Description ---- | ---- | ----------- [Color](#Color) | [new()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=Color) | Create a new color - defaults to black -[Color](#Color) | [new(Color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=Color) | +[Color](#Color) | [new(Color other)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=Color) | +[Color](#Color) | [new(Color color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=Color) | [Color](#Color) | [new(float r_, float g_, float b_, float a_)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=Color) | Create a new color by specifying its values float | [r](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=r) | float | [g](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=g) | @@ -636,9 +637,9 @@ float | [a](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=a) | [Color](#Color) | [fuchsia()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=fuchsia) | [Color](#Color) | [purple()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=purple) | tuple<int, int, int, int> | [get_rgba()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_rgba) | Returns RGBA colors in 0..255 range -[Color](#Color)& | [set_rgba(int red, int green, int blue, int alpha)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_rgba) | Changes color based on given RGBA colors in 0..255 range +[Color](#Color) | [set_rgba(int red, int green, int blue, int alpha)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_rgba) | Changes color based on given RGBA colors in 0..255 range [uColor](#Aliases) | [get_ucolor()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_ucolor) | Returns the `uColor` used in `GuiDrawContext` drawing functions -[Color](#Color)& | [set_ucolor(const uColor color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_ucolor) | Changes color based on given [uColor](#Aliases) +[Color](#Color) | [set_ucolor(uColor color)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_ucolor) | Changes color based on given [uColor](#Aliases) ### CutsceneBehavior @@ -789,7 +790,7 @@ nil | [set_pair(PRNG_CLASS type, int first, int second)](https://github.com/spel Type | Name | Description ---- | ---- | ----------- [Quad](#Quad) | [new()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=Quad) | -[Quad](#Quad) | [new(Quad)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=Quad) | +[Quad](#Quad) | [new(Quad other)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=Quad) | [Quad](#Quad) | [new(Vec2 bottom_left_, Vec2 bottom_right_, Vec2 top_right_, Vec2 top_left_)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=Quad) | [Quad](#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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=Quad) | [Quad](#Quad) | [new(AABB aabb)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=Quad) | @@ -802,10 +803,10 @@ float | [top_right_y](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=t float | [top_left_x](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=top_left_x) | float | [top_left_y](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=top_left_y) | [AABB](#AABB) | [get_AABB()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_AABB) | Returns the max/min values of the [Quad](#Quad) -[Quad](#Quad)& | [offset(float off_x, float off_y)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=offset) | -[Quad](#Quad)& | [rotate(float angle, float px, float py)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=rotate) | Rotates a [Quad](#Quad) by an angle, px/py are not offsets, use `:get_AABB():center()` to get approximated center for simetrical quadrangle -[Quad](#Quad)& | [flip_horizontally()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=flip_horizontally) | -[Quad](#Quad)& | [flip_vertically()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=flip_vertically) | +[Quad](#Quad) | [offset(float off_x, float off_y)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=offset) | +[Quad](#Quad) | [rotate(float angle, float px, float py)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=rotate) | Rotates a [Quad](#Quad) by an angle, px/py are not offsets, use `:get_AABB():center()` to get approximated center for simetrical quadrangle +[Quad](#Quad) | [flip_horizontally()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=flip_horizontally) | +[Quad](#Quad) | [flip_vertically()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=flip_vertically) | bool | [is_point_inside(Vec2 p, optional epsilon)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_point_inside) | 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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_point_inside) | tuple<[Vec2](#Vec2), [Vec2](#Vec2), [Vec2](#Vec2), [Vec2](#Vec2)> | [split()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=split) | Returns the corners in order: bottom_left, bottom_right, top_right, top_left @@ -840,7 +841,7 @@ float | [tileh](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=tileh) bool | [facing_left](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=facing_left) | bool | [render_inactive](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=render_inactive) | int | [texture_num](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=texture_num) | -class [Entity](#Entity) | [get_entity()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_entity) | +[Entity](#Entity) | [get_entity()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_entity) | bool | [set_normal_map_texture(TEXTURE texture_id)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_normal_map_texture) | 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](#TEXTURE)> | [get_second_texture](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_second_texture) | optional<[TEXTURE](#TEXTURE)> | [get_third_texture](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_third_texture) | @@ -871,8 +872,8 @@ Used in [StateMemory](#StateMemory) Type | Name | Description ---- | ---- | ----------- -custom_map<int, [ItemOwnerDetails](#ItemOwnerDetails)> | [owned_items](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=owned_items) | key/index is the uid of an item -array<[RoomOwnerDetails](#RoomOwnerDetails)> | [owned_rooms](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=owned_rooms) | +map<int, [ItemOwnerDetails](#ItemOwnerDetails)> | [owned_items](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=owned_items) | key/index is the uid of an item +vector<[RoomOwnerDetails](#RoomOwnerDetails)> | [owned_rooms](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=owned_rooms) | ### ShortTileCodeDef @@ -884,29 +885,53 @@ Type | Name | Description int | [chance](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=chance) | Chance in percent to pick `tile_code` over `alt_tile_code`, ignored if `chance == 0`. Defaults to 100. [TILE_CODE](#TILE_CODE) | [alt_tile_code](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=alt_tile_code) | Alternative tile code, ignored if `chance == 100`. Defaults to 0. +### SpawnInfo + + +Type | Name | Description +---- | ---- | ----------- +[ROOM_TEMPLATE](#ROOM_TEMPLATE) | [room_template](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=room_template) | +[Entity](#Entity) | [grid_entity](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=grid_entity) | Grid entity at this position, will only try to spawn procedural if this is nil +float | [x](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=x) | +float | [y](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=y) | + +### SpearDanglerAnimFrames + + +Type | Name | Description +---- | ---- | ----------- +int | [column](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=column) | +int | [row](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=row) | + ### Triangle Type | Name | Description ---- | ---- | ----------- [Triangle](#Triangle) | [new()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=Triangle) | -[Triangle](#Triangle) | [new(Triangle)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=Triangle) | +[Triangle](#Triangle) | [new(Triangle other)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=Triangle) | [Triangle](#Triangle) | [new(Vec2 _a, Vec2 _b, Vec2 _c)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=Triangle) | [Triangle](#Triangle) | [new(float ax, float ay, float bx, float by, float cx, float cy)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=Triangle) | [Vec2](#Vec2) | [A](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=A) | [Vec2](#Vec2) | [B](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=B) | [Vec2](#Vec2) | [C](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=C) | -[Triangle](#Triangle)& | [offset(const Vec2& off)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=offset) | -[Triangle](#Triangle)& | [offset(float x, float y)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=offset) | -[Triangle](#Triangle)& | [rotate(float angle, float px, float py)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=rotate) | Rotate triangle by an angle, the px/py are just coordinates, not offset from the center +[Triangle](#Triangle) | [offset(Vec2 off)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=offset) | +[Triangle](#Triangle) | [offset(float x, float y)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=offset) | +[Triangle](#Triangle) | [rotate(float angle, float px, float py)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=rotate) | Rotate triangle by an angle, the px/py are just coordinates, not offset from the center [Vec2](#Vec2) | [center()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=center) | Also known as centroid tuple<float, float, float> | [get_angles()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_angles) | Returns ABC, BCA, CAB angles in radians -[Triangle](#Triangle)& | [scale(float scale)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=scale) | +[Triangle](#Triangle) | [scale(float scale)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=scale) | float | [area()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=area) | bool | [is_point_inside(Vec2 p, optional epsilon)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_point_inside) | 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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_point_inside) | tuple<[Vec2](#Vec2), [Vec2](#Vec2), [Vec2](#Vec2)> | [split()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=split) | Returns the corner points +### UdpServer + + +Type | Name | Description +---- | ---- | ----------- + ### Vec2 Simple object to hold pair of coordinates @@ -914,12 +939,12 @@ Simple object to hold pair of coordinates Type | Name | Description ---- | ---- | ----------- [Vec2](#Vec2) | [new()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=Vec2) | -[Vec2](#Vec2) | [new(Vec2)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=Vec2) | +[Vec2](#Vec2) | [new(Vec2 other)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=Vec2) | [Vec2](#Vec2) | [new(float x_, float y_)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=Vec2) | float | [x](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=x) | float | [y](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=y) | -[Vec2](#Vec2)& | [rotate(float angle, float px, float py)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=rotate) | -float | [distance_to(const Vec2 other)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=distance_to) | Just simple pythagoras theorem +[Vec2](#Vec2) | [rotate(float angle, float px, float py)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=rotate) | +float | [distance_to(Vec2 other)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=distance_to) | Just simple pythagoras theorem tuple<float, float> | [split()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=split) | ## Input types @@ -946,26 +971,26 @@ Used in [get_io](#get_io) Type | Name | Description ---- | ---- | ----------- -[Vec2](#Vec2) | [displaysize](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=displaysize) | -float | [framerate](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=framerate) | -bool | [wantkeyboard](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=wantkeyboard) | -bool | [keysdown[ImGuiKey_COUNT]](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=keysdown) | +[Vec2](#Vec2) | [displaysize](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=displaysize) | +float | [framerate](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=framerate) | +bool | [wantkeyboard](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=wantkeyboard) | +bool | [keysdown[ImGuiKey_COUNT]](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=keysdown) | | [keydown](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=keydown) | bool keydown(int keycode)
bool keydown(char key)
| [keypressed](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=keypressed) | bool keypressed(int keycode, bool repeat = false)
bool keypressed(char key, bool repeat = false)
| [keyreleased](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=keyreleased) | bool keyreleased(int keycode)
bool keyreleased(char key)
-bool | [keyctrl](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=keyctrl) | -bool | [keyshift](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=keyshift) | -bool | [keyalt](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=keyalt) | -bool | [keysuper](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=keysuper) | -bool | [wantmouse](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=wantmouse) | -[Vec2](#Vec2) | [mousepos](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=mousepos) | -bool | [mousedown[5]](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=mousedown) | -bool | [mouseclicked[5]](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=mouseclicked) | -bool | [mousedoubleclicked[5]](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=mousedoubleclicked) | -float | [mousewheel](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=mousewheel) | +bool | [keyctrl](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=keyctrl) | +bool | [keyshift](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=keyshift) | +bool | [keyalt](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=keyalt) | +bool | [keysuper](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=keysuper) | +bool | [wantmouse](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=wantmouse) | +[Vec2](#Vec2) | [mousepos](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=mousepos) | +bool | [mousedown[5]](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=mousedown) | +bool | [mouseclicked[5]](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=mouseclicked) | +bool | [mousedoubleclicked[5]](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=mousedoubleclicked) | +float | [mousewheel](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=mousewheel) | [Gamepad](#Gamepad) | [gamepad](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=gamepad) | | [gamepads](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=gamepads) | [Gamepad](#Gamepad) gamepads(int index)
This is the XInput index 1..4, might not be the same as the player slot.
-bool | [showcursor](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=showcursor) | +bool | [showcursor](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=showcursor) | ### InputMapping @@ -1225,15 +1250,15 @@ Data relating to level generation, changing anything in here from [ON](#ON).LEVE Type | Name | Description ---- | ---- | ----------- -ShopType | [shop_type](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=shop_type) | -ShopType | [backlayer_shop_type](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=backlayer_shop_type) | +[SHOP_TYPE](#SHOP_TYPE) | [shop_type](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=shop_type) | +[SHOP_TYPE](#SHOP_TYPE) | [backlayer_shop_type](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=backlayer_shop_type) | int | [shop_music](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=shop_music) | int | [backlayer_shop_music](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=backlayer_shop_music) | float | [spawn_x](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=spawn_x) | float | [spawn_y](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=spawn_y) | int | [spawn_room_x](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=spawn_room_x) | int | [spawn_room_y](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=spawn_room_y) | -custom_array<[Vec2](#Vec2)> | [exit_doors](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=exit_doors) | +vector<[Vec2](#Vec2)> | [exit_doors](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=exit_doors) | array<[ThemeInfo](#ThemeInfo), 18> | [themes](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=themes) | int | [flags](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=flags) | int | [flags2](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=flags2) | @@ -1460,7 +1485,7 @@ Derived from [Logic](#Logic) Type | Name | Description ---- | ---- | ----------- -custom_array<[MagmamanSpawnPosition](#MagmamanSpawnPosition)> | [magmaman_positions](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=magmaman_positions) | +vector<[MagmamanSpawnPosition](#MagmamanSpawnPosition)> | [magmaman_positions](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=magmaman_positions) | nil | [add_spawn(int x, int y)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=add_spawn) | nil | [add_spawn(MagmamanSpawnPosition ms)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=add_spawn) | nil | [remove_spawn(int x, int y)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=remove_spawn) | @@ -1509,7 +1534,7 @@ Derived from [Logic](#Logic) [LogicChallenge](#LogicChallenge) Type | Name | Description ---- | ---- | ----------- -array<[Entity](#Entity)> | [torches](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=torches) | +vector<[Entity](#Entity)> | [torches](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=torches) | int | [start_countdown](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=start_countdown) | ### LogicSunChallenge @@ -1821,7 +1846,15 @@ int | [max_page_count](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q= int | [page_timer](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=page_timer) | int | [fade_timer](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=fade_timer) | int | [opacity](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=opacity) | -custom_array<[JournalPage](#JournalPage)> | [pages](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=pages) | Stores pages loaded into memeory. It's not cleared after the journal is closed or when you go back to the main (menu) page.
Use `:get_type()` to chcek page type and cast it correctly (see ON.[RENDER_POST_DRAW_DEPTH](#ON-RENDER_PRE_JOURNAL_PAGE)) +vector<[JournalPage](#JournalPage)> | [pages](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=pages) | Stores pages loaded into memeory. It's not cleared after the journal is closed or when you go back to the main (menu) page.
Use `:get_type()` to chcek page type and cast it correctly (see ON.[RENDER_POST_DRAW_DEPTH](#ON-RENDER_PRE_JOURNAL_PAGE)) + +### OnlineLobbyScreenPlayer + + +Type | Name | Description +---- | ---- | ----------- +int | [character](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=character) | 0 - Ana Spelunky, 1 - Margaret Tunnel, 2 - Colin Northward, 3 - Roffy D. Sloth.. and so on. Same order as in [ENT_TYPE](#ENT_TYPE) +bool | [ready](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ready) | ### PauseUI @@ -2270,7 +2303,7 @@ int | [selected_menu_index](https://github.com/spelunky-fyi/overlunky/search?l=L float | [menu_text_opacity](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=menu_text_opacity) | float | [menu_text_opacity](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=menu_text_opacity) | array<float, 6> | [spear_position](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=spear_position) | -array<SpearDanglerAnimFrames, 6> | [spear_dangler](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=spear_dangler) | +array<[SpearDanglerAnimFrames](#SpearDanglerAnimFrames), 6> | [spear_dangler](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=spear_dangler) | float | [play_scroll_descend_timer](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=play_scroll_descend_timer) | [STRINGID](#Aliases) | [scroll_text](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=scroll_text) | @@ -2304,7 +2337,7 @@ float | [scroll_unfurl_timer](https://github.com/spelunky-fyi/overlunky/search?l bool | [woodpanel_top_visible](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=woodpanel_top_visible) | bool | [woodpanel_bottom_visible](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=woodpanel_bottom_visible) | bool | [toggle_panels_slidein](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=toggle_panels_slidein) | -array<OnlineLobbyScreenPlayer, 4> | [players](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=players) | +array<[OnlineLobbyScreenPlayer](#OnlineLobbyScreenPlayer), 4> | [players](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=players) | [TextureRenderingInfo](#TextureRenderingInfo) | [background_image](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=background_image) | [TextureRenderingInfo](#TextureRenderingInfo) | [topleft_woodpanel_esc](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=topleft_woodpanel_esc) | float | [topleft_woodpanel_esc_slidein_timer](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=topleft_woodpanel_esc_slidein_timer) | @@ -2344,7 +2377,7 @@ float | [enter_code_OK_panel_slidein_timer](https://github.com/spelunky-fyi/over [TextureRenderingInfo](#TextureRenderingInfo) | [enter_code_your_code_scroll](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=enter_code_your_code_scroll) | [TextureRenderingInfo](#TextureRenderingInfo) | [enter_code_your_code_scroll_left_handle](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=enter_code_your_code_scroll_left_handle) | [TextureRenderingInfo](#TextureRenderingInfo) | [enter_code_your_code_scroll_right_handle](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=enter_code_your_code_scroll_right_handle) | -nil | [set_code(const string& code)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_code) | +nil | [set_code(string code)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_code) | ### ScreenOptions @@ -2611,7 +2644,7 @@ bool | [set_pitch(float pitch)](https://github.com/spelunky-fyi/overlunky/search bool | [set_pan(float pan)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pan) | bool | [set_volume(float volume)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_volume) | bool | [set_looping(SOUND_LOOP_MODE loop_mode)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_looping) | -bool | [set_callback(SoundCallbackFunction callback)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_callback) | +bool | [set_callback(function callback)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_callback) | map<[VANILLA_SOUND_PARAM](#VANILLA_SOUND_PARAM), string> | [get_parameters()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_parameters) | optional<float> | [get_parameter(VANILLA_SOUND_PARAM parameter_index)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_parameter) | bool | [set_parameter(VANILLA_SOUND_PARAM parameter_index, float value)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_parameter) | @@ -2844,7 +2877,7 @@ int | [toast_timer](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=toa int | [speechbubble_timer](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=speechbubble_timer) | int | [speechbubble_owner](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=speechbubble_owner) | [LevelGenSystem](#LevelGenSystem) | [level_gen](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=level_gen) | Entrance and exit coordinates, shop types and all themes -int | [correct_ushabti](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=correct_ushabti) | See `get_correct_ushabti`. == anim_frame - (2 floor(anim_frame/12)) +int | [correct_ushabti](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=correct_ushabti) | See `get_correct_ushabti`. == anim_frame - (2 * floor(anim_frame/12)) [Items](#Items) | [items](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=items) | Has the current player count, player inventories and character selections int | [camera_layer](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=camera_layer) | The currently drawn layer, can't be changed int | [layer_transition_timer](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=layer_transition_timer) | @@ -2905,16 +2938,17 @@ Type | Name | Description | [new](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=new) | [TextRenderingInfo](#TextRenderingInfo):new(string text, float scale_x, float scale_y, [VANILLA_TEXT_ALIGNMENT](#VANILLA_TEXT_ALIGNMENT) alignment, [VANILLA_FONT_STYLE](#VANILLA_FONT_STYLE) fontstyle)
[TextRenderingInfo](#TextRenderingInfo):new(string text, float x, float y, float scale_x, float scale_y, [VANILLA_TEXT_ALIGNMENT](#VANILLA_TEXT_ALIGNMENT) alignment, [VANILLA_FONT_STYLE](#VANILLA_FONT_STYLE) fontstyle)
Creates new [TextRenderingInfo](#TextRenderingInfo) that can be used in [VanillaRenderContext](#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](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=x) | float | [y](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=y) | -int | [text_length](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=text_length) | You can also just use `#` operator on the whole object to get the text lenght +int | [text_length](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=text_length) | You can also just use `#` operator on the whole TextRenderingInfo to get the text lenght float | [width](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=width) | float | [height](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=height) | int | [special_texture_id](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=special_texture_id) | Used to draw buttons and stuff, default is -1 wich uses the buttons texture -Texture | [font](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=font) | -array<[Letter](#Letter)> | [get_dest()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_dest) | Returns refrence to the letter coordinates relative to the x,y position -array<[Letter](#Letter)> | [get_source()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_source) | Returns refrence to the letter coordinates in the texture +span<[Letter](#Letter)> | [get_dest()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_dest) | Returns refrence to the letter coordinates relative to the x,y position +span<[Letter](#Letter)> | [get_source()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_source) | Returns refrence to the letter coordinates in the texture tuple<float, float> | [text_size()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=rotate) | 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(const string text, float scale_x, float scale_y, VANILLA_TEXT_ALIGNMENT alignment, VANILLA_FONT_STYLE fontstyle)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_text) | Changes the text, only position stays the same, everything else (like rotation) is reset or set according to the parameters +nil | [set_text(string text, float scale_x, float scale_y, VANILLA_TEXT_ALIGNMENT alignment, VANILLA_FONT_STYLE fontstyle)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_text) | Changes the text, only position stays the same, everything else (like rotation) is reset or set according to the parameters +[TEXTURE](#TEXTURE) | [get_font()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_font) | +bool | [set_font(TEXTURE id)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_font) | ### TextureDefinition @@ -2952,9 +2986,9 @@ float | [destination_top_left_x](https://github.com/spelunky-fyi/overlunky/searc float | [destination_top_left_y](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=destination_top_left_y) | float | [destination_top_right_x](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=destination_top_right_x) | float | [destination_top_right_y](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=destination_top_right_y) | -nil | [set_destination(const AABB& bbox)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_destination) | +nil | [set_destination(AABB bbox)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_destination) | [Quad](#Quad) | [dest_get_quad()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=dest_get_quad) | -nil | [dest_set_quad(const Quad& quad)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=dest_set_quad) | +nil | [dest_set_quad(Quad quad)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=dest_set_quad) | float | [source_bottom_left_x](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=source_bottom_left_x) | float | [source_bottom_left_y](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=source_bottom_left_y) | float | [source_bottom_right_x](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=source_bottom_right_x) | @@ -2964,7 +2998,7 @@ float | [source_top_left_y](https://github.com/spelunky-fyi/overlunky/search?l=L float | [source_top_right_x](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=source_top_right_x) | float | [source_top_right_y](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=source_top_right_y) | [Quad](#Quad) | [source_get_quad()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=source_get_quad) | -nil | [source_set_quad(const Quad& quad)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=source_set_quad) | +nil | [source_set_quad(Quad quad)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=source_set_quad) | ## Theme types @@ -3171,7 +3205,7 @@ int | [get_shop_chance()](https://github.com/spelunky-fyi/overlunky/search?l=Lua nil | [spawn_decoration()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=spawn_decoration) | Spawns some specific decoration, e.g. [Vlad](#Vlad)'s big banner nil | [spawn_decoration2()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=spawn_decoration2) | Spawns some other specific decorations, e.g. grass, flowers, udjat room decal nil | [spawn_extra()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=spawn_extra) | Spawns specific extra entities and decorations, like gold key, seaweed, lanterns, banners, signs, wires... -nil | [do_procedural_spawn(SpawnInfo info)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=do_procedural_spawn) | Spawns a single procedural entity, used in spawn_procedural +nil | [do_procedural_spawn(SpawnInfo info)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=do_procedural_spawn) | Spawns a single procedural entity, used in spawn_procedural (mostly monsters, scarb in dark levels etc.) [CallbackId](#Aliases) | [set_pre_virtual(THEME_OVERRIDE entry, function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_virtual) | Hooks before the virtual function at index `entry`. [CallbackId](#Aliases) | [set_post_virtual(THEME_OVERRIDE entry, function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_virtual) | Hooks after the virtual function at index `entry`. nil | [clear_virtual(CallbackId callback_id)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=clear_virtual) | Clears the hook given by `callback_id`, alternatively use `clear_callback()` inside the hook. @@ -3275,8 +3309,8 @@ nil | [clear_virtual(CallbackId callback_id)](https://github.com/spelunky-fyi/ov [CallbackId](#Aliases) | [set_post_spawn_decoration2(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_spawn_decoration2) | 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](#Aliases) | [set_pre_spawn_extra(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_spawn_extra) | 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](#Aliases) | [set_post_spawn_extra(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_spawn_extra) | 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](#Aliases) | [set_pre_do_procedural_spawn(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_do_procedural_spawn) | 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 -[CallbackId](#Aliases) | [set_post_do_procedural_spawn(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_do_procedural_spawn) | 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 +[CallbackId](#Aliases) | [set_pre_do_procedural_spawn(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_do_procedural_spawn) | 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, scarb in dark levels etc.) +[CallbackId](#Aliases) | [set_post_do_procedural_spawn(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_do_procedural_spawn) | 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, scarb in dark levels etc.) # Entity types @@ -3554,10 +3588,10 @@ nil | [unlock(bool unlock)](https://github.com/spelunky-fyi/overlunky/search?l=L [CallbackId](#Aliases) | [set_pre_virtual(ENTITY_OVERRIDE entry, function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_virtual) | Hooks before the virtual function at index `entry`. [CallbackId](#Aliases) | [set_post_virtual(ENTITY_OVERRIDE entry, function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_virtual) | Hooks after the virtual function at index `entry`. nil | [clear_virtual(CallbackId callback_id)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=clear_virtual) | Clears the hook given by `callback_id`, alternatively use `clear_callback()` inside the hook. -[CallbackId](#Aliases) | [set_pre_enter_attempt(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_enter_attempt) | Hooks before the virtual function.
The callback signature is `optional enter_attempt(Door self, Entity*)` -[CallbackId](#Aliases) | [set_post_enter_attempt(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_enter_attempt) | Hooks after the virtual function.
The callback signature is `nil enter_attempt(Door self, Entity*)` -[CallbackId](#Aliases) | [set_pre_hide_hud(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_hide_hud) | Hooks before the virtual function.
The callback signature is `optional hide_hud(Door self, Entity*)` -[CallbackId](#Aliases) | [set_post_hide_hud(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_hide_hud) | Hooks after the virtual function.
The callback signature is `nil hide_hud(Door self, Entity*)` +[CallbackId](#Aliases) | [set_pre_enter_attempt(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_enter_attempt) | Hooks before the virtual function.
The callback signature is `optional enter_attempt(Door self, Entity)` +[CallbackId](#Aliases) | [set_post_enter_attempt(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_enter_attempt) | Hooks after the virtual function.
The callback signature is `nil enter_attempt(Door self, Entity)` +[CallbackId](#Aliases) | [set_pre_hide_hud(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_hide_hud) | Hooks before the virtual function.
The callback signature is `optional hide_hud(Door self, Entity)` +[CallbackId](#Aliases) | [set_post_hide_hud(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_hide_hud) | Hooks after the virtual function.
The callback signature is `nil hide_hud(Door self, Entity)` [CallbackId](#Aliases) | [set_pre_enter(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_enter) | Hooks before the virtual function.
The callback signature is `optional enter(Door self, Entity who)`
Virtual function docs:
Returns the entity state / behavior id to set the entity to after the entering animation. [CallbackId](#Aliases) | [set_post_enter(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_enter) | 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](#Aliases) | [set_pre_light_level(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_light_level) | Hooks before the virtual function.
The callback signature is `optional 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 @@ -3611,7 +3645,7 @@ int | [deco_bottom](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=dec int | [deco_left](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=deco_left) | int | [deco_right](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=deco_right) | nil | [fix_border_tile_animation()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=fix_decorations) | 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_neighbours` to `true` to fix the neighbouring 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 | [fix_decorations(bool fix_also_neighbors, bool fix_styled_floor)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=fix_decorations) | 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_neighbours` to `true` to fix the neighbouring 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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=add_decoration) | 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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=remove_decoration) | Explicitly remove a decoration on the given side. Corner decorations only exist for `FLOOR_BORDERTILE` and `FLOOR_BORDERTILE_OCTOPUS`. nil | [decorate_internal()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=decorate_internal) | @@ -4003,12 +4037,12 @@ bool | [trigger_action(Entity user)](https://github.com/spelunky-fyi/overlunky/s int | [get_metadata()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_metadata) | e.g. for turkey: stores health, poison/curse state, for mattock: remaining swings (returned value is transferred) nil | [apply_metadata(int metadata)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=apply_metadata) | nil | [set_invisible(bool value)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_invisible) | -array<int> | [get_items()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_items) | +span<int> | [get_items()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_items) | bool | [is_in_liquid()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_in_liquid) | Returns true if entity is in water/lava bool | [is_cursed()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_cursed) | -nil | [kill_recursive(bool destroy_corpse, Entity responsible, optional mask, const array ent_types, RECURSIVE_MODE rec_mode)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=kill_recursive) | 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 a that, you can inclusively or exclusively limit certain [MASK](#MASK) and [ENT_TYPE](#ENT_TYPE). Note: the function will first check mask, if the entity doesn't match, it will look in the provided [ENT_TYPE](#ENT_TYPE)'s
destroy_corpse and responsible are the standard parameters for the kill funciton +nil | [kill_recursive(bool destroy_corpse, Entity responsible, optional mask, array ent_types, RECURSIVE_MODE rec_mode)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=kill_recursive) | 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](#MASK) and [ENT_TYPE](#ENT_TYPE). Note: the function will first check mask, if the entity doesn't match, it will look in the provided [ENT_TYPE](#ENT_TYPE)'s
destroy_corpse and responsible are the standard parameters for the kill funciton nil | [kill_recursive(bool destroy_corpse, Entity responsible)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=kill_recursive) | Short for using [RECURSIVE_MODE](#RECURSIVE_MODE).NONE -nil | [destroy_recursive(optional mask, const array ent_types, RECURSIVE_MODE rec_mode)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=destroy_recursive) | 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 a that, you can inclusively or exclusively limit certain [MASK](#MASK) and [ENT_TYPE](#ENT_TYPE). Note: the function will first check the mask, if the entity doesn't match, it will look in the provided [ENT_TYPE](#ENT_TYPE)'s +nil | [destroy_recursive(optional mask, array ent_types, RECURSIVE_MODE rec_mode)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=destroy_recursive) | 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](#MASK) and [ENT_TYPE](#ENT_TYPE). Note: the function will first check the mask, if the entity doesn't match, it will look in the provided [ENT_TYPE](#ENT_TYPE)'s nil | [destroy_recursive()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=destroy_recursive) | Short for using [RECURSIVE_MODE](#RECURSIVE_MODE).NONE [CallbackId](#Aliases) | [set_pre_virtual(ENTITY_OVERRIDE entry, function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_virtual) | Hooks before the virtual function at index `entry`. [CallbackId](#Aliases) | [set_post_virtual(ENTITY_OVERRIDE entry, function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_virtual) | Hooks after the virtual function at index `entry`. @@ -4041,14 +4075,14 @@ nil | [clear_virtual(CallbackId callback_id)](https://github.com/spelunky-fyi/ov [CallbackId](#Aliases) | [set_post_activate(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_activate) | 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():activate(players[1])` (make sure player 1 has the udjat eye though) [CallbackId](#Aliases) | [set_pre_on_collision2(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_on_collision2) | Hooks before the virtual function.
The callback signature is `bool on_collision2(Entity self, Entity other_entity)` [CallbackId](#Aliases) | [set_post_on_collision2(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_on_collision2) | Hooks after the virtual function.
The callback signature is `nil on_collision2(Entity self, Entity other_entity)` -[CallbackId](#Aliases) | [set_pre_walked_on(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_walked_on) | Hooks before the virtual function.
The callback signature is `bool walked_on(Entity self, Entity*)` -[CallbackId](#Aliases) | [set_post_walked_on(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_walked_on) | Hooks after the virtual function.
The callback signature is `nil walked_on(Entity self, Entity*)` -[CallbackId](#Aliases) | [set_pre_walked_off(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_walked_off) | Hooks before the virtual function.
The callback signature is `bool walked_off(Entity self, Entity*)` -[CallbackId](#Aliases) | [set_post_walked_off(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_walked_off) | Hooks after the virtual function.
The callback signature is `nil walked_off(Entity self, Entity*)` -[CallbackId](#Aliases) | [set_pre_ledge_grab(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_ledge_grab) | Hooks before the virtual function.
The callback signature is `bool ledge_grab(Entity self, Entity*)` -[CallbackId](#Aliases) | [set_post_ledge_grab(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_ledge_grab) | Hooks after the virtual function.
The callback signature is `nil ledge_grab(Entity self, Entity*)` -[CallbackId](#Aliases) | [set_pre_stood_on(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_stood_on) | Hooks before the virtual function.
The callback signature is `bool stood_on(Entity self, Entity*)` -[CallbackId](#Aliases) | [set_post_stood_on(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_stood_on) | Hooks after the virtual function.
The callback signature is `nil stood_on(Entity self, Entity*)` +[CallbackId](#Aliases) | [set_pre_walked_on(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_walked_on) | Hooks before the virtual function.
The callback signature is `bool walked_on(Entity self, Entity)` +[CallbackId](#Aliases) | [set_post_walked_on(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_walked_on) | Hooks after the virtual function.
The callback signature is `nil walked_on(Entity self, Entity)` +[CallbackId](#Aliases) | [set_pre_walked_off(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_walked_off) | Hooks before the virtual function.
The callback signature is `bool walked_off(Entity self, Entity)` +[CallbackId](#Aliases) | [set_post_walked_off(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_walked_off) | Hooks after the virtual function.
The callback signature is `nil walked_off(Entity self, Entity)` +[CallbackId](#Aliases) | [set_pre_ledge_grab(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_ledge_grab) | Hooks before the virtual function.
The callback signature is `bool ledge_grab(Entity self, Entity)` +[CallbackId](#Aliases) | [set_post_ledge_grab(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_ledge_grab) | Hooks after the virtual function.
The callback signature is `nil ledge_grab(Entity self, Entity)` +[CallbackId](#Aliases) | [set_pre_stood_on(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_stood_on) | Hooks before the virtual function.
The callback signature is `bool stood_on(Entity self, Entity)` +[CallbackId](#Aliases) | [set_post_stood_on(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_stood_on) | Hooks after the virtual function.
The callback signature is `nil stood_on(Entity self, Entity)` [CallbackId](#Aliases) | [set_pre_init(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_init) | Hooks before the virtual function.
The callback signature is `bool init(Entity self)` [CallbackId](#Aliases) | [set_post_init(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_init) | Hooks after the virtual function.
The callback signature is `nil init(Entity self)` @@ -5213,7 +5247,7 @@ Type | Name | Description nil | [remove_powerup(ENT_TYPE powerup_type)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=remove_powerup) | 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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=give_powerup) | 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)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=has_powerup) | Checks whether the player/monster has a certain powerup -array<[ENT_TYPE](#ENT_TYPE)> | [get_powerups()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_powerups) | Return all powerups that the entity has +vector<[ENT_TYPE](#ENT_TYPE)> | [get_powerups()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_powerups) | Return all powerups that the entity has nil | [unequip_backitem()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=unequip_backitem) | Unequips the currently worn backitem int | [worn_backitem()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=worn_backitem) | Returns the uid of the currently worn backitem, or -1 if wearing nothing @@ -6062,7 +6096,7 @@ Derived from [Entity](#Entity) [Movable](#Movable) Type | Name | Description ---- | ---- | ----------- -float | [sine_angle](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=sine_angle) | Counts form 0 to 2pi, responsible for moving back and forth +float | [sine_angle](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=sine_angle) | Counts form 0 to 2*pi, responsible for moving back and forth float | [visibility](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=visibility) | bool | [is_active](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_active) | [Player](#Player) has compass @@ -6657,7 +6691,7 @@ bool | [can_jump()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=can nil | [collect_treasure(int value, ENT_TYPE treasure)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=collect_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()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_on_fire) | bool | [damage(int damage_dealer_uid, int damage_amount, int stun_time, float velocity_x, float velocity_y, int iframes)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=damage) | Damage the movable by the specified amount, stuns and gives it invincibility for the specified amount of frames and applies the velocities
Returns: true if entity was affected, damage_dealer should break etc. false if the event should be ignored by damage_dealer? -array<int> | [get_all_behaviors()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_all_behaviors) | Get all avaible behavior ids +vector<int> | [get_all_behaviors()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_all_behaviors) | Get all avaible behavior ids bool | [set_behavior(int behavior_id)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_behavior) | 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()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_behavior) | Get the current behavior id nil | [set_gravity(float gravity)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_gravity) | Force the gravity for this entity. Will override anything set by special states like swimming too, unless you reset it. Default 1.0 @@ -6700,16 +6734,16 @@ nil | [clear_virtual(CallbackId callback_id)](https://github.com/spelunky-fyi/ov [CallbackId](#Aliases) | [set_post_check_out_of_bounds(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_check_out_of_bounds) | Hooks after the virtual function.
The callback signature is `nil check_out_of_bounds(Movable self)` [CallbackId](#Aliases) | [set_pre_standing_on(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_standing_on) | Hooks before the virtual function.
The callback signature is `optional standing_on(Movable self)` [CallbackId](#Aliases) | [set_post_standing_on(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_standing_on) | Hooks after the virtual function.
The callback signature is `nil standing_on(Movable self)` -[CallbackId](#Aliases) | [set_pre_stomped_by(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_stomped_by) | Hooks before the virtual function.
The callback signature is `bool stomped_by(Movable self, Entity*)` -[CallbackId](#Aliases) | [set_post_stomped_by(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_stomped_by) | Hooks after the virtual function.
The callback signature is `nil stomped_by(Movable self, Entity*)` -[CallbackId](#Aliases) | [set_pre_thrown_by(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_thrown_by) | Hooks before the virtual function.
The callback signature is `bool thrown_by(Movable self, Entity*)` -[CallbackId](#Aliases) | [set_post_thrown_by(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_thrown_by) | Hooks after the virtual function.
The callback signature is `nil thrown_by(Movable self, Entity*)` -[CallbackId](#Aliases) | [set_pre_cloned_to(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_cloned_to) | Hooks before the virtual function.
The callback signature is `bool cloned_to(Movable self, Entity*)` -[CallbackId](#Aliases) | [set_post_cloned_to(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_cloned_to) | Hooks after the virtual function.
The callback signature is `nil cloned_to(Movable self, Entity*)` +[CallbackId](#Aliases) | [set_pre_stomped_by(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_stomped_by) | Hooks before the virtual function.
The callback signature is `bool stomped_by(Movable self, Entity)` +[CallbackId](#Aliases) | [set_post_stomped_by(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_stomped_by) | Hooks after the virtual function.
The callback signature is `nil stomped_by(Movable self, Entity)` +[CallbackId](#Aliases) | [set_pre_thrown_by(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_thrown_by) | Hooks before the virtual function.
The callback signature is `bool thrown_by(Movable self, Entity)` +[CallbackId](#Aliases) | [set_post_thrown_by(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_thrown_by) | Hooks after the virtual function.
The callback signature is `nil thrown_by(Movable self, Entity)` +[CallbackId](#Aliases) | [set_pre_cloned_to(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_cloned_to) | Hooks before the virtual function.
The callback signature is `bool cloned_to(Movable self, Entity)` +[CallbackId](#Aliases) | [set_post_cloned_to(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_cloned_to) | Hooks after the virtual function.
The callback signature is `nil cloned_to(Movable self, Entity)` [CallbackId](#Aliases) | [set_pre_pick_up(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_pick_up) | Hooks before the virtual function.
The callback signature is `bool pick_up(Movable self, Entity entity_to_pick_up)` [CallbackId](#Aliases) | [set_post_pick_up(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_pick_up) | Hooks after the virtual function.
The callback signature is `nil pick_up(Movable self, Entity entity_to_pick_up)` -[CallbackId](#Aliases) | [set_pre_picked_up_by(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_picked_up_by) | Hooks before the virtual function.
The callback signature is `bool picked_up_by(Movable self, Entity*)` -[CallbackId](#Aliases) | [set_post_picked_up_by(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_picked_up_by) | Hooks after the virtual function.
The callback signature is `nil picked_up_by(Movable self, Entity*)` +[CallbackId](#Aliases) | [set_pre_picked_up_by(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_picked_up_by) | Hooks before the virtual function.
The callback signature is `bool picked_up_by(Movable self, Entity)` +[CallbackId](#Aliases) | [set_post_picked_up_by(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_picked_up_by) | Hooks after the virtual function.
The callback signature is `nil picked_up_by(Movable self, Entity)` [CallbackId](#Aliases) | [set_pre_drop(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_drop) | 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](#Aliases) | [set_post_drop(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_drop) | 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](#Aliases) | [set_pre_collect_treasure(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_collect_treasure) | 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. @@ -6724,8 +6758,8 @@ nil | [clear_virtual(CallbackId callback_id)](https://github.com/spelunky-fyi/ov [CallbackId](#Aliases) | [set_post_fall(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_fall) | Hooks after the virtual function.
The callback signature is `nil fall(Movable self)` [CallbackId](#Aliases) | [set_pre_apply_friction(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_apply_friction) | Hooks before the virtual function.
The callback signature is `bool apply_friction(Movable self)` [CallbackId](#Aliases) | [set_post_apply_friction(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_apply_friction) | Hooks after the virtual function.
The callback signature is `nil apply_friction(Movable self)` -[CallbackId](#Aliases) | [set_pre_crush(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_crush) | Hooks before the virtual function.
The callback signature is `bool crush(Movable self, Entity*)` -[CallbackId](#Aliases) | [set_post_crush(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_crush) | Hooks after the virtual function.
The callback signature is `nil crush(Movable self, Entity*)` +[CallbackId](#Aliases) | [set_pre_crush(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_crush) | Hooks before the virtual function.
The callback signature is `bool crush(Movable self, Entity)` +[CallbackId](#Aliases) | [set_post_crush(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_crush) | Hooks after the virtual function.
The callback signature is `nil crush(Movable self, Entity)` ### MovingIcon @@ -7015,7 +7049,7 @@ float | [rotation_center_y](https://github.com/spelunky-fyi/overlunky/search?l=L float | [rotation_angle](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=rotation_angle) | float | [size](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=size) | slowly goes down to default 1.0, is 0.0 when not on screen float | [size_multiply](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=size_multiply) | 0.0 when not on screen -float | [next_size](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=next_size) | width and height will be set to `next_size size_multiply` next frame +float | [next_size](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=next_size) | width and height will be set to `next_size * size_multiply` next frame int | [size_change_timer](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=size_change_timer) | very short timer before next size change, giving a pulsing effect float | [speed](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=speed) | This is custom variable, you need [activate_sparktraps_hack](#activate_sparktraps_hack) to use it float | [distance](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=distance) | This is custom variable, you need [activate_sparktraps_hack](#activate_sparktraps_hack) to use it diff --git a/docs/validator.py b/docs/validator.py new file mode 100644 index 000000000..6dd73b139 --- /dev/null +++ b/docs/validator.py @@ -0,0 +1,170 @@ +import re + +import parse_source as ps + +#should be the same as in generate.py +replace_table = { + # standard basic types + "uint8_t": "int", + "uint16_t": "int", + "uint32_t": "int", + "uint64_t": "int", + "int8_t": "int", + "int16_t": "int", + "int32_t": "int", + "int64_t": "int", + "ImU32": "int", + "in_port_t": "int", + "size_t": "int", + "char*": "string", + "wstring": "string", + "u16string": "string", + "string_view": "string", + "char16_t*": "string", + "char16_t": "char", + "pair<": "tuple<", + # std containers + "custom_vector<": "vector<", + "custom_map<": "map<", + "custom_unordered_map<": "map<", + "custom_set<": "set<", + "custom_unordered_set<": "set<", + "game_vector<": "vector<", + "game_map<": "map<", + "game_unordered_map<": "map<", + "game_set<": "set<", + "game_unordered_set<": "set<", + "unordered_map<": "map<", # doesn't seam to matter for lua if it's ordered or not + "unordered_set<": "set<", # doesn't seam to matter for lua if it's ordered or not + # removers + ", identity_hasher<>": "", + "std::": "", + "sol::": "", + "void": "", + "constexpr": "", + "const": "", + "static": "", + # special + "variadic_args va": "ENT_TYPE, ENT_TYPE...", + "EmittedParticlesInfo": "array", + "ImVec2": "Vec2", + "SoundCallbackFunction": "function", + "object ": "any ", +} + +def replace_all(text): + for repl, wth in replace_table.items(): + pos = text.find(repl) + br2 = text.find("`", pos + len(repl)) + br1 = text.rfind("`", 0, pos) + if pos > 0 and br1 >= 0 and br2 > 0: + continue + text = text.replace(repl, wth) + return text + +ps.configure_parse(replace_all, "slate.pickle") +ps.run_parse() + +# types that does not need explanation, ideally we don't want to expand this list too much +known_types = [ + "array", + "table", + "optional", + "mixed", + "int", + "float", + "string", + "function", + "bool", + "tuple", + "variadic_args", + "MAX_PLAYERS", + "any", + "IMAGE", + "VTABLE_OFFSET", + # std library + "map", + "set", + "vector", + "span", +] + +unknown_types = [] + +def check_types(ret): + parts = re.findall(r"(?:(?<=^)|(?<=,|<|\()|(?<=,\s))[a-zA-Z_][\w]+(?=$|[ ,<>])", ret) + if(ret and ret != "nil"): + for part in parts: + add_part = True + for type in ps.types: + if (part == type["name"]): + add_part = False + for enum in ps.enums: + if (part == enum["name"]): + add_part = False + for alias in ps.aliases: + if (part == alias["name"]): + add_part = False + if(add_part == True and not part in unknown_types and not part in known_types): + unknown_types.insert(0, part) + +for lf in ps.funcs + ps.deprecated_funcs: + if not (lf["name"].startswith("on_") or lf["name"] in ps.not_functions): + if lf["comment"] and "NoDoc" in lf["comment"][0]: + continue + m = re.search(r"\(([^\{]*)\)\s*->\s*([^\{]*)", lf["cpp"]) + m2 = re.search(r"\(([^\{]*)\)", lf["cpp"]) + ret = "nil" + param = "" + if m: + ret = m.group(2) or "nil" + if m or m2: + param = (m or m2).group(1) + + check_types(ret) + check_types(param) + +for type in ps.types: + if "comment" in type and "NoDoc" in type["comment"]: + continue + type_name = type["name"] + + ctors = ( + [] if type_name not in ps.constructors else ps.constructors[type_name] + ) + for var in ctors + type["vars"]: + if "comment" in var and "NoDoc" in var["comment"]: + continue + var_name = var["name"] + if "signature" in var: + signature = var["signature"].strip() + ret = "" + if var_name == type_name: + ret = type_name + else: + n = re.search(r"^\s*([^\( ]*)(\(([^\)]*))", signature) + m = re.search( + r"\s*([^\(]*)\s+([^\( ]*)(\(([^\)]*))?", signature + ) + + param = "" + + if n: + if n.group(2): + param = n.group(2) + elif m: + ret = m.group(1) or "nil" + if m.group(3): + param = m.group(3) + + if(param): + check_types(param) + if(ret): + check_types(ret) + +if(len(unknown_types) > 0): + print("Found types not documented in the API") + print(unknown_types) + exit(1) +else: + print("No Problems found") diff --git a/src/game_api/color.hpp b/src/game_api/color.hpp index c99ce38fb..5cb196d83 100644 --- a/src/game_api/color.hpp +++ b/src/game_api/color.hpp @@ -9,7 +9,7 @@ struct Color { /// Create a new color - defaults to black constexpr Color() = default; - constexpr Color(const Color&) = default; + constexpr Color(const Color& other) = default; constexpr Color(Color&&) = default; constexpr Color& operator=(const Color&) = default; constexpr Color& operator=(Color&&) = default; diff --git a/src/game_api/entities_monsters.hpp b/src/game_api/entities_monsters.hpp index 0b5653f7a..06f73b161 100644 --- a/src/game_api/entities_monsters.hpp +++ b/src/game_api/entities_monsters.hpp @@ -1,5 +1,6 @@ #pragma once +#include "containers/custom_set.hpp" #include "entities_chars.hpp" #include "movable.hpp" #include "particles.hpp" @@ -243,7 +244,7 @@ class Yang : public RoomOwner { public: /// Table of uid's of the turkeys, goes only up to 3, is nil when yang is angry - std::set turkeys_in_den; + custom_set turkeys_in_den; uint8_t unknown4; uint8_t unknown5; /// I'm looking for turkeys, wanna help? diff --git a/src/game_api/level_api.cpp b/src/game_api/level_api.cpp index 8791b6d22..4b223b0bc 100644 --- a/src/game_api/level_api.cpp +++ b/src/game_api/level_api.cpp @@ -775,7 +775,7 @@ std::optional g_overridden_room_templates[2]; LevelGenRooms g_CustomRoomShims[2]; // Used for making per-room shop types possible -std::array, 16>, 8> g_CustomShopTypes[2]{}; +std::array, 16>, 8> g_CustomShopTypes[2]{}; // Some select room templates enum class RoomTemplate : uint16_t @@ -1291,10 +1291,10 @@ void spawn_room_from_tile_codes(LevelGenData* level_gen_data, int room_idx_x, in { auto level_gen = State::get().ptr()->level_gen; - std::optional before[2]; + std::optional before[2]; for (size_t i = 0; i < 2; i++) { - const std::optional custom_type = g_CustomShopTypes[i][room_idx_x][room_idx_y]; + const std::optional custom_type = g_CustomShopTypes[i][room_idx_x][room_idx_y]; if (custom_type != std::nullopt) { before[i] = level_gen->shop_type; @@ -1321,7 +1321,7 @@ void spawn_room_from_tile_codes(LevelGenData* level_gen_data, int room_idx_x, in for (size_t i = 0; i < 2; i++) { - const std::optional before_type = before[i]; + const std::optional before_type = before[i]; if (before_type != std::nullopt) { level_gen->shop_types[i] = before_type.value(); @@ -2015,7 +2015,7 @@ bool LevelGenSystem::mark_as_set_room(uint32_t x, uint32_t y, uint8_t l, bool is return true; } -bool LevelGenSystem::set_shop_type(uint32_t x, uint32_t y, uint8_t l, ShopType _shop_type) +bool LevelGenSystem::set_shop_type(uint32_t x, uint32_t y, uint8_t l, SHOP_TYPE _shop_type) { auto* state_ptr = State::get().ptr_local(); diff --git a/src/game_api/level_api.hpp b/src/game_api/level_api.hpp index ab8108d36..1e300b37a 100644 --- a/src/game_api/level_api.hpp +++ b/src/game_api/level_api.hpp @@ -20,6 +20,8 @@ #include "level_api_types.hpp" // for ShortTileCodeDef #include "math.hpp" // for AABB (ptr only), Vec2 +class Entity; + struct TileCodeDef { std::uint32_t id; @@ -170,8 +172,11 @@ struct DoorCoords struct SpawnInfo { - void* ptr0; - void* ptr1; + ROOM_TEMPLATE room_template; + // probably padding here + + /// Grid entity at this position, will only try to spawn procedural if this is nil + Entity* grid_entity; float x; float y; }; @@ -359,7 +364,7 @@ class ThemeInfo /// Spawns specific extra entities and decorations, like gold key, seaweed, lanterns, banners, signs, wires... virtual void spawn_extra() = 0; - /// Spawns a single procedural entity, used in spawn_procedural + /// Spawns a single procedural entity, used in spawn_procedural (mostly monsters, scarb in dark levels etc.) virtual void do_procedural_spawn(SpawnInfo* info) = 0; uint32_t get_aux_id(); @@ -394,7 +399,7 @@ class SpecialLevelGeneration virtual void procedual_spawns() = 0; }; -enum class ShopType : uint8_t +enum class SHOP_TYPE : uint8_t { General, Clothing, @@ -505,11 +510,11 @@ struct LevelGenSystem uint8_t flags3; union { - ShopType shop_types[2]; + SHOP_TYPE shop_types[2]; struct { - ShopType shop_type; - ShopType backlayer_shop_type; + SHOP_TYPE shop_type; + SHOP_TYPE backlayer_shop_type; }; }; uint8_t frontlayer_shop_music; @@ -533,7 +538,7 @@ struct LevelGenSystem bool mark_as_machine_room_origin(uint32_t x, uint32_t y, uint8_t l); bool mark_as_set_room(uint32_t x, uint32_t y, uint8_t l, bool is_set_room); - bool set_shop_type(uint32_t x, uint32_t y, uint8_t l, ShopType shop_type); + bool set_shop_type(uint32_t x, uint32_t y, uint8_t l, SHOP_TYPE shop_type); std::string_view get_room_template_name(uint16_t room_template); std::optional get_procedural_spawn_chance_name(uint32_t chance_id); diff --git a/src/game_api/math.hpp b/src/game_api/math.hpp index 44300d1ff..20470e419 100644 --- a/src/game_api/math.hpp +++ b/src/game_api/math.hpp @@ -9,7 +9,7 @@ struct Vec2 { Vec2() = default; - Vec2(const Vec2&) = default; + Vec2(const Vec2& other) = default; Vec2(float x_, float y_) : x(x_), y(y_){}; @@ -144,7 +144,7 @@ struct AABB AABB() = default; /// Copy an axis aligned bounding box - AABB(const AABB&) = default; + AABB(const AABB& other) = default; /// NoDoc AABB(const std::tuple tuple) { @@ -289,7 +289,7 @@ struct AABB struct Triangle { Triangle() = default; - Triangle(const Triangle&) = default; + Triangle(const Triangle& other) = default; Triangle(const Vec2& _a, const Vec2& _b, const Vec2& _c) : A(_a), B(_b), C(_c){}; Triangle(float ax, float ay, float bx, float by, float cx, float cy) @@ -407,7 +407,7 @@ struct Quad { Quad() = default; - Quad(const Quad&) = default; + Quad(const Quad& other) = default; Quad(const Vec2& bottom_left_, const Vec2& bottom_right_, const Vec2& top_right_, const Vec2& top_left_) : bottom_left_x(bottom_left_.x), bottom_left_y(bottom_left_.y), bottom_right_x(bottom_right_.x), bottom_right_y(bottom_right_.y), top_right_x(top_right_.x), top_right_y(top_right_.y), top_left_x(top_left_.x), top_left_y(top_left_.y){}; diff --git a/src/game_api/render_api.hpp b/src/game_api/render_api.hpp index e6c19c5f9..47da31719 100644 --- a/src/game_api/render_api.hpp +++ b/src/game_api/render_api.hpp @@ -17,6 +17,7 @@ struct JournalUI; struct Layer; +class Entity; using VANILLA_TEXT_ALIGNMENT = uint32_t; using VANILLA_FONT_STYLE = uint32_t; @@ -143,12 +144,28 @@ struct TextRenderingInfo { return text_length; } + TEXTURE get_font() const + { + if (font) + return font->id; + else + return 0; + } + bool set_font(TEXTURE id) + { + if (auto* texture = get_texture(id)) + { + font = get_texture(id); + return true; + } + return false; + } /// 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 void rotate(float angle, std::optional px, std::optional py); float x; float y; - /// You can also just use `#` operator on the whole object to get the text lenght + /// You can also just use `#` operator on the whole TextRenderingInfo to get the text lenght uint32_t text_length; float width; float height; @@ -333,7 +350,7 @@ struct RenderInfo virtual bool unknown_3() = 0; // init? sets darkness to 1.0 at the start, then does some other stuff // gets the entity owning this RenderInfo - class Entity* get_entity() const; + Entity* get_entity() const; // for supporting HookableVTable uint32_t get_aux_id() const; diff --git a/src/game_api/screen.hpp b/src/game_api/screen.hpp index 0c4eb878a..35ee2adfd 100644 --- a/src/game_api/screen.hpp +++ b/src/game_api/screen.hpp @@ -668,6 +668,7 @@ class ScreenOnlineLoading : public Screen // ID: 28 struct OnlineLobbyScreenPlayer { uint8_t unknown1; + /// 0 - Ana Spelunky, 1 - Margaret Tunnel, 2 - Colin Northward, 3 - Roffy D. Sloth.. and so on. Same order as in ENT_TYPE uint8_t character; bool ready; uint8_t unknown2; diff --git a/src/game_api/script/lua_vm.cpp b/src/game_api/script/lua_vm.cpp index 3a79003b7..0c12c0439 100644 --- a/src/game_api/script/lua_vm.cpp +++ b/src/game_api/script/lua_vm.cpp @@ -999,7 +999,7 @@ end /// Check the [entity hierarchy list](https://github.com/spelunky-fyi/overlunky/blob/main/docs/entities-hierarchy.md) for what the exact ENT_TYPE's can this function affect lua["set_contents"] = set_contents; /// Get the Entity behind an uid, converted to the correct type. To see what type you will get, consult the [entity hierarchy list](https://github.com/spelunky-fyi/overlunky/blob/main/docs/entities-hierarchy.md) - // lua["get_entity"] = [](uint32_t uid) -> Entity* {}; + // lua["get_entity"] = [](uint32_t uid) -> Entity*{}; /// NoDoc /// Get the [Entity](#Entity) behind an uid, without converting to the correct type (do not use, use `get_entity` instead) lua["get_entity_raw"] = get_entity_ptr; @@ -1434,7 +1434,7 @@ end /// Returns unique id for the callback to be used in [clear_screen_callback](#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) + ///
The callback signature is bool render_screen(Screen self, VanillaRenderContext render_ctx) lua["set_pre_render_screen"] = [](int screen_id, sol::function fun) -> sol::optional { if (Screen* screen = get_screen_ptr(screen_id)) @@ -1458,7 +1458,7 @@ end }; /// Returns unique id for the callback to be used in [clear_screen_callback](#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) + ///
The callback signature is nil render_screen(Screen self, VanillaRenderContext render_ctx) lua["set_post_render_screen"] = [](int screen_id, sol::function fun) -> sol::optional { if (Screen* screen = get_screen_ptr(screen_id)) @@ -2032,7 +2032,7 @@ end return sol::make_object(lua, sol::as_table(files)); }; - /// List all char*.png files recursively from Mods/Packs. Returns table of file paths. + /// List all char_*.png files recursively from Mods/Packs. Returns table of file paths. lua["list_char_mods"] = [&lua]() { std::vector files; diff --git a/src/game_api/script/usertypes/level_lua.cpp b/src/game_api/script/usertypes/level_lua.cpp index c213c903e..0799be3ba 100644 --- a/src/game_api/script/usertypes/level_lua.cpp +++ b/src/game_api/script/usertypes/level_lua.cpp @@ -65,7 +65,7 @@ bool PostRoomGenerationContext::unmark_as_set_room(uint32_t x, uint32_t y, LAYER bool PostRoomGenerationContext::set_shop_type(uint32_t x, uint32_t y, LAYER layer, int32_t shop_type) { const uint8_t real_layer = static_cast(layer) < 0 ? 0 : static_cast(layer); - return State::get().ptr_local()->level_gen->set_shop_type(x, y, real_layer, static_cast(shop_type)); + return State::get().ptr_local()->level_gen->set_shop_type(x, y, real_layer, static_cast(shop_type)); } bool PostRoomGenerationContext::set_procedural_spawn_chance(PROCEDURAL_CHANCE chance_id, uint32_t inverse_chance) @@ -1326,7 +1326,7 @@ void register_usertypes(sol::state& lua) lua.create_named_table("DYNAMIC_TEXTURE", "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); /// 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. - // lua["force_custom_theme"] = [](* customtheme) + // lua["force_custom_theme"] = [](CustomTheme|ThemeInfo|THEME customtheme) lua["force_custom_theme"] = sol::overload( [](CustomTheme* customtheme) { @@ -1343,7 +1343,7 @@ void register_usertypes(sol::state& lua) }); /// Force current subtheme used in the CO theme. You can pass a CustomTheme, ThemeInfo or THEME. Not to be confused with force_co_subtheme. - // lua["force_custom_subtheme"] = [](* customtheme) + // lua["force_custom_subtheme"] = [](CustomTheme|ThemeInfo|THEME customtheme) lua["force_custom_subtheme"] = sol::overload( [](CustomTheme* customtheme) { @@ -1807,5 +1807,16 @@ void register_usertypes(sol::state& lua) // DEFAULT // FLOOR | SAFE | EMPTY */ + + lua.new_usertype( + "SpawnInfo", + "room_template", + &SpawnInfo::room_template, + "grid_entity", + &SpawnInfo::grid_entity, + "x", + &SpawnInfo::x, + "y", + &SpawnInfo::y); } }; // namespace NLevel diff --git a/src/game_api/script/usertypes/screen_lua.cpp b/src/game_api/script/usertypes/screen_lua.cpp index d7847429d..42cb1b41b 100644 --- a/src/game_api/script/usertypes/screen_lua.cpp +++ b/src/game_api/script/usertypes/screen_lua.cpp @@ -136,6 +136,13 @@ void register_usertypes(sol::state& lua) sol::base_classes, sol::bases()); + lua.new_usertype( + "SpearDanglerAnimFrames", + "column", + &SpearDanglerAnimFrames::column, + "row", + &SpearDanglerAnimFrames::row); + auto screenmenu_type = lua.new_usertype("ScreenMenu", sol::base_classes, sol::bases()); screenmenu_type["tunnel_background"] = &ScreenMenu::tunnel_background; screenmenu_type["cthulhu_disc"] = &ScreenMenu::cthulhu_disc; @@ -482,6 +489,13 @@ void register_usertypes(sol::state& lua) sol::base_classes, sol::bases()); + lua.new_usertype( + "OnlineLobbyScreenPlayer", + "character", + &OnlineLobbyScreenPlayer::character, + "ready", + &OnlineLobbyScreenPlayer::ready); + auto screenonlinelobby_type = lua.new_usertype("ScreenOnlineLobby", sol::base_classes, sol::bases()); screenonlinelobby_type["woodpanels_slidein_timer"] = &ScreenOnlineLobby::woodpanels_slidein_timer; screenonlinelobby_type["scroll_unfurl_timer"] = &ScreenOnlineLobby::scroll_unfurl_timer; diff --git a/src/game_api/script/usertypes/socket_lua.cpp b/src/game_api/script/usertypes/socket_lua.cpp index 92fd5bf74..aa4896f12 100644 --- a/src/game_api/script/usertypes/socket_lua.cpp +++ b/src/game_api/script/usertypes/socket_lua.cpp @@ -45,11 +45,19 @@ UdpServer::UdpServer(std::string host_, in_port_t port_, std::function kill_thr.test_and_set(); thr = std::thread(udp_data, std::move(sock), this); } -UdpServer::~UdpServer() +void UdpServer::clear() // TODO: fix and expose: this and the destructor causes deadlock { kill_thr.clear(std::memory_order_release); thr.join(); } +UdpServer::~UdpServer() +{ + if (thr.joinable()) + { + kill_thr.clear(std::memory_order_release); + thr.join(); + } +} using NetFun = int(SOCKET, char*, int, int, sockaddr_in*, int*); NetFun* g_sendto_trampoline{nullptr}; @@ -175,10 +183,14 @@ namespace NSocket { void register_usertypes(sol::state& lua) { + lua.new_usertype( + "UdpServer", + sol::no_constructor); /// 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. lua["udp_listen"] = [](std::string host, in_port_t port, sol::function cb) -> UdpServer* { + // TODO: change the return to std::unique_ptr after fixing the dead lock with the destroctor UdpServer* server = new UdpServer(std::move(host), std::move(port), make_safe_cb(std::move(cb))); return server; }; @@ -225,10 +237,9 @@ void register_usertypes(sol::state& lua) /// 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) - lua["http_get_async"] = [](std::string url, sol::function on_data) -> HttpRequest* + lua["http_get_async"] = [](std::string url, sol::function on_data) { - auto req = new HttpRequest(std::move(url), make_safe_cb(std::move(on_data))); - return req; + new HttpRequest(std::move(url), make_safe_cb(std::move(on_data))); }; } }; // namespace NSocket diff --git a/src/game_api/script/usertypes/socket_lua.hpp b/src/game_api/script/usertypes/socket_lua.hpp index 7f38ad6b0..972f8af99 100644 --- a/src/game_api/script/usertypes/socket_lua.hpp +++ b/src/game_api/script/usertypes/socket_lua.hpp @@ -16,6 +16,7 @@ class UdpServer UdpServer(std::string host, in_port_t port, std::function cb); ~UdpServer(); + void clear(); std::string host; in_port_t port; diff --git a/src/game_api/script/usertypes/vanilla_render_lua.cpp b/src/game_api/script/usertypes/vanilla_render_lua.cpp index 3e3fcf425..072cb0218 100644 --- a/src/game_api/script/usertypes/vanilla_render_lua.cpp +++ b/src/game_api/script/usertypes/vanilla_render_lua.cpp @@ -790,8 +790,6 @@ void register_usertypes(sol::state& lua) &TextRenderingInfo::height, "special_texture_id", &TextRenderingInfo::special_texture_id, - "font", - &TextRenderingInfo::font, "get_dest", &TextRenderingInfo::get_dest, "get_source", @@ -801,7 +799,11 @@ void register_usertypes(sol::state& lua) "rotate", &TextRenderingInfo::rotate, "set_text", - &TextRenderingInfo::set_textx); + &TextRenderingInfo::set_textx, + "get_font", + &TextRenderingInfo::get_font, + "set_font", + &TextRenderingInfo::set_font); /* TextRenderingInfo // new // TextRenderingInfo:new(string text, float scale_x, float scale_y, VANILLA_TEXT_ALIGNMENT alignment, VANILLA_FONT_STYLE fontstyle)