mirror of
https://codeberg.org/usrib/emeraldbank.git
synced 2024-08-19 21:04:09 +02:00
51 lines
1.6 KiB
Lua
51 lines
1.6 KiB
Lua
|
|
|
|
-- Copyright (C) 2021 Sandro Del Toro De Ana
|
|
|
|
-- 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 General Public License as published by
|
|
-- the Free Software Foundation, either version 3 of the License, or
|
|
-- (at your option) any later version.
|
|
|
|
-- 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 General Public License for more details.
|
|
|
|
-- You should have received a copy of the GNU General Public License
|
|
-- along with Emeraldbank. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
local S = core.get_translator(core.get_current_modname())
|
|
|
|
|
|
local income_count = tonumber(core.settings:get("emeraldbank.income_count")) or 1
|
|
local income_period = tonumber(core.settings:get("emeraldbank.income_period")) or 1800
|
|
|
|
|
|
-- income
|
|
if income_enabled then
|
|
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 meta = player:get_meta()
|
|
local name = player:get_player_name()
|
|
local bankemeralds = meta:get_int("emeraldbank:emerald")
|
|
local total = bankemeralds+income_count
|
|
meta:set_int("emeraldbank:emerald", total)
|
|
core.chat_send_player(name, S("You have earned @1 emeralds in your bank account!", income_count) )
|
|
end
|
|
end
|
|
end
|
|
)
|
|
end
|