|
|
|
@ -81,19 +81,6 @@ function emeraldbank.update_account()
|
|
|
|
|
atm.saveaccounts()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function emeraldbank.old_add_emeralds(player, num)
|
|
|
|
|
if not player then return false end
|
|
|
|
|
local meta = player:get_meta()
|
|
|
|
|
local bankemeralds = meta:get_int("emeraldbank:emerald") -- if nil "get_int()" return 0 Magic!
|
|
|
|
|
local name = player:get_player_name()
|
|
|
|
|
if num then
|
|
|
|
|
meta:set_int("emeraldbank:emerald", bankemeralds+num)
|
|
|
|
|
mcl_title.set(player, "actionbar", {text=S("Emeralds in Bank: @1", bankemeralds+num), color="yellow"})
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function emeraldbank.add_emeralds(player, num)
|
|
|
|
|
atm.readaccounts()
|
|
|
|
|
if not player then return false end
|
|
|
|
@ -143,42 +130,6 @@ function emeraldbank.transfer_emeralds(player1, player2, num)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function emeraldbank.keep(player, itemstack)
|
|
|
|
|
local itemname = itemstack:get_name()
|
|
|
|
|
local itemcount = itemstack:get_count()
|
|
|
|
|
local name = player:get_player_name()
|
|
|
|
|
if itemname == "mcl_core:emerald" then
|
|
|
|
|
itemstack:take_item(itemcount)
|
|
|
|
|
emeraldbank.add_emeralds(player, itemcount)
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
if itemname == "mcl_core:emeraldblock" then
|
|
|
|
|
itemstack:take_item(itemcount)
|
|
|
|
|
emeraldbank.add_emeralds(player, itemcount*9)
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
mcl_title.set(player, "actionbar", {text=S("You need keep emeralds or emeraldblocks in your hand!"), color="dark_red"})
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function emeraldbank.take(player)
|
|
|
|
|
local meta = player:get_meta()
|
|
|
|
|
local bankemeralds = meta:get_int("emeraldbank:emerald")
|
|
|
|
|
local name = player:get_player_name()
|
|
|
|
|
local pos = player:get_pos()
|
|
|
|
|
local num = 1
|
|
|
|
|
if bankemeralds >= 1 then
|
|
|
|
|
if bankemeralds >= 10 then
|
|
|
|
|
num = 10
|
|
|
|
|
end
|
|
|
|
|
emeraldbank.add_emeralds(player, -num)
|
|
|
|
|
core.add_item(pos, "mcl_core:emerald "..num)
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
mcl_title.set(player, "actionbar", {text=S("Not enough Emeralds in your account"), color="dark_red"})
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- wire transfer data storage
|
|
|
|
|
|
|
|
|
|