From fde429d1a7a6e6c583418690b286e062de72ad2d Mon Sep 17 00:00:00 2001 From: emmaker Date: Mon, 2 Jun 2025 16:21:32 -0400 Subject: Add codex bindings to player table --- source/game/scripting/StarPlayerLuaBindings.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'source/game/scripting/StarPlayerLuaBindings.cpp') diff --git a/source/game/scripting/StarPlayerLuaBindings.cpp b/source/game/scripting/StarPlayerLuaBindings.cpp index ea2bae5..833d718 100755 --- a/source/game/scripting/StarPlayerLuaBindings.cpp +++ b/source/game/scripting/StarPlayerLuaBindings.cpp @@ -743,6 +743,31 @@ LuaCallbacks LuaBindings::makePlayerCallbacks(Player* player) { player->log()->removeScannedObject(objectName); }); + // codex bindings + callbacks.registerCallback("isCodexKnown", [player](String const& codexId) -> bool { + return player.codexes()->codexKnown(codexId); + }); + + callbacks.registerCallback("isCodexRead", [player](String const& codexId) -> bool { + return player->codexes()->codexRead(codexId); + }); + + callbacks.registerCallback("markCodexRead", [player](String const& codexId) -> bool { + return player->codexes()->markCodexRead(codexId); + }); + + callbacks.registerCallback("markCodexUnread", [player](String const& codexId) -> bool { + return player->codexes()->markCodexUnread(codexId); + }); + + callbacks.registerCallback("learnCodex", [player](String const& codexId, bool markRead) { + player->codexes()->learnCodex(codexId, markRead); + }); + + callbacks.registerCallback("getCodexes", [player]() -> Json { + return player->codexes()->toJson(); + }); + return callbacks; } -- cgit v1.2.3 From 9287cf833594d7bccfe3dce2b1f7230496908bcc Mon Sep 17 00:00:00 2001 From: emmaker Date: Mon, 2 Jun 2025 17:47:11 -0400 Subject: Syntax fix (oops) --- source/game/scripting/StarPlayerLuaBindings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/game/scripting/StarPlayerLuaBindings.cpp') diff --git a/source/game/scripting/StarPlayerLuaBindings.cpp b/source/game/scripting/StarPlayerLuaBindings.cpp index 833d718..ca7c3c2 100755 --- a/source/game/scripting/StarPlayerLuaBindings.cpp +++ b/source/game/scripting/StarPlayerLuaBindings.cpp @@ -745,7 +745,7 @@ LuaCallbacks LuaBindings::makePlayerCallbacks(Player* player) { // codex bindings callbacks.registerCallback("isCodexKnown", [player](String const& codexId) -> bool { - return player.codexes()->codexKnown(codexId); + return player->codexes()->codexKnown(codexId); }); callbacks.registerCallback("isCodexRead", [player](String const& codexId) -> bool { -- cgit v1.2.3 From 00d70f62235437bd7f473d43c506a1c652236362 Mon Sep 17 00:00:00 2001 From: emmaker Date: Mon, 2 Jun 2025 18:04:46 -0400 Subject: Include missing header --- source/game/scripting/StarPlayerLuaBindings.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'source/game/scripting/StarPlayerLuaBindings.cpp') diff --git a/source/game/scripting/StarPlayerLuaBindings.cpp b/source/game/scripting/StarPlayerLuaBindings.cpp index ca7c3c2..0f8bdfc 100755 --- a/source/game/scripting/StarPlayerLuaBindings.cpp +++ b/source/game/scripting/StarPlayerLuaBindings.cpp @@ -13,6 +13,7 @@ #include "StarJsonExtra.hpp" #include "StarUniverseClient.hpp" #include "StarTeamClient.hpp" +#include "StarPlayerCodexes.hpp" namespace Star { -- cgit v1.2.3 From 855d34a80a9c1efdc4d04bd540efef5125e54974 Mon Sep 17 00:00:00 2001 From: emmaker Date: Mon, 2 Jun 2025 18:45:40 -0400 Subject: Change type of markRead to Maybe --- source/game/scripting/StarPlayerLuaBindings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/game/scripting/StarPlayerLuaBindings.cpp') diff --git a/source/game/scripting/StarPlayerLuaBindings.cpp b/source/game/scripting/StarPlayerLuaBindings.cpp index 0f8bdfc..ff0b877 100755 --- a/source/game/scripting/StarPlayerLuaBindings.cpp +++ b/source/game/scripting/StarPlayerLuaBindings.cpp @@ -761,8 +761,8 @@ LuaCallbacks LuaBindings::makePlayerCallbacks(Player* player) { return player->codexes()->markCodexUnread(codexId); }); - callbacks.registerCallback("learnCodex", [player](String const& codexId, bool markRead) { - player->codexes()->learnCodex(codexId, markRead); + callbacks.registerCallback("learnCodex", [player](String const& codexId, Maybe markRead) { + player->codexes()->learnCodex(codexId, markRead.value(false)); }); callbacks.registerCallback("getCodexes", [player]() -> Json { -- cgit v1.2.3