emeraldbank/income.lua

42 lines
1.4 KiB
Lua
Raw Normal View History

2021-10-13 14:23:24 +02:00
2022-07-03 18:20:28 +02:00
-- Copyright (C) 2021, 2022 Ale
2021-10-13 14:23:24 +02:00
-- This file is part of Emeraldbank Minetest Mod.
-- Emeraldbank is free software: you can redistribute it and/or modify
-- it under the terms of the GNU Affero General Public License as
-- published by the Free Software Foundation, either version 3 of the
-- License, or (at your option) any later version.
2021-10-13 14:23:24 +02:00
-- Emeraldbank is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU Affero General Public License for more details.
2021-10-13 14:23:24 +02:00
-- You should have received a copy of the GNU Affero General Public License
2021-10-13 14:23:24 +02:00
-- along with Emeraldbank. If not, see <https://www.gnu.org/licenses/>.
local S = core.get_translator(core.get_current_modname())
2021-10-20 17:58:12 +02:00
2021-10-13 14:23:24 +02:00
local income_count = tonumber(core.settings:get("emeraldbank.income_count")) or 1
local income_period = tonumber(core.settings:get("emeraldbank.income_period")) or 1800
2021-10-20 17:58:12 +02:00
local timer = 0
core.register_globalstep(function(dtime)
timer = timer + dtime;
if timer >= income_period then
timer = 0
for _, player in ipairs(core.get_connected_players()) do
if not player or player.is_fake_player then return end
local name = player:get_player_name()
2023-01-04 21:36:26 +01:00
mcl_title.set(player, "subtitle", {text=S("You have earned @1 emeralds in your bank account!", income_count), color="green"})
2021-10-20 17:58:12 +02:00
emeraldbank.add_emeralds(player, income_count)
2021-10-13 14:23:24 +02:00
end
2021-10-20 17:58:12 +02:00
end
end)