diff options
author | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2014-07-04 05:28:19 -0400 |
---|---|---|
committer | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2014-07-04 05:28:19 -0400 |
commit | 5e5580db1e018c05becb95591e8db704e6d9ac22 (patch) | |
tree | d03e5f3e56e32167b4848c5260707c3876cc6214 /income.lua |
initial commit
Diffstat (limited to 'income.lua')
-rw-r--r-- | income.lua | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/income.lua b/income.lua new file mode 100644 index 0000000..5aa6fbc --- /dev/null +++ b/income.lua @@ -0,0 +1,40 @@ +players_income = {} + +local timer = 0 +minetest.register_globalstep(function(dtime) + timer = timer + dtime; + if timer >= 720 then --720 for one day + timer = 0 + for _,player in ipairs(minetest.get_connected_players()) do + local name = player:get_player_name() + if players_income[name] == nil then + players_income[name] = 0 + end + players_income[name] = 1 + print("[Currency] basic income for "..name.."") + end + end +end) + +earn_income = function(player) + if not player or player.is_fake_player then return end + local name = player:get_player_name() + if players_income[name] == nil then + players_income[name] = 0 + end + if players_income[name] > 0 then + count = players_income[name] + local inv = player:get_inventory() + inv:add_item("main", {name="currency:minegeld_5", count=count}) + players_income[name] = 0 + print("[Currency] added basic income for "..name.." to inventory") + end +end + +minetest.register_on_dignode(function(pos, oldnode, digger) + earn_income(digger) +end) + +minetest.register_on_placenode(function(pos, node, placer) + earn_income(placer) +end) |