fix: lua script wasn't started when state was running on wolrd load

Dieser Commit ist enthalten in:
Reinder Feenstra 2022-03-22 23:26:00 +01:00
Ursprung a19879159a
Commit 6104827890
2 geänderte Dateien mit 11 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -3,7 +3,7 @@
*
* This file is part of the traintastic source code.
*
* Copyright (C) 2019-2021 Reinder Feenstra
* Copyright (C) 2019-2022 Reinder Feenstra
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -109,6 +109,14 @@ void Script::addToWorld()
m_world.luaScripts->addObject(shared_ptr<Script>());
}
void Script::loaded()
{
IdObject::loaded();
if(state == LuaScriptState::Running)
startSandbox();
}
void Script::worldEvent(WorldState worldState, WorldEvent worldEvent)
{
IdObject::worldEvent(worldState, worldEvent);

Datei anzeigen

@ -3,7 +3,7 @@
*
* This file is part of the traintastic source code.
*
* Copyright (C) 2019-2021 Reinder Feenstra
* Copyright (C) 2019-2022 Reinder Feenstra
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -41,6 +41,7 @@ class Script : public IdObject
void load(WorldLoader& loader, const nlohmann::json& data) final;
void save(WorldSaver& saver, nlohmann::json& data, nlohmann::json& stateData) const final;
void addToWorld() final;
void loaded() final;
void worldEvent(WorldState worldState, WorldEvent worldEvent) final;
void updateEnabled();