mirror of
https://codeberg.org/usrib/emeraldbank.git
synced 2025-01-10 23:37:31 +01:00
new shops move emeralds in inventary to owner bank account
This commit is contained in:
parent
f68657b2bf
commit
794cd3cad7
@ -99,11 +99,29 @@ function emeraldbank.add_emeralds(player, num)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function emeraldbank.inv_emeralds_to_stonks(pos)
|
||||||
|
local meta = core.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
local stonks = meta:get_int("stonks")
|
||||||
|
local fancy_inv = inv:get_list("main")
|
||||||
|
if not fancy_inv then return end
|
||||||
|
local has_emerald = inv:contains_item("main", "mcl_core:emerald 1", true)
|
||||||
|
if has_emerald then
|
||||||
|
meta:set_int("stonks", stonks+1)
|
||||||
|
inv:remove_item("main", "mcl_core:emerald 1")
|
||||||
|
emeraldbank.inv_emeralds_to_stonks(pos)
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function emeraldbank.get_stonks(pos)
|
function emeraldbank.get_stonks(pos)
|
||||||
local meta = core.get_meta(pos)
|
local meta = core.get_meta(pos)
|
||||||
local owner = meta:get_string("owner")
|
local owner = meta:get_string("owner")
|
||||||
local player = core.get_player_by_name(owner)
|
local player = core.get_player_by_name(owner)
|
||||||
local is_online = core.player_exists(owner)
|
local is_online = core.player_exists(owner)
|
||||||
|
emeraldbank.inv_emeralds_to_stonks(pos)
|
||||||
local stonks = meta:get_int("stonks")
|
local stonks = meta:get_int("stonks")
|
||||||
if not player or player.is_fake_player then return end
|
if not player or player.is_fake_player then return end
|
||||||
if is_online and stonks > 0 then
|
if is_online and stonks > 0 then
|
||||||
|
Loading…
Reference in New Issue
Block a user