aboutsummaryrefslogtreecommitdiff
path: root/interest.lua
diff options
context:
space:
mode:
Diffstat (limited to 'interest.lua')
-rw-r--r--interest.lua28
1 files changed, 24 insertions, 4 deletions
diff --git a/interest.lua b/interest.lua
index 696b691..54df1ce 100644
--- a/interest.lua
+++ b/interest.lua
@@ -5,11 +5,11 @@ function atm.welfare_payout()
payout = false
for _,player in ipairs(minetest.get_connected_players()) do
local name = player:get_player_name()
- local limit = atm.welfare[name] or atm.default_welfare
+ local limit = atm.welfare[name] or atm.welfare_cap
atm.ensure_init(name)
- if limit > 5 then
- atm.balance[name] = math.floor(atm.balance[name] + 5)
- atm.welfare[name] = limit - 5
+ if limit > atm.welfare_amount then
+ atm.balance[name] = math.floor(atm.balance[name] + atm.welfare_amount)
+ atm.welfare[name] = limit - atm.welfare_amount
payout = true
end
end
@@ -25,3 +25,23 @@ minetest.register_globalstep(function(dtime)
atm.welfare_payout()
end
end)
+
+
+minetest.register_chatcommand("give_welfare", {
+ description = "Put a player on welfare payments",
+ params = "<player> <amount>",
+ privs = { kick = true },
+ func = function (name, params)
+ local plname, amount = params:match("(%S+)%s+(%d+)")
+ if not plname then
+ return false, "Invalid parameters: "..params
+ end
+ if not atm.balance[plname] then
+ return false, plname.." does not have a bank account!"
+ end
+ atm.welfare[plname] = tonumber(amount) or atm.welfare_cap
+ minetest.chat_send_player(name, "Player "..plname.." put on welfare successfully.")
+ return true
+ end,
+})
+