Fixing hp bugs
This commit is contained in:
1 parent
49501e32ce
commit
21bf3f0710
10 files changed
+38
-16
No files matched your search
@@ -17,6 +17,7 @@ namespace ZL {
|
||||
std::unordered_map<std::string, sol::protected_function> triggerExitCallbacks;
|
||||
std::unordered_map<std::string, sol::protected_function> cutsceneCompleteCallbacks;
|
||||
std::unordered_map<std::string, int>* globalInts = nullptr;
|
||||
std::unordered_map<std::string, float>* globalFloats = nullptr;
|
||||
sol::protected_function locationEnterCallback;
|
||||
sol::protected_function locationExitCallback;
|
||||
sol::protected_function darklandsEnterCallback;
|
||||
@@ -192,6 +193,18 @@ namespace ZL {
|
||||
api.set_function("is_darklands",
|
||||
[game]() { return game->isDarklands; });
|
||||
|
||||
api.set_function("setFloatValue",
|
||||
[this_impl = impl.get()](const std::string& key, float value) {
|
||||
if (this_impl->globalFloats)
|
||||
(*this_impl->globalFloats)[key] = value;
|
||||
});
|
||||
api.set_function("getFloatValue",
|
||||
[this_impl = impl.get()](const std::string& key) -> float {
|
||||
if (!this_impl->globalFloats) return 0.0f;
|
||||
auto it = this_impl->globalFloats->find(key);
|
||||
return it != this_impl->globalFloats->end() ? it->second : 0.0f;
|
||||
});
|
||||
|
||||
// set_player_hp(value) — sets the player's current HP directly.
|
||||
api.set_function("set_player_hp",
|
||||
[game](float value) {
|
||||
@@ -476,6 +489,10 @@ namespace ZL {
|
||||
if (impl) impl->globalInts = store;
|
||||
}
|
||||
|
||||
void ScriptEngine::setGlobalFloatStore(std::unordered_map<std::string, float>* store) {
|
||||
if (impl) impl->globalFloats = store;
|
||||
}
|
||||
|
||||
void ScriptEngine::callLocationEnterCallback() {
|
||||
if (!impl || !impl->locationEnterCallback.valid()) return;
|
||||
auto result = impl->locationEnterCallback();
|
||||
|
||||
Reference in new issue
Block a user