You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
985 B
40 lines
985 B
-- ___ _ _ _ |
|
-- / __| |_ __ _| |_ ___ _ _(_)___ |
|
-- \__ \ _/ _` | _/ _ \ '_| / _ \ |
|
-- |___/\__\__,_|\__\___/_| |_\___/ |
|
-- |
|
-- |
|
-- Cache the mod's settings locally |
|
-- so frequent reads cannot cause a |
|
-- performance hit in the game API. |
|
|
|
-- This isn't exposed on the global |
|
-- .statorio object. Other mods can |
|
-- already access them with the API |
|
-- if they ever want to. |
|
|
|
local this = {} |
|
|
|
this.runtimeGlobals = {} |
|
|
|
this.init = function() |
|
-- load all settings from the game API (expensive) |
|
this.runtimeGlobals["statorio-filename"] = settings.global["statorio-filename"].value |
|
this.runtimeGlobals["statorio-frequency"] = tonumber(settings.global["statorio-frequency"].value) |
|
|
|
log("Settings loaded into cache") |
|
end |
|
|
|
this.getRuntimeGlobal = function(key) |
|
return this.runtimeGlobals[key] |
|
end |
|
|
|
this.setRuntimeGlobal = function(key, val) |
|
if isNumeric(val) then |
|
this.runtimeGlobals[key] = tonumber(val) |
|
else |
|
this.runtimeGlobals[key] = val |
|
end |
|
end |
|
|
|
return this |