mirror of
https://github.com/mt-mods/currency.git
synced 2024-11-22 12:23:44 +01:00
add option to disable currency for creative players
This commit is contained in:
parent
1aa9b1532e
commit
a243c2ed88
18
income.lua
18
income.lua
@ -1,12 +1,14 @@
|
|||||||
local players_income = {}
|
local players_income = {}
|
||||||
|
|
||||||
local income_enabled = minetest.settings:get_bool("currency.income_enabled", true)
|
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_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_count = tonumber(minetest.settings:get("currency.income_count")) or 1
|
||||||
local income_period = tonumber(minetest.settings:get("currency.income_period")) or 720
|
local income_period = tonumber(minetest.settings:get("currency.income_period")) or 720
|
||||||
|
|
||||||
if income_enabled then
|
if income_enabled then
|
||||||
local timer = 0
|
local timer = 0
|
||||||
|
if creative_income_enabled then
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
timer = timer + dtime;
|
timer = timer + dtime;
|
||||||
if timer >= income_period then
|
if timer >= income_period then
|
||||||
@ -18,6 +20,22 @@ if income_enabled then
|
|||||||
end
|
end
|
||||||
end
|
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)
|
local function earn_income(player)
|
||||||
if not player or player.is_fake_player then return end
|
if not player or player.is_fake_player then return end
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
# Is income enabled?
|
# Is income enabled?
|
||||||
currency.income_enabled (Is currency income enabled?) bool true
|
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
|
# Item that is given as income by the currency mod
|
||||||
currency.income_item (Currency income item) string currency:minegeld_10
|
currency.income_item (Currency income item) string currency:minegeld_10
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user