add option to disable currency for creative players

This commit is contained in:
flux 2020-05-10 00:17:17 +00:00
parent 1aa9b1532e
commit a243c2ed88
2 changed files with 31 additions and 10 deletions

@ -1,12 +1,14 @@
local players_income = {}
local income_enabled = minetest.settings:get_bool("currency.income_enabled", true)
local creative_income_enabled = minetest.settings:get_bool("currency.creative_income_enabled", true)
local income_item = minetest.settings:get("currency.income_item") or "currency:minegeld_10"
local income_count = tonumber(minetest.settings:get("currency.income_count")) or 1
local income_period = tonumber(minetest.settings:get("currency.income_period")) or 720
if income_enabled then
local timer = 0
if creative_income_enabled then
minetest.register_globalstep(function(dtime)
timer = timer + dtime;
if timer >= income_period then
@ -18,6 +20,22 @@ if income_enabled then
end
end
end)
else
minetest.register_globalstep(function(dtime)
timer = timer + dtime;
if timer >= income_period then
timer = 0
for _, player in ipairs(minetest.get_connected_players()) do
local name = player:get_player_name()
local privs = minetest.get_player_privs(name)
if not (privs.creative or privs.give) then
players_income[name] = income_count
minetest.log("info", "[Currency] basic income for "..name)
end
end
end
end)
end
local function earn_income(player)
if not player or player.is_fake_player then return end

@ -1,6 +1,9 @@
# Is income enabled?
currency.income_enabled (Is currency income enabled?) bool true
# Is income enabled for creative players?
currency.creative_income_enabled (Is income enabled for creative players?) bool true
# Item that is given as income by the currency mod
currency.income_item (Currency income item) string currency:minegeld_10