diff options
author | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2016-04-01 20:02:19 -0400 |
---|---|---|
committer | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2016-04-01 21:09:33 -0400 |
commit | da66780a569712c23ae4f2996cfb4608a9f9d69d (patch) | |
tree | 217556029a78bc23ad4564720afc86de97228a04 /currency/income.lua | |
parent | 615b22df4d423aded3613db7716943a2f389b047 (diff) | |
download | dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar.gz dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar.bz2 dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar.xz dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.zip |
copy all standard Dreambuilder mods in from the old subgame
(exactly as last supplied there, updates to these mods will follow later)
Diffstat (limited to 'currency/income.lua')
-rw-r--r-- | currency/income.lua | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/currency/income.lua b/currency/income.lua new file mode 100644 index 0000000..5aa6fbc --- /dev/null +++ b/currency/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) |