From 1b9ea22d6334bef588bc13c58d4c93057ea1cdc4 Mon Sep 17 00:00:00 2001 From: Mr-Auto <36127424+Mr-Auto@users.noreply.github.com> Date: Thu, 5 Oct 2023 22:48:00 +0200 Subject: [PATCH] fix doc --- docs/game_data/spel2.lua | 9 +- docs/src/includes/_types.md | 4 +- src/game_api/script/usertypes/logic_lua.cpp | 104 ++++++++++---------- 3 files changed, 64 insertions(+), 53 deletions(-) diff --git a/docs/game_data/spel2.lua b/docs/game_data/spel2.lua index 869dcc6d4..e40f72db5 100644 --- a/docs/game_data/spel2.lua +++ b/docs/game_data/spel2.lua @@ -5906,7 +5906,14 @@ function Quad:is_point_inside(x, y, epsilon) end ---@field arena_3 Logic @Handles time end death ---@field arena_alien_blast LogicArenaAlienBlast ---@field arena_loose_bombs LogicArenaLooseBombs - ---@field start_logic any @[&lua](LogicList&l + ---@field start_logic fun(self, idx: LOGIC): Logic @This only properly constructs the base class
you may still need to initialise the parameters correctly +local LogicList = nil +---@param idx LOGIC +---@return nil +function LogicList:stop_logic(idx) end +---@param log Logic +---@return nil +function LogicList:stop_logic(log) end ---@class Logic ---@field logic_index LOGIC diff --git a/docs/src/includes/_types.md b/docs/src/includes/_types.md index b2fa9fccc..26f1d5134 100644 --- a/docs/src/includes/_types.md +++ b/docs/src/includes/_types.md @@ -1439,7 +1439,9 @@ Type | Name | Description [Logic](#Logic) | [arena_3](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=arena_3) | Handles time end death [LogicArenaAlienBlast](#LogicArenaAlienBlast) | [arena_alien_blast](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=arena_alien_blast) | [LogicArenaLooseBombs](#LogicArenaLooseBombs) | [arena_loose_bombs](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=arena_loose_bombs) | - | [start_logic](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=start_logic) | +[Logic](#Logic) | [start_logic(LOGIC idx)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=start_logic) | This only properly constructs the base class
you may still need to initialise the parameters correctly +nil | [stop_logic(LOGIC idx)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=stop_logic) | +nil | [stop_logic(Logic log)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=stop_logic) | ### LogicMagmamanSpawn diff --git a/src/game_api/script/usertypes/logic_lua.cpp b/src/game_api/script/usertypes/logic_lua.cpp index 7aefb1445..bb2395781 100644 --- a/src/game_api/script/usertypes/logic_lua.cpp +++ b/src/game_api/script/usertypes/logic_lua.cpp @@ -76,6 +76,58 @@ void register_usertypes(sol::state& lua) "ARENA_LOOSE_BOMBS", LOGIC::ARENA_LOOSE_BOMBS); + auto start_logic = [&lua](LogicList& l, LOGIC idx) -> sol::object + { + auto return_logic = l.start_logic(idx); + switch (idx) + { + case LOGIC::TUTORIAL: + return sol::make_object(lua, (LogicTutorial*)return_logic); + case LOGIC::OUROBOROS: + return sol::make_object(lua, (LogicOuroboros*)return_logic); + case LOGIC::SPEEDRUN: + return sol::make_object(lua, (LogicBasecampSpeedrun*)return_logic); + case LOGIC::GHOST_TOAST: + return sol::make_object(lua, (LogicGhostToast*)return_logic); + case LOGIC::DICESHOP: + return sol::make_object(lua, (LogicDiceShop*)return_logic); + case LOGIC::PRE_CHALLENGE: + return sol::make_object(lua, (LogicTunPreChallenge*)return_logic); + case LOGIC::MOON_CHALLENGE: + return sol::make_object(lua, (LogicMoonChallenge*)return_logic); + case LOGIC::STAR_CHALLENGE: + return sol::make_object(lua, (LogicStarChallenge*)return_logic); + case LOGIC::SUN_CHALLENGE: + return sol::make_object(lua, (LogicSunChallenge*)return_logic); + case LOGIC::MAGMAN_SPAWN: + return sol::make_object(lua, (LogicMagmamanSpawn*)return_logic); + case LOGIC::WATER_BUBBLES: + return sol::make_object(lua, (LogicUnderwaterBubbles*)return_logic); + case LOGIC::OLMEC_CUTSCENE: + return sol::make_object(lua, (LogicOlmecCutscene*)return_logic); + case LOGIC::TIAMAT_CUTSCENE: + return sol::make_object(lua, (LogicTiamatCutscene*)return_logic); + case LOGIC::APEP: + return sol::make_object(lua, (LogicApepTrigger*)return_logic); + case LOGIC::COG_SACRIFICE: + return sol::make_object(lua, (LogicCOGAnkhSacrifice*)return_logic); + case LOGIC::BUBBLER: + return sol::make_object(lua, (LogicTiamatBubbles*)return_logic); + case LOGIC::PLEASURE_PALACE: + return sol::make_object(lua, (LogicTuskPleasurePalace*)return_logic); + case LOGIC::ARENA_1: + return sol::make_object(lua, (LogicArena1*)return_logic); + // case LOGIC::ARENA_2: + // return sol::make_object(lua, () return_logic); + case LOGIC::ARENA_ALIEN_BLAST: + return sol::make_object(lua, (LogicArenaAlienBlast*)return_logic); + case LOGIC::ARENA_LOOSE_BOMBS: + return sol::make_object(lua, (LogicArenaLooseBombs*)return_logic); + default: + return sol::make_object(lua, return_logic); + } + }; + /// Used in StateMemory lua.new_usertype( "LogicList", @@ -136,57 +188,7 @@ void register_usertypes(sol::state& lua) "arena_loose_bombs", &LogicList::arena_loose_bombs, "start_logic", - [&lua](LogicList& l, LOGIC idx) -> sol::object // -> mixed* - { - auto return_logic = l.start_logic(idx); - switch (idx) - { - case LOGIC::TUTORIAL: - return sol::make_object(lua, (LogicTutorial*)return_logic); - case LOGIC::OUROBOROS: - return sol::make_object(lua, (LogicOuroboros*)return_logic); - case LOGIC::SPEEDRUN: - return sol::make_object(lua, (LogicBasecampSpeedrun*)return_logic); - case LOGIC::GHOST_TOAST: - return sol::make_object(lua, (LogicGhostToast*)return_logic); - case LOGIC::DICESHOP: - return sol::make_object(lua, (LogicDiceShop*)return_logic); - case LOGIC::PRE_CHALLENGE: - return sol::make_object(lua, (LogicTunPreChallenge*)return_logic); - case LOGIC::MOON_CHALLENGE: - return sol::make_object(lua, (LogicMoonChallenge*)return_logic); - case LOGIC::STAR_CHALLENGE: - return sol::make_object(lua, (LogicStarChallenge*)return_logic); - case LOGIC::SUN_CHALLENGE: - return sol::make_object(lua, (LogicSunChallenge*)return_logic); - case LOGIC::MAGMAN_SPAWN: - return sol::make_object(lua, (LogicMagmamanSpawn*)return_logic); - case LOGIC::WATER_BUBBLES: - return sol::make_object(lua, (LogicUnderwaterBubbles*)return_logic); - case LOGIC::OLMEC_CUTSCENE: - return sol::make_object(lua, (LogicOlmecCutscene*)return_logic); - case LOGIC::TIAMAT_CUTSCENE: - return sol::make_object(lua, (LogicTiamatCutscene*)return_logic); - case LOGIC::APEP: - return sol::make_object(lua, (LogicApepTrigger*)return_logic); - case LOGIC::COG_SACRIFICE: - return sol::make_object(lua, (LogicCOGAnkhSacrifice*)return_logic); - case LOGIC::BUBBLER: - return sol::make_object(lua, (LogicTiamatBubbles*)return_logic); - case LOGIC::PLEASURE_PALACE: - return sol::make_object(lua, (LogicTuskPleasurePalace*)return_logic); - case LOGIC::ARENA_1: - return sol::make_object(lua, (LogicArena1*)return_logic); - // case LOGIC::ARENA_2: - // return sol::make_object(lua, () return_logic); - case LOGIC::ARENA_ALIEN_BLAST: - return sol::make_object(lua, (LogicArenaAlienBlast*)return_logic); - case LOGIC::ARENA_LOOSE_BOMBS: - return sol::make_object(lua, (LogicArenaLooseBombs*)return_logic); - default: - return sol::make_object(lua, return_logic); - } - }, + start_logic, "stop_logic", stop_logic); /// Used in LogicList