mod security compatibility

This commit is contained in:
raymoo 2016-11-17 20:19:33 -08:00
parent 22f9f394c1
commit 7db6fb3ca7
2 changed files with 9 additions and 5 deletions

View File

@ -1,5 +1,6 @@
local sql = require("lsqlite3")
local insecure_env = ...
local sql = insecure_env.require("lsqlite3")
local exports = {}
local init_query = [=[

View File

@ -1,16 +1,19 @@
local insecure_env = minetest.request_insecure_environment()
assert(insecure_env,
"global_exchange needs to be trusted to run under mod security.")
local modpath = minetest.get_modpath(minetest.get_current_modname()) .. "/"
local income = tonumber(minetest.setting_get("citizens_income")) or 10
local income_interval = 1200
local income_msg = "You receive your citizen's income (+" .. income .. ")"
local next_payout = os.time() + income_interval
local exchange = (dofile(modpath .. "exchange.lua")).open_exchange(
minetest.get_worldpath() .. "/global_exchange.db"
local exchange =
assert(loadfile(modpath .. "exchange.lua"))(insecure_env).open_exchange(
minetest.get_worldpath() .. "/global_exchange.db"
)