-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Lua build to matrix * Add Lua sources * Add sol2 v3.3.0 sources * Set up Lua infrastructure * Run Lua scripts at loading stage * Prevent scripts from messing with globals table * Prevent scripts from messing with mod lists * Fix non-Lua build * Fix non-Lua build for real * When checking all mods, check Lua mods only in Lua builds * Stop world loading in non-Lua build if mod requires Lua * Fix inverted check * Astyle * Add wip docs * Add a bunch of tests that check Lua error and C++ exception interop * CMake Lua build * Lua in CMake build in Github Actions * Add Lua to msvc build * Add Lua to android build * Fix duplicated bindings registration * Clean up Lua state in exit_handler() * Bindings for Tripoint * Add bindings for item and itype_id * Run Lua functions after game loads * Add bindings for map and map item iteration * Add hooks for iuse functions * Run Lua functions on tinymap after mapgen * Log lua output to dedicated in-memory log * Lua console * Reload some parts of Lua code on demand, reset game.current_mod after load * Add bindings for getting/setting terrain * More bindings * Fix marking tables as readonly * Hack: pairs() for read-only tables * MOAR bindings * Add Smart House Remotes mod * Fix gcc build * Fix OSX build * Fix typos, fix LUA=0 build * Fix get_all_mods.py grabbing Lua mods for non-Lua tests * Fix Lua state deallocation after tests has been run * Simplify addition of new hooks in catalua.cpp * Implement save/load for global mod state * Add example mod that saves and loads state * Fix LUA=0 build again * Show Lua API version in debug log and in game report * In LUA=0 builds, prevent loading worlds that depend on Lua and show warning on mods * Update docs * Fix some clang lints * Bind faction_id * [WiP] Lua doc generator - constructors * Lua doc generator - member vars and functions * Fixup constructor * Lua doc generator - base classes * Lua doc generator - overloads * Lua doc generator - prettier docs * Lua doc generator - tuples * Lua doc generator - don't show nil return * Lua doc generator - more docced bindings * Lua doc generator - fix ref/const in return type * Lua doc generator - split up bindings to functions * Encapsulate some code * Redister std::string_view in docs * LDC: separate macro for documenting vs values * make_readonly_table: accept state_view * LDG: enums and string_ids * LDG: sol::optional * LDG: libraries * Check that userlib/userenum has been finalized * LDG: library constants * Bind game api & debug functions * Switch over to new bindings * Fix compilation * Fix LUA=0 build * Move hooks into a sub-table * Fix test * Update SaveLoad Lua Test mod, mark it obsolete * Update Smart House Remotes mod * Rename function to better match its purpose * Register examples for hooks so they show up in docs * Astyle * Fix rename * Fully implement Lua table (de-)serialization * Update SaveLoad Lua Test mod * Fix g++ build * No, it wasn't fine * Extract lua doc output filename to PATH_INFO * Update docs * Warn on accidental direct inclusion of sol/sol.hpp (thanks, vscode) * Fix invalid int_id definition * Add string_id(int_id) constructor * Add bindings for int_id, implement manual conversions * Fix doc generation for const pointers that are not const char* * Split up luna into its own header * Explicit type for color_id enum * Move luna doc definitions to header * Allow splitting catalua_bindings.cpp * Split up catalua_bindings.cpp into 3 files * Make console fullscreen * Rename function to match its purpose * Extract comparison operator hack into header * Better names + docs * Mark changes done to sol.hpp * Fix msvc build * Build releases with LUA=1 * Fix avatar.get_pos_ms * Print typeid() if no luna registration found * Revert "Fix msvc build" This reverts commit ed46b46. * Split up into more functions * Alternative msvc fix * More msvc fixes * Add comments to the documentation * Convert *ter_at to int_id * GCC fix * Add regression test * Fix typo * More hooks and bindings * Fix msvc build, again * Bind l10n api * Update src/catalua_bindings.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Extract strings from Lua code * Write Lua backtrace on debugmsg * Fix: start backtrace with level 0 * Add comment * Lunadoc: support this_state and function * Recurrent hooks with customizable interval * Less calendar checks * Special fix for special compiler * Fix LUA=0 build * Use locale API in SHR mod * Add docs on binding new stuff to Lua * Fix typo * Elaborate on implementing `enum_traits<T>` * Mark "Smart House Remotes" as obsolete * Update doc/LUA_SUPPORT.md * Restrict some of the fun functionality --------- Co-authored-by: scarf <[email protected]> Co-authored-by: Zhilkin Serg <[email protected]>
- Loading branch information
1 parent
6cc49ee
commit 90a1e97
Showing
168 changed files
with
59,537 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
gdebug.log_info("SLT: finalize") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
gdebug.log_info("SLT: main") | ||
|
||
local mod = game.mod_runtime[ game.current_mod ] | ||
local storage = game.mod_storage[ game.current_mod ] | ||
|
||
--[[ | ||
If we keep all our data simple and in mod.storage, | ||
we won't even have to register save/load hooks, | ||
it'll be saved/loaded automatically. | ||
]]-- | ||
mod.storage = storage | ||
|
||
--[[ | ||
The following values are default, they'll be assigned on | ||
new game start or on game init before save is loaded. | ||
]] | ||
-- Numeric data | ||
storage.num = 12.3 | ||
-- Usertype | ||
storage.tri = Tripoint.new(3, 4, 5) | ||
-- String | ||
storage.tri_as_str = tostring( Tripoint.new(3, 4, 5) ) | ||
|
||
--[[ | ||
If we want to build complex state out of loaded data | ||
we may create a hook that would read loaded data from mod_storage | ||
and create our complex state in the mod_runtime. | ||
]]-- | ||
mod.on_game_load_hook = function() | ||
gdebug.log_info("SLT: on_load") | ||
|
||
if storage.num then | ||
gdebug.log_info( "Data found! num = ", storage.num ) | ||
end | ||
if storage.tri then | ||
gdebug.log_info( "Data found! tri = ", storage.tri ) | ||
end | ||
end | ||
|
||
--[[ | ||
If we have complex enough state (e.g. recursive tables, or with custom metatables) | ||
we may create a hook that would write a simplified version into mod_storage, | ||
so the hardcoded JSON serializer would be able to handle it. | ||
]]-- | ||
mod.on_game_save_hook = function() | ||
gdebug.log_info("SLT: on_save") | ||
|
||
if storage.num then | ||
gdebug.log_info("Saving NUM value = ", storage.num) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[ | ||
{ | ||
"type": "MOD_INFO", | ||
"id": "saveload_lua_test", | ||
"name": "SaveLoad Lua Test", | ||
"authors": [ "Olanti" ], | ||
"description": "Mod for testing Lua save/load API.", | ||
"category": "content", | ||
"lua_api_version": 1, | ||
"//": "It's not really obsolete, but it's useful only for devs and modders, and not for player.", | ||
"obsolete": true, | ||
"dependencies": [ "bn" ] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
gdebug.log_info("SLT: preload") | ||
|
||
local mod = game.mod_runtime[ game.current_mod ] | ||
|
||
game.hooks.on_game_load[ #game.hooks.on_game_load + 1 ] = function( ... ) | ||
return mod.on_game_load_hook( ... ) | ||
end | ||
|
||
game.hooks.on_game_save[ #game.hooks.on_game_save + 1 ] = function( ... ) | ||
return mod.on_game_save_hook( ... ) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
gdebug.log_info("SHR: finalize.") | ||
|
||
-- We're not finalizing anything. | ||
-- Besides, there's no finalizing API available yet. |
Oops, something went wrong.