2021-10-13 14:23:40 +02:00
|
|
|
|
|
|
|
|
2023-08-17 21:10:08 +02:00
|
|
|
-- Copyright (C) 2021, 2023 Ale
|
2021-10-13 14:23:40 +02:00
|
|
|
|
|
|
|
-- This file is part of Emeraldbank Minetest Mod.
|
|
|
|
|
|
|
|
-- Emeraldbank is free software: you can redistribute it and/or modify
|
2022-03-11 19:02:35 +01:00
|
|
|
-- 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:40 +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
|
2022-03-11 19:02:35 +01:00
|
|
|
-- GNU Affero General Public License for more details.
|
2021-10-13 14:23:40 +02:00
|
|
|
|
2022-03-11 19:02:35 +01:00
|
|
|
-- You should have received a copy of the GNU Affero General Public License
|
2021-10-13 14:23:40 +02:00
|
|
|
-- along with Emeraldbank. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local S = core.get_translator(core.get_current_modname())
|
|
|
|
|
|
|
|
|
|
|
|
-- user /pay chat command
|
|
|
|
core.register_chatcommand("pay", {
|
|
|
|
params = "<player> <num>",
|
|
|
|
description = S("Pay money to other player. Transfer your emeralds to another bank account."),
|
|
|
|
func = function(name, param)
|
2023-08-25 17:06:28 +02:00
|
|
|
local player1 = core.get_player_by_name(name)
|
|
|
|
local name2, stringnum = param:match("([^ ]+) (.+)")
|
2021-10-13 14:23:40 +02:00
|
|
|
local player2
|
|
|
|
local num = tonumber(stringnum)
|
2023-08-25 17:06:28 +02:00
|
|
|
if name2 and num then
|
|
|
|
player2 = core.get_player_by_name(name2)
|
2021-10-13 14:23:40 +02:00
|
|
|
end
|
|
|
|
if player2 and num then
|
2023-08-25 17:06:28 +02:00
|
|
|
return emeraldbank.transfer_emeralds(player1, player2, num)
|
2021-10-13 14:23:40 +02:00
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
-- admin chat command
|
|
|
|
core.register_chatcommand("emeralds", {
|
|
|
|
params = "<player> <num>",
|
|
|
|
description = S("Admin Command! Add player emeralds in bank account, also can use negative numbers"),
|
2023-08-25 17:06:28 +02:00
|
|
|
privs = {server=true},
|
|
|
|
func = function(name, param)
|
|
|
|
local playername, stringnum = param:match("([^ ]+) (.+)")
|
|
|
|
local player
|
2021-10-13 14:23:40 +02:00
|
|
|
local num = tonumber(stringnum)
|
|
|
|
if playername and num then
|
|
|
|
player = core.get_player_by_name(playername)
|
|
|
|
end
|
|
|
|
if player and num then
|
2021-10-20 17:39:17 +02:00
|
|
|
emeraldbank.add_emeralds(player, num)
|
2023-08-30 02:58:29 +02:00
|
|
|
atm.read_account(playername)
|
2023-08-25 17:23:36 +02:00
|
|
|
minetest.chat_send_player(name, S("@1 has now @2 emeralds in bank account", playername, atm.balance[playername]))
|
2021-10-13 14:23:40 +02:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
})
|
2023-08-25 17:06:28 +02:00
|
|
|
|
|
|
|
-- experimental upgrade command
|
|
|
|
core.register_chatcommand("upgrade", {
|
|
|
|
description = S("Admin Command! Upgrade a shop"),
|
|
|
|
privs = {server=true},
|
|
|
|
func = function(name, param)
|
|
|
|
local player = core.get_player_by_name(name)
|
|
|
|
local pos = player:get_pos()
|
|
|
|
local nodename = core.get_node(pos).name
|
|
|
|
if nodename == "emeraldbank:shop" or nodename == "emeraldbank:shop_empty" then
|
|
|
|
emeraldbank.upgrade_shop(pos)
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
})
|