Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/game/scripting
diff options
context:
space:
mode:
Diffstat (limited to 'source/game/scripting')
-rw-r--r--source/game/scripting/StarLuaComponents.cpp8
-rw-r--r--source/game/scripting/StarLuaComponents.hpp6
-rw-r--r--source/game/scripting/StarLuaRoot.cpp6
-rw-r--r--source/game/scripting/StarWorldLuaBindings.cpp52
4 files changed, 36 insertions, 36 deletions
diff --git a/source/game/scripting/StarLuaComponents.cpp b/source/game/scripting/StarLuaComponents.cpp
index 000e787..2d7c819 100644
--- a/source/game/scripting/StarLuaComponents.cpp
+++ b/source/game/scripting/StarLuaComponents.cpp
@@ -29,7 +29,7 @@ void LuaBaseComponent::setScripts(StringList scripts) {
void LuaBaseComponent::addCallbacks(String groupName, LuaCallbacks callbacks) {
if (!m_callbacks.insert(groupName, callbacks).second)
- throw LuaComponentException::format("Duplicate callbacks named '%s' in LuaBaseComponent", groupName);
+ throw LuaComponentException::format("Duplicate callbacks named '{}' in LuaBaseComponent", groupName);
if (m_context)
m_context->setCallbacks(groupName, callbacks);
@@ -75,7 +75,7 @@ bool LuaBaseComponent::init() {
try {
m_context = m_luaRoot->createContext(m_scripts);
} catch (LuaException const& e) {
- Logger::error("Exception while creating lua context for scripts '%s': %s", m_scripts, outputException(e, true));
+ Logger::error("Exception while creating lua context for scripts '{}': {}", m_scripts, outputException(e, true));
m_error = String(printException(e, false));
m_context.reset();
return false;
@@ -86,7 +86,7 @@ bool LuaBaseComponent::init() {
try {
m_context->invokePath("init");
} catch (LuaException const& e) {
- Logger::error("Exception while calling script init: %s", outputException(e, true));
+ Logger::error("Exception while calling script init: {}", outputException(e, true));
m_error = String(printException(e, false));
m_context.reset();
return false;
@@ -102,7 +102,7 @@ void LuaBaseComponent::uninit() {
try {
m_context->invokePath("uninit");
} catch (LuaException const& e) {
- Logger::error("Exception while calling script uninit: %s", outputException(e, true));
+ Logger::error("Exception while calling script uninit: {}", outputException(e, true));
m_error = String(printException(e, false));
}
}
diff --git a/source/game/scripting/StarLuaComponents.hpp b/source/game/scripting/StarLuaComponents.hpp
index dec2b23..f370679 100644
--- a/source/game/scripting/StarLuaComponents.hpp
+++ b/source/game/scripting/StarLuaComponents.hpp
@@ -184,7 +184,7 @@ Maybe<Ret> LuaBaseComponent::invoke(String const& name, V&&... args) {
return {};
return m_context->luaTo<LuaFunction>(move(method)).invoke<Ret>(forward<V>(args)...);
} catch (LuaException const& e) {
- Logger::error("Exception while invoking lua function '%s'. %s", name, outputException(e, true));
+ Logger::error("Exception while invoking lua function '{}'. {}", name, outputException(e, true));
setError(printException(e, false));
return {};
}
@@ -198,7 +198,7 @@ Maybe<LuaValue> LuaBaseComponent::eval(String const& code) {
try {
return m_context->eval<Ret>(code);
} catch (LuaException const& e) {
- Logger::error("Exception while evaluating lua in context: %s", outputException(e, true));
+ Logger::error("Exception while evaluating lua in context: {}", outputException(e, true));
return {};
}
}
@@ -316,7 +316,7 @@ Maybe<Json> LuaMessageHandlingComponent<Base>::handleMessage(
return handler->template invoke<Json>(message, localMessage, luaUnpack(args));
} catch (LuaException const& e) {
Logger::error(
- "Exception while invoking lua message handler for message '%s'. %s", message, outputException(e, true));
+ "Exception while invoking lua message handler for message '{}'. {}", message, outputException(e, true));
Base::setError(String(printException(e, false)));
}
}
diff --git a/source/game/scripting/StarLuaRoot.cpp b/source/game/scripting/StarLuaRoot.cpp
index 70602de..4d6e8cf 100644
--- a/source/game/scripting/StarLuaRoot.cpp
+++ b/source/game/scripting/StarLuaRoot.cpp
@@ -34,7 +34,7 @@ LuaRoot::~LuaRoot() {
JsonObject profile;
profile.set("function", entry.name.value("<function>"));
profile.set("scope", entry.nameScope.value("?"));
- profile.set("source", strf("%s:%s", entry.source, entry.sourceLine));
+ profile.set("source", strf("{}:{}", entry.source, entry.sourceLine));
profile.set("self", entry.selfTime);
profile.set("total", entry.totalTime);
List<LuaProfileEntry> calls;
@@ -51,9 +51,9 @@ LuaRoot::~LuaRoot() {
File::makeDirectory(m_storageDirectory);
}
- String filename = strf("%s.luaprofile", Time::printCurrentDateAndTime("<year>-<month>-<day>-<hours>-<minutes>-<seconds>-<millis>"));
+ String filename = strf("{}.luaprofile", Time::printCurrentDateAndTime("<year>-<month>-<day>-<hours>-<minutes>-<seconds>-<millis>"));
String path = File::relativeTo(m_storageDirectory, filename);
- Logger::info("Writing lua profile %s", filename);
+ Logger::info("Writing lua profile {}", filename);
File::writeFile(profileSummary, path);
}
}
diff --git a/source/game/scripting/StarWorldLuaBindings.cpp b/source/game/scripting/StarWorldLuaBindings.cpp
index ca0ebb2..9906eec 100644
--- a/source/game/scripting/StarWorldLuaBindings.cpp
+++ b/source/game/scripting/StarWorldLuaBindings.cpp
@@ -175,7 +175,7 @@ namespace LuaBindings {
} else if (*order == "random") {
Random::shuffle(entities);
} else {
- throw StarException(strf("Unsupported query order %s", order->ptr()));
+ throw StarException(strf("Unsupported query order {}", order->ptr()));
}
}
@@ -820,7 +820,7 @@ namespace LuaBindings {
return true;
}
} catch (StarException const& exception) {
- Logger::warn("Could not create placable object of kind '%s', exception caught: %s",
+ Logger::warn("Could not create placable object of kind '{}', exception caught: {}",
objectType,
outputException(exception, false));
}
@@ -860,7 +860,7 @@ namespace LuaBindings {
Logger::warn("Could not spawn item, item empty in WorldCallbacks::spawnItem");
} catch (StarException const& exception) {
- Logger::warn("Could not spawn Item of kind '%s', exception caught: %s", itemType, outputException(exception, false));
+ Logger::warn("Could not spawn Item of kind '{}', exception caught: {}", itemType, outputException(exception, false));
}
return {};
@@ -878,7 +878,7 @@ namespace LuaBindings {
}
} catch (StarException const& exception) {
Logger::warn(
- "Could not spawn treasure from pool '%s', exception caught: %s", pool, outputException(exception, false));
+ "Could not spawn treasure from pool '{}', exception caught: {}", pool, outputException(exception, false));
}
return entities;
}
@@ -904,7 +904,7 @@ namespace LuaBindings {
return monster->inWorld() ? monster->entityId() : Maybe<EntityId>();
} catch (StarException const& exception) {
Logger::warn(
- "Could not spawn Monster of type '%s', exception caught: %s", arg1, outputException(exception, false));
+ "Could not spawn Monster of type '{}', exception caught: {}", arg1, outputException(exception, false));
return {};
}
}
@@ -936,7 +936,7 @@ namespace LuaBindings {
world->addEntity(npc);
return npc->inWorld() ? npc->entityId() : Maybe<EntityId>();
} catch (StarException const& exception) {
- Logger::warn("Could not spawn NPC of species '%s' and type '%s', exception caught: %s",
+ Logger::warn("Could not spawn NPC of species '{}' and type '{}', exception caught: {}",
arg2,
typeName,
outputException(exception, false));
@@ -954,7 +954,7 @@ namespace LuaBindings {
return stagehand->inWorld() ? stagehand->entityId() : Maybe<EntityId>();
} catch (StarException const& exception) {
Logger::warn(
- "Could not spawn Stagehand of type '%s', exception caught: %s", typeName, outputException(exception, false));
+ "Could not spawn Stagehand of type '{}', exception caught: {}", typeName, outputException(exception, false));
return {};
}
}
@@ -977,7 +977,7 @@ namespace LuaBindings {
return projectile->inWorld() ? projectile->entityId() : Maybe<EntityId>();
} catch (StarException const& exception) {
Logger::warn(
- "Could not spawn Projectile of type '%s', exception caught: %s", projectileType, outputException(exception, false));
+ "Could not spawn Projectile of type '{}', exception caught: {}", projectileType, outputException(exception, false));
return {};
}
}
@@ -1122,9 +1122,9 @@ namespace LuaBindings {
else if (auto stagehand = as<Stagehand>(entity.get()))
stagehand->setUniqueId(uniqueId);
else if (entity)
- throw StarException::format("Cannot set unique id on entity of type %s", EntityTypeNames.getRight(entity->entityType()));
+ throw StarException::format("Cannot set unique id on entity of type {}", EntityTypeNames.getRight(entity->entityType()));
else
- throw StarException::format("No such entity with id %s", entityId);
+ throw StarException::format("No such entity with id {}", entityId);
}
Json ServerWorldCallbacks::takeItemDrop(World* world, EntityId entityId, Maybe<EntityId> const& takenBy) {
@@ -1169,7 +1169,7 @@ namespace LuaBindings {
void WorldDebugCallbacks::debugText(LuaEngine& engine, LuaVariadic<LuaValue> const& args) {
if (args.size() < 3)
- throw StarException(strf("Too few arguments to debugText: %s", args.size()));
+ throw StarException(strf("Too few arguments to debugText: {}", args.size()));
Vec2F const position = engine.luaTo<Vec2F>(args.at(args.size() - 2));
Vec4B const color = engine.luaTo<Color>(args.at(args.size() - 1)).toRgba();
@@ -1228,7 +1228,7 @@ namespace LuaBindings {
else if (orientationName.empty())
orientation = LoungeOrientation::None;
else
- throw StarException(strf("Unsupported loungeableQuery orientation %s", orientationName));
+ throw StarException(strf("Unsupported loungeableQuery orientation {}", orientationName));
auto filter = [orientation](shared_ptr<LoungeableObject> const& entity) -> bool {
auto loungeable = as<LoungeableEntity>(entity);
@@ -1419,7 +1419,7 @@ namespace LuaBindings {
} else if (handName == "alt") {
toolHand = ToolHand::Alt;
} else {
- throw StarException(strf("Unknown tool hand %s", handName));
+ throw StarException(strf("Unknown tool hand {}", handName));
}
if (auto entity = world->get<ToolUserEntity>(entityId)) {
@@ -1438,7 +1438,7 @@ namespace LuaBindings {
} else if (handName == "alt") {
toolHand = ToolHand::Alt;
} else {
- throw StarException(strf("Unknown tool hand %s", handName));
+ throw StarException(strf("Unknown tool hand {}", handName));
}
if (auto entity = world->get<ToolUserEntity>(entityId)) {
@@ -1713,7 +1713,7 @@ namespace LuaBindings {
Maybe<LuaValue> WorldEntityCallbacks::callScriptedEntity(World* world, EntityId entityId, String const& function, LuaVariadic<LuaValue> const& args) {
auto entity = as<ScriptedEntity>(world->entity(entityId));
if (!entity || !entity->isMaster())
- throw StarException::format("Entity %s does not exist or is not a local master scripted entity", entityId);
+ throw StarException::format("Entity {} does not exist or is not a local master scripted entity", entityId);
return entity->callScript(function, args);
}
@@ -1794,7 +1794,7 @@ namespace LuaBindings {
} else if (layerName == "background") {
layer = TileLayer::Background;
} else {
- throw StarException(strf("Unsupported material layer %s", layerName));
+ throw StarException(strf("Unsupported material layer {}", layerName));
}
auto materialId = world->material(Vec2I::floor(position), layer);
@@ -1815,7 +1815,7 @@ namespace LuaBindings {
} else if (layerName == "background") {
layer = TileLayer::Background;
} else {
- throw StarException(strf("Unsupported mod layer %s", layerName));
+ throw StarException(strf("Unsupported mod layer {}", layerName));
}
auto modId = world->mod(Vec2I::floor(position), layer);
@@ -1834,7 +1834,7 @@ namespace LuaBindings {
} else if (layerName == "background") {
layer = TileLayer::Background;
} else {
- throw StarException(strf("Unsupported material layer %s", layerName));
+ throw StarException(strf("Unsupported material layer {}", layerName));
}
return world->materialHueShift(Vec2I::floor(position), layer);
@@ -1847,7 +1847,7 @@ namespace LuaBindings {
} else if (layerName == "background") {
layer = TileLayer::Background;
} else {
- throw StarException(strf("Unsupported material layer %s", layerName));
+ throw StarException(strf("Unsupported material layer {}", layerName));
}
return world->modHueShift(Vec2I::floor(position), layer);
@@ -1860,7 +1860,7 @@ namespace LuaBindings {
} else if (layerName == "background") {
layer = TileLayer::Background;
} else {
- throw StarException(strf("Unsupported material layer %s", layerName));
+ throw StarException(strf("Unsupported material layer {}", layerName));
}
return world->colorVariant(Vec2I::floor(position), layer);
@@ -1873,7 +1873,7 @@ namespace LuaBindings {
} else if (layerName == "background") {
layer = TileLayer::Background;
} else {
- throw StarException(strf("Unsupported material layer %s", layerName));
+ throw StarException(strf("Unsupported material layer {}", layerName));
}
world->modifyTile(Vec2I::floor(position), PlaceMaterialColor{layer, color}, true);
@@ -1896,7 +1896,7 @@ namespace LuaBindings {
} else if (layerName == "background") {
layer = TileLayer::Background;
} else {
- throw StarException(strf("Unsupported damageTile layer %s", layerName));
+ throw StarException(strf("Unsupported damageTile layer {}", layerName));
}
unsigned harvestLevel = 999;
@@ -1932,13 +1932,13 @@ namespace LuaBindings {
} else if (layerName == "background") {
placeMaterial.layer = TileLayer::Background;
} else {
- throw StarException(strf("Unsupported damageTile layer %s", layerName));
+ throw StarException(strf("Unsupported damageTile layer {}", layerName));
}
auto materialName = arg3;
auto materialDatabase = Root::singleton().materialDatabase();
if (!materialDatabase->materialNames().contains(materialName))
- throw StarException(strf("Unknown material name %s", materialName));
+ throw StarException(strf("Unknown material name {}", materialName));
placeMaterial.material = materialDatabase->materialId(materialName);
if (arg4)
@@ -1960,13 +1960,13 @@ namespace LuaBindings {
} else if (layerName == "background") {
placeMod.layer = TileLayer::Background;
} else {
- throw StarException(strf("Unsupported damageTile layer %s", layerName));
+ throw StarException(strf("Unsupported damageTile layer {}", layerName));
}
auto modName = arg3;
auto materialDatabase = Root::singleton().materialDatabase();
if (!materialDatabase->modNames().contains(modName))
- throw StarException(strf("Unknown mod name %s", modName));
+ throw StarException(strf("Unknown mod name {}", modName));
placeMod.mod = materialDatabase->modId(modName);
if (arg4)