mirror of
https://codeberg.org/usrib/emeraldbank.git
synced 2024-08-18 20:34:04 +02:00
un timer recauda el dinero de las tiendas si el jugador esta online
This commit is contained in:
parent
3d21c146b1
commit
e8189b3641
18
shop.lua
18
shop.lua
@ -23,6 +23,8 @@ local S = core.get_translator(core.get_current_modname())
|
||||
|
||||
local shopcraft = core.settings:get_bool("emeraldbank.shop_craft") or true
|
||||
|
||||
local shop_timer = 5
|
||||
|
||||
local stock_h = 3
|
||||
local stock_w = 5
|
||||
|
||||
@ -126,6 +128,7 @@ core.register_node("emeraldbank:shop", {
|
||||
local meta = core.get_meta(pos)
|
||||
meta:set_string("infotext", S("Exchange shop (owned by @1)", owner))
|
||||
meta:set_string("owner", owner)
|
||||
core.get_node_timer(pos):start(shop_timer)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("stock", stock_w*stock_h)
|
||||
end,
|
||||
@ -143,6 +146,18 @@ core.register_node("emeraldbank:shop", {
|
||||
on_metadata_inventory_put = set_item,
|
||||
|
||||
on_metadata_inventory_take = check_empty,
|
||||
|
||||
on_timer = function(pos, elapsed)
|
||||
local meta = core.get_meta(pos)
|
||||
local owner = meta:get_string("owner")
|
||||
local is_online = core.player_exists(owner)
|
||||
if is_online then
|
||||
local player = core.get_player_by_name(owner)
|
||||
if not player or player.is_fake_player then return end
|
||||
get_stonks(pos, player)
|
||||
end
|
||||
core.get_node_timer(pos):start(shop_timer)
|
||||
end,
|
||||
|
||||
can_dig = function(pos, player)
|
||||
local pname = player:get_player_name()
|
||||
@ -176,6 +191,9 @@ core.register_on_player_receive_fields(function(sender, formname, fields)
|
||||
local minv = meta:get_inventory()
|
||||
local pinv = sender:get_inventory()
|
||||
local bankemeralds = playermeta:get_int("emeraldbank:emerald")
|
||||
|
||||
-- set or reset timer
|
||||
core.get_node_timer(pos):start(shop_timer)
|
||||
|
||||
if fields.count and string.find(fields.count, "^[0-9]+$") then
|
||||
if new_count >= 1 and new_count <= 64 and new_count ~= meta:get_int("count") then
|
||||
|
Loading…
Reference in New Issue
Block a user