Update StarObject.cpp

This commit is contained in:
Kae 2024-07-25 07:21:17 +10:00
parent 0634ae78fc
commit 0638127721

View File

@ -187,9 +187,12 @@ void Object::init(World* world, EntityId entityId, EntityMode mode) {
m_liquidCheckTimer.setDone(); m_liquidCheckTimer.setDone();
setKeepAlive(configValue("keepAlive", false).toBool()); setKeepAlive(configValue("keepAlive", false).toBool());
StringList scripts = configValue("scripts", JsonArray()).optArray().apply(jsonToStringList).value(m_config->scripts); auto jScripts = configValue("scripts", JsonArray());
m_scriptComponent.setScripts(scripts.transformed(bind(AssetPath::relativeTo, m_config->path, _1))); StringList scripts = jScripts.isType(Json::Type::Array)
? jsonToStringList(jScripts).transformed(bind(AssetPath::relativeTo, m_config->path, _1))
: m_config->scripts;
m_scriptComponent.setScripts(scripts);
m_scriptComponent.setUpdateDelta(configValue("scriptDelta", 5).toInt()); m_scriptComponent.setUpdateDelta(configValue("scriptDelta", 5).toInt());
m_scriptComponent.addCallbacks("object", makeObjectCallbacks()); m_scriptComponent.addCallbacks("object", makeObjectCallbacks());