diff --git a/docs/game_data/spel2.lua b/docs/game_data/spel2.lua index a49230c85..d9a632325 100644 --- a/docs/game_data/spel2.lua +++ b/docs/game_data/spel2.lua @@ -2079,7 +2079,7 @@ do ---@class Items ---@field player_count integer - ---@field saved_pets_count integer + ---@field saved_pets_count integer @Only for the level transition, the actual number is held in player inventory ---@field saved_pets ENT_TYPE[] @size: 4 @Pet information for level transition ---@field is_pet_cursed boolean[] @size: 4 ---@field is_pet_poisoned boolean[] @size: 4 @@ -2364,7 +2364,6 @@ do ---@field slide_position number ---@class GameProps - ---@field buttons integer[] @size: MAX_PLAYERS @Used for player input and might be used for some menu inputs not found in buttons_menu. You can probably capture and edit this in ON.POST_PROCESS_INPUT. These are raw inputs, without things like autorun applied. ---@field input integer[] @size: MAX_PLAYERS @Used for player input and might be used for some menu inputs not found in buttons_menu. You can probably capture and edit this in ON.POST_PROCESS_INPUT. These are raw inputs, without things like autorun applied. ---@field input_previous integer[] @size: MAX_PLAYERS ---@field input_menu MENU_INPUT @Inputs used to control all the menus, separate from player inputs. You can probably capture and edit this in ON.POST_PROCESS_INPUT @@ -2466,11 +2465,11 @@ function PRNG:random(min, max) end ---@field texture_num integer ---@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? + ---@field get_second_texture fun(self): TEXTURE? + ---@field get_third_texture fun(self): TEXTURE? ---@field set_second_texture fun(self, texture_id: TEXTURE): boolean ---@field set_third_texture fun(self, texture_id: TEXTURE): boolean - ---@field set_texture_num fun(self, texture_id: integer): boolean @Set the number of textures that may be used, need to have them set before for it to work + ---@field set_texture_num fun(self, num: integer): boolean @Set the number of textures that may be used, need to have them set before for it to work ---@field set_pre_virtual fun(self, entry: RENDER_INFO_OVERRIDE, fun: function): CallbackId @Hooks before the virtual function at index `entry`. ---@field set_post_virtual fun(self, entry: RENDER_INFO_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. @@ -2669,7 +2668,7 @@ function Entity:destroy_recursive() end ---@field set_position fun(self, to_x: number, to_y: number): nil @Set the absolute position of an entity and offset all rendering related things accordingly to teleport without any interpolation or graphical glitches. If the camera is focused on the entity, it is also moved. ---@field process_input fun(self): nil ---@field cutscene CutsceneBehavior - ---@field clear_cutscene any @[](Movable&movable){deletemovable.cutscene_behavior + ---@field clear_cutscene fun(self): nil ---@field get_base_behavior fun(self, state_id: integer): VanillaMovableBehavior @Gets a vanilla behavior from this movable, needs to be called before `clear_behaviors`
but the returned values are still valid after a call to `clear_behaviors` ---@field add_behavior fun(self, behavior: MovableBehavior): nil @Add a behavior to this movable, can be either a `VanillaMovableBehavior` or a
`CustomMovableBehavior` ---@field clear_behavior fun(self, behavior: MovableBehavior): nil @Clear a specific behavior of this movable, can be either a `VanillaMovableBehavior` or a
`CustomMovableBehavior`, a behavior with this behaviors `state_id` may be required to
run this movables statemachine without crashing, so add a new one if you are not sure @@ -2771,6 +2770,7 @@ function Movable:generic_update_world(move, sprint_factor, disable_gravity, on_r ---@field time_of_death integer @Is set to state.time_total when player dies in coop (to determinate who should be first to re-spawn from coffin) ---@field held_item ENT_TYPE @Used to transfer information to transition/next level. Is not updated during a level
You can use `ON.PRE_LEVEL_GENERATION` to access/edit this ---@field held_item_metadata integer @Metadata of the held item (health, is cursed etc.)
Used to transfer information to transition/next level. Is not updated during a level
You can use `ON.PRE_LEVEL_GENERATION` to access/edit this + ---@field saved_pets_count integer ---@field mount_type ENT_TYPE @Used to transfer information to transition/next level (player rading a mout). Is not updated during a level
You can use `ON.PRE_LEVEL_GENERATION` to access/edit this ---@field mount_metadata integer @Metadata of the mount (health, is cursed etc.)
Used to transfer information to transition/next level (player rading a mout). Is not updated during a level
You can use `ON.PRE_LEVEL_GENERATION` to access/edit this ---@field kills_level integer @@ -4037,7 +4037,6 @@ function Movable:generic_update_world(move, sprint_factor, disable_gravity, on_r ---@field smoke2 ParticleEmitterInfo ---@class CookFire : Torch - ---@field lit any @&Torch::is_lit ---@field emitted_light Illumination ---@field particles_smoke ParticleEmitterInfo ---@field particles_flames ParticleEmitterInfo @@ -4733,11 +4732,10 @@ function MovableBehavior:get_state_id() end ---@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. ---@field theme integer @Theme index. Probably shouldn't collide with the vanilla ones. Purpose unknown. - ---@field base_theme integer @Base THEME to load enabled functions from, when no other theme is specified. ---@field textures table @Add TEXTUREs here to override different dynamic textures. - ---@field override any @theme_override ---@field pre fun(self, index: THEME_OVERRIDE, func_: function): nil @Set a callback to be called before this theme function. ---@field post fun(self, index: THEME_OVERRIDE, func_: function): nil @Set a callback to be called after this theme function, to fix some changes it did for example. + ---@field base_theme integer @Base THEME to load enabled functions from, when no other theme is specified. ---@field reset_theme_flags fun(self): nil ---@field init_flags fun(self): nil ---@field init_level fun(self): nil @@ -4749,7 +4747,7 @@ function MovableBehavior:get_state_id() end ---@field add_idol fun(self): nil ---@field add_vault fun(self): nil ---@field add_coffin fun(self): nil - ---@field add_feeling any @&CustomTheme::add_feeling + ---@field add_special_feeling fun(self): nil ---@field spawn_level fun(self): nil ---@field spawn_border fun(self): nil ---@field post_process_level fun(self): nil @@ -4789,6 +4787,22 @@ function MovableBehavior:get_state_id() end ---@field spawn_decoration2 fun(self): nil ---@field spawn_extra fun(self): nil ---@field do_procedural_spawn fun(self, info: SpawnInfo): nil +local CustomTheme = nil +---To disable or enable theme functions using the base_theme. +---@param index THEME_OVERRIDE +---@param enabled_ boolean +---@return nil +function CustomTheme:override(index, enabled_) end +---To override a theme function with another theme. +---@param index THEME_OVERRIDE +---@param theme_ integer +---@return nil +function CustomTheme:override(index, theme_) end +---To override a theme function with a lua function. +---@param index THEME_OVERRIDE +---@param func_ function +---@return nil +function CustomTheme:override(index, func_) end ---@class PreLoadLevelFilesContext ---@field override_level_files fun(self, levels: string[]): nil @Block all loading `.lvl` files and instead load the specified `.lvl` files. This includes `generic.lvl` so if you need it specify it here.
All `.lvl` files are loaded relative to `Data/Levels`, but they can be completely custom `.lvl` files that ship with your mod so long as they are in said folder.
Use at your own risk, some themes/levels expect a certain level file to be loaded. @@ -4814,7 +4828,7 @@ function MovableBehavior:get_state_id() end ---@field flags integer ---@field flags2 integer ---@field flags3 integer - ---@field level_config integer[] + ---@field level_config integer[] @size: 17 ---@class PostRoomGenerationContext ---@field set_room_template fun(self, x: integer, y: integer, layer: LAYER, room_template: ROOM_TEMPLATE): boolean @Set the room template at the given index and layer, returns `false` if the index is outside of the level. @@ -5138,8 +5152,8 @@ function GuiDrawContext:win_pushid(id) end ---@class ImGuiIO ---@field displaysize Vec2 ---@field framerate number - ---@field wantkeyboard any @wantkeyboard - ---@field keys boolean[] @size: ImGuiKey_COUNT + ---@field wantkeyboard boolean + ---@field keys boolean[] @size: 652 ---@field keydown fun(key: number | string): boolean ---@field keypressed fun(key: number | string, repeat?: boolean ): boolean ---@field keyreleased fun(key: number | string): boolean @@ -5147,8 +5161,8 @@ function GuiDrawContext:win_pushid(id) end ---@field keyshift boolean ---@field keyalt boolean ---@field keysuper boolean - ---@field modifierdown any @modifierdown - ---@field wantmouse any @wantmouse + ---@field modifierdown fun(self, chord: integer): boolean + ---@field wantmouse boolean ---@field mousepos Vec2 ---@field mousedown boolean[] @size: 5 ---@field mouseclicked boolean[] @size: 5 @@ -5156,7 +5170,7 @@ function GuiDrawContext:win_pushid(id) end ---@field mousereleased boolean[] @size: 5 ---@field mousewheel number ---@field gamepad Gamepad - ---@field gamepads any @[](unsignedintindex){g_WantUpdateHasGamepad=true + ---@field gamepads fun(self, index: integer): Gamepad ---@field showcursor boolean ---@class VanillaRenderContext @@ -5384,7 +5398,7 @@ function VanillaRenderContext:draw_world_poly_filled(points, color) end function VanillaRenderContext:draw_world_poly_filled(points, color) end ---@class TextureRenderingInfo - ---@field new any @sol::constructors{} ---@field x number ---@field y number ---@field destination_bottom_left_x number @destination is relative to the x,y centerpoint @@ -5417,7 +5431,7 @@ function VanillaRenderContext:draw_world_poly_filled(points, color) end ---@field center fun(self): Vec2 @Get's approximated center of a letter by finding the highest and lowest values, then finding the center of a rectangle build from those values ---@class TextRenderingInfo - ---@field new any @sol::initializers(&TextRenderingInfo_ctor + ---@field new any @initializers(TextRenderingInfo_ctor, TextRenderingInfo_ctor2) ---@field x number ---@field y number ---@field text_length integer @You can also just use `#` operator on the whole TextRenderingInfo to get the text lenght @@ -5496,10 +5510,19 @@ function VanillaRenderContext:draw_world_poly_filled(points, color) end ---@class Vec2 ---@field x number ---@field y number - ---@field rotate fun(self, angle: number, px: number, py: number): Vec2 ---@field distance_to fun(self, other: Vec2): number @Just simple pythagoras theorem ---@field set fun(self, other: Vec2): Vec2 ---@field split fun(self): number, number +local Vec2 = nil +---@param angle number +---@param px number +---@param py number +---@return Vec2 +function Vec2:rotate(angle, px, py) end +---@param angle number +---@param p Vec2 +---@return Vec2 +function Vec2:rotate(angle, p) end ---@class AABB ---@field left number @@ -5577,13 +5600,19 @@ function Triangle:is_point_inside(x, y, epsilon) end ---@field top_left_x number ---@field top_left_y number ---@field get_AABB fun(self): AABB @Returns the max/min values of the Quad - ---@field offset fun(self, off_x: number, off_y: number): Quad ---@field rotate fun(self, angle: number, px: number, py: number): Quad @Rotates a Quad by an angle, px/py are not offsets, use `:get_AABB():center()` to get approximated center for simetrical quadrangle ---@field flip_horizontally fun(self): Quad ---@field flip_vertically fun(self): Quad ---@field set fun(self, other: Quad): Quad ---@field split fun(self): Vec2, Vec2, Vec2, Vec2 @Returns the corners in order: bottom_left, bottom_right, top_right, top_left local Quad = nil +---@param off Vec2 +---@return Quad +function Quad:offset(off) end +---@param off_x number +---@param off_y number +---@return Quad +function Quad:offset(off_x, off_y) end ---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` ---@param p Vec2 @@ -5953,7 +5982,7 @@ function Quad:is_point_inside(x, y, epsilon) end ---@field sequence_state integer ---@field animation_timer integer ---@field constellation_text_opacity number - ---@field constellation_text number + ---@field constellation_text string ---@field explosion_and_loop SoundMeta ---@field music SoundMeta @@ -6022,7 +6051,7 @@ function Quad:is_point_inside(x, y, epsilon) end ---@field entire_book TextureRenderingInfo ---@field fade_timer integer ---@field page_timer integer - ---@field opacity integer + ---@field opacity number ---@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_PRE_JOURNAL_PAGE](#ON-RENDER_PRE_JOURNAL_PAGE)) ---@class JournalPage @@ -6447,7 +6476,6 @@ function LogicMagmamanSpawn:remove_spawn(ms) end ---@class PauseAPI ---@field pause PAUSE_TYPE @Current pause state bitmask. Use custom PAUSE_TYPE.PRE_✱ (or multiple) to freeze the game at the specified callbacks automatically. Checked after the matching ON update callbacks, so can be set on the same callback you want to block at the latest. Vanilla PAUSE flags will be forwarded to state.pause, but use of vanilla PAUSE flags is discouraged and might not work with other PauseAPI features. - ---@field pause any @sol::property(&PauseAPI::get_pause ---@field pause_type PAUSE_TYPE @Pause mask to toggle when using the PauseAPI methods to set or get pause state. ---@field pause_trigger PAUSE_TRIGGER @Bitmask for conditions when the current `pause_type` should be automatically enabled in `pause`, can have multiple conditions. ---@field pause_screen PAUSE_SCREEN @Bitmask to only enable PAUSE_TRIGGER.SCREEN during specific SCREEN, or any screen when NONE. @@ -11450,12 +11478,10 @@ YANG = { ---@alias YANG integer local MAX_PLAYERS = 4 ----@alias in_port_t number ---@class Logic ---@alias OnlinePlayerShort any ---@alias UdpServer any ----@alias Texture any ---@alias SpearDanglerAnimFrames any ---@alias OnlineLobbyScreenPlayer any ---@alias SoundCallbackFunction function diff --git a/docs/generate.py b/docs/generate.py index 1a7072f26..fbc2fdc73 100644 --- a/docs/generate.py +++ b/docs/generate.py @@ -365,20 +365,20 @@ def print_lf(lf): 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 | set:find(any key) | Searches for the value in set, returns the value itself or nil if not found, only available for simple values that are comparable") 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 | set:erase(any key) | Removes element from set") +print("nil | map:erase(any key) | Removes element from map") 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("nil | set:insert(int order, any key) | 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") diff --git a/docs/generate_emmylua.py b/docs/generate_emmylua.py index 89e01ec14..d7d73e036 100644 --- a/docs/generate_emmylua.py +++ b/docs/generate_emmylua.py @@ -26,15 +26,18 @@ "u16string": "string", "char16_t*": "string", "string_view": "string", - "pair": "tuple", + "std::pair": "tuple", "std::": "", "sol::": "", + "unsigned": "", " = nullopt": "", "void": "", "constexpr": "", - "inline": "", + "inline ": "", "[[nodiscard]]": "", "[[maybe_unused]]": "", + "self_return<&": "", + ">()": "", "...va:": "...ent_type:", "set<": "Array<", "span<": "Array<", @@ -297,8 +300,6 @@ def main(): else "" ) if "function" in var and var["function"]: - # if var["name"] == "clear_behaviors": - # gu.breakpoint() signature = var["signature"] m = re.search(r"\s*(.*)\s+([^\(]*)\((.*)\)", signature) if m: @@ -442,12 +443,10 @@ def main(): print( """local MAX_PLAYERS = 4 ----@alias in_port_t number ---@class Logic ---@alias OnlinePlayerShort any ---@alias UdpServer any ----@alias Texture any ---@alias SpearDanglerAnimFrames any ---@alias OnlineLobbyScreenPlayer any ---@alias SoundCallbackFunction function""" @@ -464,13 +463,10 @@ def main(): # Replace some things final_replace_stuff = { - " ---@field menu_text_opacity number\n ---@field menu_text_opacity number": "---@field menu_text_opacity number", "---@field find_all_short_tile_codes fun(self, layer: LAYER, short_tile_code: SHORT_TILE_CODE): Array>": "---@field find_all_short_tile_codes fun(self, layer: LAYER, short_tile_code: SHORT_TILE_CODE): integer[][]", - "---@field keysdown boolean [] @size: ImGuiKey_COUNT": "---@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 keydown any @keydown": "---@field keydown fun(key: number | string): boolean", "---@field keypressed any @keypressed": "---@field keypressed fun(key: number | string, repeat?: boolean ): boolean", "---@field keyreleased any @keyreleased": "---@field keyreleased fun(key: number | string): boolean", - "---@field gamepad any @sol::property([](){g_WantUpdateHasGamepad=true;returnget_gamepad()/**/;})": "---@field gamepad Gamepad", "---@field user_data fun(self): nil": "---@field user_data table?", """---@param number> p tuple()": "", + "unsigned": "", + "sol::no_constructor": "", # special "variadic_args va": "ENT_TYPE, ENT_TYPE...", "EmittedParticlesInfo": "array", @@ -211,6 +215,22 @@ def cb_signature_dict(ret, param): "param": param, } +def custom_split(var): + result = [] + level = 0 + current = "" + for char in var: + if char == ',' and level == 0: + result.append(current.strip()) + current = "" + else: + current += char + if char == '[' or char == '(' or char == '<': + level += 1 + elif char == ']' or char == ')' or char == '>': + level -= 1 + result.append(current.strip()) + return result def get_cb_signature(text): signature_ms = reSignature.findall(text) @@ -615,11 +635,11 @@ def run_parse(): for file in api_files: data = open(file, "r").read() data = data.replace("\n", "") - data = re.sub(r" ", "", data) + data = fix_spaces(data) reParticleHelper = re.compile(r"MakeParticleMemberAccess<(.+?)>\(\)") data = reParticleHelper.sub(r"\1", data) m = re.findall( - r'(auto([a-z]+_type)=)?lua\.new_usertype\<([^\>]*?)\>\s*\(\s*"([^"]*)",?(.*?)\);', + r'(auto ([a-z]+_type) =)? lua\.new_usertype\<([^\>]*?)\>\s*\(\s*"([^"]*)",?(.*?)\);', data, ) for type in m: @@ -630,7 +650,7 @@ def run_parse(): if container: extra = [] n = re.findall( - r"(?", attr) if bm: - base = bm.group(1) + base = bm.group(1).replace(" ", "") attr = attr.replace('",', ",") attr = attr.split('"') vars = [] @@ -673,10 +693,10 @@ def run_parse(): continue if not var: continue - var = var.split(",") + var = custom_split(var) if len(var) < 2: continue - if var[0] == "sol::base_classes" or var[0] == "sol::no_constructor": + if var[0] == "sol::no_constructor": continue if "NoDoc" in var[0]: skip = True @@ -691,11 +711,11 @@ def run_parse(): var[1] = var[1][:-1] var_name = var[0] - cpp = var[1] + cpp = replace_fun(var[1]) # should probably be done later, so the regex doesn't have to relay on some of the changes, also generate_emmylua.py uses some unique formats replacements if var[1].startswith("sol::property"): param_match = re.match( - rf"sol::property\(\[\]\({underlying_cpp_type['name']}&(\w+)\)", + rf"property\(\[\]\({underlying_cpp_type['name']}&(\w+)\)", cpp, ) if param_match: @@ -711,8 +731,8 @@ def run_parse(): cpp_name = cpp else: cpp_name = cpp[cpp.find("::") + 2 :] if cpp.find("::") >= 0 else cpp - - if var[0].startswith("sol::constructors"): + + if var_name.startswith("sol::constructors"): for fun in underlying_cpp_type["member_funs"][cpp_type]: param = fun["param"] @@ -725,6 +745,34 @@ def run_parse(): "comment": fun["comment"], } ) + elif cpp.startswith("[]("): + param_match = re.match(r"\[\]\(([\w &*:,]+)?\) -> ([\w.*&<>\?\[\]:]+)?(?: )?{", cpp) + if param_match: + ret = param_match.group(2) + if ret is None: + ret = "nil" + + sig = param_match.group(1) + if sig.startswith(cpp_type): # remove the self parameter if present + first_param_end = sig.find(",") + 1 + if first_param_end == 0: + sig = "" + else: + sig = sig[first_param_end:].strip() + vars.append( + { + "name": var_name, + "type": cpp, + "signature": f"{ret} {var_name}({sig})", + "comment": "", + "function": True, + "cb_signature": "", + } + ) + elif var_name.startswith("sol::base_classes"): + bm = re.search(r"bases<([^\]]*)", cpp) + if bm: + base = bm.group(1).replace(" ", "") elif cpp_name in underlying_cpp_type["member_funs"]: for fun in underlying_cpp_type["member_funs"][cpp_name]: ret = fun["return"] or "nil" @@ -779,7 +827,7 @@ def run_parse(): ) else: m_return_type = re.search( - r"->([:<>\w*]+){", var[1] + r"-> ([:<>\w\[\], *]+) {", var[1] ) # Use var[1] instead of cpp because it could be replaced on the sol::property stuff if m_return_type: type = replace_fun(m_return_type[1]) diff --git a/docs/src/includes/_enums.md b/docs/src/includes/_enums.md index 274846aab..c814abaf5 100644 --- a/docs/src/includes/_enums.md +++ b/docs/src/includes/_enums.md @@ -845,7 +845,7 @@ Name | Data | Description [DEATH](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.DEATH) | ON::DEATH | Runs when entering the death screen.
[SPACESHIP](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.SPACESHIP) | ON::SPACESHIP | Runs when entering the olmecship cutscene after [Tiamat](#Tiamat).
[WIN](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.WIN) | ON::WIN | Runs when entering any winning cutscene, including the constellation.
-[CREDITS](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.CREDITS) | ON::CREDITS | Runs when entering the credits.
+[CREDITS](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.CREDITS) | ON::CREDITS | Runs when entering the credits screen.
[SCORES](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.SCORES) | ON::SCORES | Runs when entering the final score celebration screen of a normal or hard ending.
[CONSTELLATION](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.CONSTELLATION) | ON::CONSTELLATION | Runs when entering the turning into constellation cutscene after cosmic ocean.
[RECAP](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.RECAP) | ON::RECAP | Runs when entering the Dear Journal screen after final scores.
diff --git a/docs/src/includes/_events.md b/docs/src/includes/_events.md index d03a84b5c..41fa08125 100644 --- a/docs/src/includes/_events.md +++ b/docs/src/includes/_events.md @@ -130,7 +130,7 @@ Runs when entering any winning cutscene, including the constellation.
> Search script examples for [ON.CREDITS](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.CREDITS) -Runs when entering the credits.
+Runs when entering the credits screen.
## ON.SCORES diff --git a/docs/src/includes/_globals.md b/docs/src/includes/_globals.md index 971492bff..56c0f4265 100644 --- a/docs/src/includes/_globals.md +++ b/docs/src/includes/_globals.md @@ -165,17 +165,17 @@ any | set:at(int order) | Returns elements in order, it's not an index as sets d 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 | set:find(any key) | Searches for the value in set, returns the value itself or nil if not found, only available for simple values that are comparable any | map:find(any key) | Searches for the key in map, returns the value itself or nil if not found, only available for simple keys that are comparable nil | vector:erase(int index) | Removes element at given index, the rest of elements shift down so that the vector stays contiguous -nil | set:erase(any value) | Removes element from set -nil | map:erase(any key) | Removes element from map by key +nil | set:erase(any key) | Removes element from set +nil | map:erase(any key) | Removes element from map nil | vector:clear() | Removes all elements from vector nil | set:clear() | Removes all elements from set nil | map:clear() | Removes all elements from map nil | vector:insert(int index, any element) | Inserts element at given index, the rest of elements shift up in index -nil | set:insert(int order, any 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` +nil | set:insert(int order, any key) | The order param doesn't acutally matter and can be set to nil +nil | map:insert(any key, any value)? | unsure, probably easier to just use `map[key] = value` # Functions The game functions like `spawn` use [level coordinates](#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. diff --git a/docs/src/includes/_types.md b/docs/src/includes/_types.md index a4fe9445c..fea7b567e 100644 --- a/docs/src/includes/_types.md +++ b/docs/src/includes/_types.md @@ -523,6 +523,7 @@ int | [kapala_blood_amount](https://github.com/spelunky-fyi/overlunky/search?l=L int | [time_of_death](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=time_of_death) | Is set to state.time_total when player dies in coop (to determinate who should be first to re-spawn from coffin) [ENT_TYPE](#ENT_TYPE) | [held_item](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=held_item) | Used to transfer information to transition/next level. Is not updated during a level
You can use `ON.PRE_LEVEL_GENERATION` to access/edit this int | [held_item_metadata](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=held_item_metadata) | Metadata of the held item (health, is cursed etc.)
Used to transfer information to transition/next level. Is not updated during a level
You can use `ON.PRE_LEVEL_GENERATION` to access/edit this +int | [saved_pets_count](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=saved_pets_count) | [ENT_TYPE](#ENT_TYPE) | [mount_type](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=mount_type) | Used to transfer information to transition/next level (player rading a mout). Is not updated during a level
You can use `ON.PRE_LEVEL_GENERATION` to access/edit this int | [mount_metadata](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=mount_metadata) | Metadata of the mount (health, is cursed etc.)
Used to transfer information to transition/next level (player rading a mout). Is not updated during a level
You can use `ON.PRE_LEVEL_GENERATION` to access/edit this int | [kills_level](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=kills_level) | @@ -839,7 +840,6 @@ Control the pause API Type | Name | Description ---- | ---- | ----------- [PAUSE_TYPE](#PAUSE_TYPE) | [pause](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=pause) | Current pause state bitmask. Use custom [PAUSE_TYPE](#PAUSE_TYPE).PRE_✱ (or multiple) to freeze the game at the specified callbacks automatically. Checked after the matching [ON](#ON) update callbacks, so can be set on the same callback you want to block at the latest. Vanilla [PAUSE](#PAUSE) flags will be forwarded to state.pause, but use of vanilla [PAUSE](#PAUSE) flags is discouraged and might not work with other [PauseAPI](#PauseAPI) features. - | [pause](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=pause) | [PAUSE_TYPE](#PAUSE_TYPE) | [pause_type](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=pause_type) | Pause mask to toggle when using the [PauseAPI](#PauseAPI) methods to set or get pause state. [PAUSE_TRIGGER](#PAUSE_TRIGGER) | [pause_trigger](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=pause_trigger) | Bitmask for conditions when the current `pause_type` should be automatically enabled in `pause`, can have multiple conditions. [PAUSE_SCREEN](#PAUSE_SCREEN) | [pause_screen](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=pause_screen) | Bitmask to only enable [PAUSE_TRIGGER](#PAUSE_TRIGGER).[SCREEN](#SCREEN) during specific [SCREEN](#SCREEN), or any screen when NONE. @@ -884,6 +884,7 @@ 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(Vec2 off)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=offset) | [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) | @@ -925,11 +926,11 @@ bool | [render_inactive](https://github.com/spelunky-fyi/overlunky/search?l=Lua& int | [texture_num](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=texture_num) | [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) | +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) | bool | [set_second_texture(TEXTURE texture_id)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_second_texture) | bool | [set_third_texture(TEXTURE texture_id)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_third_texture) | -bool | [set_texture_num(int texture_id)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_texture_num) | Set the number of textures that may be used, need to have them set before for it to work +bool | [set_texture_num(int num)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_texture_num) | Set the number of textures that may be used, need to have them set before for it to work [CallbackId](#Aliases) | [set_pre_virtual(RENDER_INFO_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(RENDER_INFO_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. @@ -1046,6 +1047,7 @@ Type | Name | Description 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) | +[Vec2](#Vec2) | [rotate(float angle, Vec2 p)](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 [Vec2](#Vec2) | [set(Vec2 other)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set) | tuple<float, float> | [split()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=split) | @@ -1094,8 +1096,8 @@ 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) | - | [wantkeyboard](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=wantkeyboard) | True if anyone else (i.e. some input box, OL hotkey) is already capturing keyboard or reacted to this keypress and you probably shouldn't.
Set this to true every GUIFRAME while you want to capture keyboard and disable UI key bindings and game keys. Won't affect UI or game keys on this frame though, that train has already sailed. Also see [Bucket](#Bucket)::[Overlunky](#Overlunky) for other ways to override key bindings.
Do not set this to false, unless you want the player input to bleed through input fields.
-bool | [keys[ImGuiKey_COUNT]](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=keys) | ZeroIndexArray of currently held keys, indexed by [KEY](#KEY) <= 0xFF
+bool | [wantkeyboard](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=wantkeyboard) | True if anyone else (i.e. some input box, OL hotkey) is already capturing keyboard or reacted to this keypress and you probably shouldn't.
Set this to true every GUIFRAME while you want to capture keyboard and disable UI key bindings and game keys. Won't affect UI or game keys on this frame though, that train has already sailed. Also see [Bucket](#Bucket)::[Overlunky](#Overlunky) for other ways to override key bindings.
Do not set this to false, unless you want the player input to bleed through input fields.
+array<bool, 652> | [keys](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=keys) | ZeroIndexArray of currently held keys, indexed by [KEY](#KEY) <= 0xFF
| [keydown](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=keydown) | Returns true if key or chord is down.
bool keydown([KEY](#KEY) keychord)
bool keydown(char key)
| [keypressed](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=keypressed) | Returns true if key or chord was pressed this GUIFRAME.
bool keypressed([KEY](#KEY) keychord, bool repeat = false)
bool keypressed(char key, bool repeat = false)
| [keyreleased](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=keyreleased) | Returns true if key or chord was released this GUIFRAME.
bool keyreleased([KEY](#KEY) keychord)
bool keyreleased(char key)
@@ -1103,16 +1105,16 @@ bool | [keyctrl](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=keyctr 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) | - | [modifierdown](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=modifierdown) | bool modifierdown([KEY](#KEY) keychord)
Returns true if modifiers in chord are down, ignores other keys in chord.
- | [wantmouse](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=wantmouse) | True if anyone else (i.e. hovering some window) is already capturing mouse and you probably shouldn't.
Set this to true if you want to capture mouse and override UI mouse binding.
+bool | [modifierdown(int chord)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=modifierdown) | bool modifierdown([KEY](#KEY) keychord)
Returns true if modifiers in chord are down, ignores other keys in chord.
+bool | [wantmouse](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=wantmouse) | True if anyone else (i.e. hovering some window) is already capturing mouse and you probably shouldn't.
Set this to true if you want to capture mouse and override UI mouse binding.
[Vec2](#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) | -bool | [mousereleased[5]](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=mousereleased) | +array<bool, 5> | [mousedown](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=mousedown) | +array<bool, 5> | [mouseclicked](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=mouseclicked) | +array<bool, 5> | [mousedoubleclicked](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=mousedoubleclicked) | +array<bool, 5> | [mousereleased](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=mousereleased) | 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.
+[Gamepad](#Gamepad) | [gamepads(int index)](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) | True when the cursor is visible.
Set to true to force the cursor visible.
### InputMapping @@ -1377,7 +1379,7 @@ array<[ThemeInfo](#ThemeInfo), 18> | [themes](https://github.com/spelunky- 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) | int | [flags3](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=flags3) | -array<int> | [level_config](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=level_config) | +array<int, 17> | [level_config](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=level_config) | ## Lighting types @@ -1969,7 +1971,7 @@ int | [max_page_count](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q= [TextureRenderingInfo](#TextureRenderingInfo) | [entire_book](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=entire_book) | int | [fade_timer](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=fade_timer) | int | [page_timer](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=page_timer) | -int | [opacity](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=opacity) | +float | [opacity](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=opacity) | 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_PRE_JOURNAL_PAGE](#ON-RENDER_PRE_JOURNAL_PAGE)) ### MenuScreenPanels @@ -2368,7 +2370,7 @@ Type | Name | Description int | [sequence_state](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=sequence_state) | int | [animation_timer](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=animation_timer) | float | [constellation_text_opacity](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=constellation_text_opacity) | -float | [constellation_text](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=constellation_text) | +string | [constellation_text](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=constellation_text) | [SoundMeta](#SoundMeta) | [explosion_and_loop](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=explosion_and_loop) | [SoundMeta](#SoundMeta) | [music](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=music) | @@ -2874,7 +2876,6 @@ array<int, MAX_PLAYERS> | [buttons_movement](https://github.com/spelunky-f Type | Name | Description ---- | ---- | ----------- -array<int, MAX_PLAYERS> | [buttons](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=buttons) | Used for player input and might be used for some menu inputs not found in buttons_menu. You can probably capture and edit this in [ON](#ON).POST_PROCESS_INPUT. These are raw inputs, without things like autorun applied. array<int, MAX_PLAYERS> | [input](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=input) | Used for player input and might be used for some menu inputs not found in buttons_menu. You can probably capture and edit this in [ON](#ON).POST_PROCESS_INPUT. These are raw inputs, without things like autorun applied. array<int, MAX_PLAYERS> | [input_previous](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=input_previous) | [MENU_INPUT](#MENU_INPUT) | [input_menu](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=input_menu) | Inputs used to control all the menus, separate from player inputs. You can probably capture and edit this in [ON](#ON).POST_PROCESS_INPUT @@ -2890,7 +2891,7 @@ Used in [StateMemory](#StateMemory) Type | Name | Description ---- | ---- | ----------- int | [player_count](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=player_count) | -int | [saved_pets_count](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=saved_pets_count) | +int | [saved_pets_count](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=saved_pets_count) | Only for the level transition, the actual number is held in player inventory array<[ENT_TYPE](#ENT_TYPE), 4> | [saved_pets](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=saved_pets) | [Pet](#Pet) information for level transition array<bool, 4> | [is_pet_cursed](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_pet_cursed) | array<bool, 4> | [is_pet_poisoned](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_pet_poisoned) | @@ -3113,7 +3114,7 @@ bool | [set_font(TEXTURE id)](https://github.com/spelunky-fyi/overlunky/search?l ### TextureDefinition -Use `TextureDefinition.new()` to get a new instance to this and pass it to define_entity_texture. +Use `TextureDefinition.new()` to get a new instance to this and pass it to [define_texture](#define_texture). `width` and `height` always have to be the size of the image file. They should be divisible by `tile_width` and `tile_height` respectively. `tile_width` and `tile_height` define the size of a single tile, the image will automatically be divided into these tiles. Tiles are labeled in sequence starting at the top left, going right and down at the end of the image (you know, like sentences work in the English language). Use those numbers in `Entity::animation_frame`. @@ -3212,11 +3213,13 @@ Type | Name | Description [CustomTheme](#CustomTheme) | [new()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=CustomTheme) | Create a new theme with base dwelling and id 100. string | [level_file](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=level_file) | Level file to load. Probably doesn't do much in custom themes, especially if you're forcing them in PRE_LOAD_LEVEL_FILES. int | [theme](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=theme) | Theme index. Probably shouldn't collide with the vanilla ones. Purpose unknown. -int | [base_theme](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=base_theme) | Base [THEME](#THEME) to load enabled functions from, when no other theme is specified. map<[DYNAMIC_TEXTURE](#DYNAMIC_TEXTURE), [TEXTURE](#TEXTURE)> | [textures](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=textures) | Add TEXTUREs here to override different dynamic textures. - | [override](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=override) | `override(THEME_OVERRIDE override, bool enabled)` To disable or enable theme functions using the base_theme.
`override(THEME_OVERRIDE override, THEME theme)` To override a theme function with another theme.
`override(THEME_OVERRIDE override, function func)` To override a theme function with a lua function.
+nil | [override(THEME_OVERRIDE index, bool enabled_)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=override) | To disable or enable theme functions using the base_theme. +nil | [override(THEME_OVERRIDE index, int theme_)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=override) | To override a theme function with another theme. +nil | [override(THEME_OVERRIDE index, function func_)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=override) | To override a theme function with a lua function. nil | [pre(THEME_OVERRIDE index, function func_)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=pre) | Set a callback to be called before this theme function. nil | [post(THEME_OVERRIDE index, function func_)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=post) | Set a callback to be called after this theme function, to fix some changes it did for example. +int | [base_theme](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=base_theme) | Base [THEME](#THEME) to load enabled functions from, when no other theme is specified. nil | [reset_theme_flags()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=reset_theme_flags) | nil | [init_flags()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=init_flags) | nil | [init_level()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=init_level) | @@ -3228,7 +3231,7 @@ nil | [add_dirk_coffin()](https://github.com/spelunky-fyi/overlunky/search?l=Lua nil | [add_idol()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=add_idol) | nil | [add_vault()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=add_vault) | nil | [add_coffin()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=add_coffin) | - | [add_feeling](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=add_feeling) | +nil | [add_special_feeling()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=add_special_feeling) | nil | [spawn_level()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=spawn_level) | nil | [spawn_border()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=spawn_border) | nil | [post_process_level()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=post_process_level) | @@ -4217,7 +4220,7 @@ 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) | -span<int> | [get_items()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_items) | +vector<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, 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 @@ -6043,7 +6046,6 @@ Derived from [Entity](#Entity) [Movable](#Movable) [Torch](#Torch) Type | Name | Description ---- | ---- | ----------- - | [lit](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=lit) | [Illumination](#Illumination) | [emitted_light](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=emitted_light) | [ParticleEmitterInfo](#ParticleEmitterInfo) | [particles_smoke](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=particles_smoke) | [ParticleEmitterInfo](#ParticleEmitterInfo) | [particles_flames](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=particles_flames) | @@ -6882,7 +6884,7 @@ nil | [reset_gravity()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q nil | [set_position(float to_x, float to_y)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_position) | Set the absolute position of an entity and offset all rendering related things accordingly to teleport without any interpolation or graphical glitches. If the camera is focused on the entity, it is also moved. nil | [process_input()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=process_input) | [CutsceneBehavior](#CutsceneBehavior) | [cutscene](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=cutscene) | - | [clear_cutscene](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=clear_cutscene) | +nil | [clear_cutscene()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=clear_cutscene) | [VanillaMovableBehavior](#VanillaMovableBehavior) | [get_base_behavior(int state_id)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_base_behavior) | Gets a vanilla behavior from this movable, needs to be called before `clear_behaviors`
but the returned values are still valid after a call to `clear_behaviors` nil | [add_behavior(MovableBehavior behavior)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=add_behavior) | Add a behavior to this movable, can be either a `VanillaMovableBehavior` or a
`CustomMovableBehavior` nil | [clear_behavior(MovableBehavior behavior)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=clear_behavior) | Clear a specific behavior of this movable, can be either a `VanillaMovableBehavior` or a
`CustomMovableBehavior`, a behavior with this behaviors `state_id` may be required to
run this movables statemachine without crashing, so add a new one if you are not sure diff --git a/src/game_api/script/usertypes/color.cpp b/src/game_api/color.cpp similarity index 100% rename from src/game_api/script/usertypes/color.cpp rename to src/game_api/color.cpp diff --git a/src/game_api/color.hpp b/src/game_api/color.hpp index a81e561a6..adebbd022 100644 --- a/src/game_api/color.hpp +++ b/src/game_api/color.hpp @@ -129,7 +129,7 @@ struct Color return {toRGB(r), toRGB(g), toRGB(b), toRGB(a)}; } /// Changes color based on given RGBA colors in 0..255 range - Color& set_rgba(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha) noexcept + Color& set_rgba(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha) { r = red / 255.0f; g = green / 255.0f; @@ -143,7 +143,7 @@ struct Color return (toRGB(a) << 24) + (toRGB(b) << 16) + (toRGB(g) << 8) + (toRGB(r)); } /// Changes color based on given uColor - Color& set_ucolor(const uColor color) noexcept + Color& set_ucolor(const uColor color) { uint8_t red = color & 0xFF; uint8_t green = (color >> 8U) & 0xFF; @@ -153,7 +153,7 @@ struct Color } /// Copies the values of different Color to this one - Color& set(Color& other) noexcept + Color& set(Color& other) { *this = other; return *this; diff --git a/src/game_api/entity.cpp b/src/game_api/entity.cpp index 2d97ca11d..11942972d 100644 --- a/src/game_api/entity.cpp +++ b/src/game_api/entity.cpp @@ -323,10 +323,10 @@ void Entity::set_enable_turning(bool enabled) set_entity_turning(this, enabled); } -std::span Entity::get_items() +std::vector Entity::get_items() { if (items.size) - return std::span(items.uids().begin(), items.uids().end()); + return std::vector(items.uids().begin(), items.uids().end()); return {}; } diff --git a/src/game_api/entity.hpp b/src/game_api/entity.hpp index 4624a0750..b95b94b75 100644 --- a/src/game_api/entity.hpp +++ b/src/game_api/entity.hpp @@ -224,7 +224,7 @@ class Entity void set_enable_turning(bool enabled); - std::span get_items(); + std::vector get_items(); /// Kill entity along with all entities attached to it. Be aware that for example killing push block with this function will also kill anything on top of it, any items, players, monsters etc. /// To avoid that, you can inclusively or exclusively limit certain MASK and ENT_TYPE. Note: the function will first check mask, if the entity doesn't match, it will look in the provided ENT_TYPE's diff --git a/src/game_api/items.hpp b/src/game_api/items.hpp index 1464d2981..faab1c302 100644 --- a/src/game_api/items.hpp +++ b/src/game_api/items.hpp @@ -37,7 +37,7 @@ struct Inventory /// Used to transfer information to transition/next level. Is not updated during a level /// You can use `ON.PRE_LEVEL_GENERATION` to access/edit this int16_t held_item_metadata; - uint8_t unknown5c; // padding? + uint8_t saved_pets_count; int8_t player_slot; /// Used to transfer information to transition/next level (player rading a mout). Is not updated during a level @@ -121,6 +121,7 @@ struct Items std::array saved_pets; std::array is_pet_cursed; std::array is_pet_poisoned; + /// Only for the level transition, the actual number is held in player inventory uint8_t saved_pets_count; uint8_t player_count; diff --git a/src/game_api/math.hpp b/src/game_api/math.hpp index 189a8792d..90a80d278 100644 --- a/src/game_api/math.hpp +++ b/src/game_api/math.hpp @@ -21,7 +21,7 @@ struct Vec2 /// NoDoc Vec2(const ImVec2&) noexcept; - Vec2& rotate(float angle, float px, float py) noexcept + Vec2& rotate(float angle, float px, float py) { const float sin_a{std::sin(angle)}; const float cos_a{std::cos(angle)}; @@ -34,6 +34,10 @@ struct Vec2 *this += p; return *this; } + Vec2& rotate(float angle, const Vec2& p) + { + return rotate(angle, p.x, p.y); + } /// Just simple pythagoras theorem float distance_to(const Vec2 other) const noexcept { @@ -41,7 +45,7 @@ struct Vec2 diff *= diff; // pow return (float)std::sqrt(diff.x + diff.y); } - Vec2& set(const Vec2& other) noexcept + Vec2& set(const Vec2& other) { *this = other; return *this; @@ -177,7 +181,7 @@ struct AABB } /// Fixes the AABB if any of the sides have negative length - AABB& abs() noexcept + AABB& abs() { if (left > right) std::swap(left, right); @@ -188,13 +192,13 @@ struct AABB /// Grows or shrinks the AABB by the given amount in all directions. /// If `amount < 0` and `abs(amount) > right/top - left/bottom` the respective dimension of the AABB will become `0`. - AABB& extrude(float amount) noexcept + AABB& extrude(float amount) { return extrude(amount, amount); } /// Grows or shrinks the AABB by the given amount in each direction. /// If `amount_x/y < 0` and `abs(amount_x/y) > right/top - left/bottom` the respective dimension of the AABB will become `0`. - AABB& extrude(float amount_x, float amount_y) noexcept + AABB& extrude(float amount_x, float amount_y) { left -= amount_x; right += amount_x; @@ -214,7 +218,7 @@ struct AABB return *this; } /// Offsets the AABB by the given offset. - AABB& offset(float off_x, float off_y) noexcept + AABB& offset(float off_x, float off_y) { left += off_x; bottom += off_y; @@ -276,7 +280,7 @@ struct AABB return false; } - AABB& set(const AABB& other) noexcept + AABB& set(const AABB& other) { *this = other; return *this; @@ -305,14 +309,14 @@ struct Triangle Triangle(float ax, float ay, float bx, float by, float cx, float cy) noexcept : A(ax, ay), B(bx, by), C(cx, cy){}; - Triangle& offset(const Vec2& off) noexcept + Triangle& offset(const Vec2& off) { A += off; B += off; C += off; return *this; } - Triangle& offset(float x, float y) noexcept + Triangle& offset(float x, float y) { return offset({x, y}); } @@ -330,7 +334,7 @@ struct Triangle } Triangle& operator=(const Triangle& a) = default; /// Rotate triangle by an angle, the px/py are just coordinates, not offset from the center - Triangle& rotate(float angle, float px, float py) noexcept + Triangle& rotate(float angle, float px, float py) { const float sin_a{std::sin(angle)}; const float cos_a{std::cos(angle)}; @@ -367,7 +371,7 @@ struct Triangle float a_cab = std::abs(std::atan2(ab.y * ac.x - ab.x * ac.y, ab.x * ac.x + ab.y * ac.y)); return {a_abc, a_cab, a_bca}; } - Triangle& scale(float scale) noexcept + Triangle& scale(float scale) { Vec2 centroid = center(); A = (A - centroid) * scale + centroid; @@ -392,7 +396,7 @@ struct Triangle { return is_point_inside(Vec2{x, y}, epsilon); } - Triangle& set(const Triangle& other) noexcept + Triangle& set(const Triangle& other) { *this = other; return *this; @@ -442,8 +446,11 @@ struct Quad result.bottom = std::min({bottom_left_y, bottom_right_y, top_right_y, top_left_y}); return result; } - - Quad& offset(float off_x, float off_y) noexcept + Quad& offset(const Vec2& vec) + { + return offset(vec.x, vec.y); + } + Quad& offset(float off_x, float off_y) { bottom_left_x += off_x; bottom_right_x += off_x; @@ -478,7 +485,7 @@ struct Quad } /// Rotates a Quad by an angle, px/py are not offsets, use `:get_AABB():center()` to get approximated center for simetrical quadrangle - Quad& rotate(float angle, float px, float py) noexcept + Quad& rotate(float angle, float px, float py) { const float sin_a{std::sin(angle)}; const float cos_a{std::cos(angle)}; @@ -502,7 +509,7 @@ struct Quad return *this; } - Quad& flip_horizontally() noexcept + Quad& flip_horizontally() { std::swap(top_left_x, top_right_x); std::swap(top_left_y, top_right_y); @@ -512,7 +519,7 @@ struct Quad return *this; } - Quad& flip_vertically() noexcept + Quad& flip_vertically() { std::swap(top_left_x, bottom_left_x); std::swap(top_left_y, bottom_left_y); @@ -535,7 +542,7 @@ struct Quad { return is_point_inside(Vec2{x, y}, epsilon); } - Quad& set(const Quad& other) noexcept + Quad& set(const Quad& other) { *this = other; return *this; @@ -548,6 +555,8 @@ struct Quad /// 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_quad(Vec2 p, std::optional epsilon); bool is_point_inside_quad(float x, float y, std::optional epsilon); + Quad& offset_quad(const Vec2& off); + Quad& offset_quad(float off_x, float off_y); */ /// Returns the corners in order: bottom_left, bottom_right, top_right, top_left diff --git a/src/game_api/render_api.hpp b/src/game_api/render_api.hpp index fd9534f58..f8cb093a0 100644 --- a/src/game_api/render_api.hpp +++ b/src/game_api/render_api.hpp @@ -356,7 +356,7 @@ struct RenderInfo bool set_second_texture(TEXTURE texture_id); bool set_third_texture(TEXTURE texture_id); /// Set the number of textures that may be used, need to have them set before for it to work - bool set_texture_num(uint32_t texture_id); + bool set_texture_num(uint32_t num); /// 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) bool set_normal_map_texture(TEXTURE texture_id); }; diff --git a/src/game_api/script/lua_vm.cpp b/src/game_api/script/lua_vm.cpp index 6d8afe881..141d4d094 100644 --- a/src/game_api/script/lua_vm.cpp +++ b/src/game_api/script/lua_vm.cpp @@ -2512,7 +2512,7 @@ end // WIN // Runs when entering any winning cutscene, including the constellation. // CREDITS - // Runs when entering the credits. + // Runs when entering the credits screen. // SCORES // Runs when entering the final score celebration screen of a normal or hard ending. // CONSTELLATION diff --git a/src/game_api/script/sol_helper.hpp b/src/game_api/script/sol_helper.hpp index d50334f27..439de3c44 100644 --- a/src/game_api/script/sol_helper.hpp +++ b/src/game_api/script/sol_helper.hpp @@ -5,6 +5,7 @@ #include #include #include +#include template struct ZeroIndexArray @@ -93,3 +94,42 @@ struct usertype_container> } }; } // namespace sol + +namespace detail +{ +template +struct extract; +template +struct extract +{ + using BaseType = C; + using ReturnType = R; + using Params = std::tuple; +}; +} // namespace detail + +namespace +{ +template +struct proFunc; + +template