* Adicionando arquivos

This commit is contained in:
Lunovox 2017-03-13 18:26:38 -03:00
parent 951dc999fe
commit 3c4ecc7236
60 changed files with 1407 additions and 0 deletions

149
api.lua Normal file
View file

@ -0,0 +1,149 @@
--FONTE: https://forum.minetest.net/viewtopic.php?pid=48124
minetest.register_privilege("checkchest", {
description="O poder abrir os baus trancados de outros jogadores",
give_to_singleplayer=false,
})
modMinerTrade.safe = {}
modMinerTrade.getNodesInRange = function(pos, search_distance, node_name)
if pos==nil then return 0 end
if pos.x==nil or type(pos.x)~="number" then return 0 end
if pos.y==nil or type(pos.y)~="number" then return 0 end
if pos.z==nil or type(pos.z)~="number" then return 0 end
if search_distance==nil or type(search_distance)~="number" and search_distance<=0 then return 0 end
if node_name==nil or type(node_name)~="string" and node_name=="" then return 0 end
local minp = {x=pos.x-search_distance,y=pos.y-search_distance, z=pos.z-search_distance}
local maxp = {x=pos.x+search_distance,y=pos.y+search_distance, z=pos.z+search_distance}
local nodes = minetest.env:find_nodes_in_area(minp, maxp, node_name)
return #nodes
end
modMinerTrade.doSave = function()
local file = io.open(modMinerTrade.urlTabela, "w")
if file then
file:write(minetest.serialize(modMinerTrade.safe))
file:close()
--minetest.log('action',"[MINERTRADE] Banco de dados salvo !")
else
minetest.log('error',"[MINERTRADE:ERRO] O arquivo '"..modMinerTrade.urlTabela.."' não esta no formato de tabela!")
end
end
modMinerTrade.doLoad = function()
local file = io.open(modMinerTrade.urlTabela, "r")
if file then
modMinerTrade.safe = minetest.deserialize(file:read("*all"))
file:close()
if not modMinerTrade.safe or type(modMinerTrade.safe) ~= "table" then
minetest.log('error',"[MINERTRADE:ERRO] O arquivo '"..modMinerTrade.urlTabela.."' não esta no formato de tabela!")
return { }
else
minetest.log('action',"[MINERTRADE] Abrindo '"..modMinerTrade.urlTabela.."' !")
end
end
end
modMinerTrade.setSafeInventory = function(playername, tblListInventory)
local newInv = minetest.create_detached_inventory_raw("safe_"..playername)
newInv:set_list("safe", tblListInventory)
local tamanho = newInv:get_size("safe")
modMinerTrade.safe[playername] = { }
for i=1,tamanho do
modMinerTrade.safe[playername][i] = newInv:get_stack("safe", i):to_table()
end
end
modMinerTrade.getSafeInventory = function(playername)
local newInv = minetest.create_detached_inventory_raw("safe_"..playername)
newInv:set_size("safe", modMinerTrade.size.width*modMinerTrade.size.height)
local listInventory = { }
for i=1,(modMinerTrade.size.width*modMinerTrade.size.height) do
if modMinerTrade.safe and modMinerTrade.safe[playername] and modMinerTrade.safe[playername][i] then
newInv:set_stack("safe", i, ItemStack(modMinerTrade.safe[playername][i]))
else
newInv:set_stack("safe", i, nil)
end
end
return newInv:get_list("safe")
end
modMinerTrade.getFormspec = function(playername)
--local playername = player:get_player_name()
local formspec = "size[8,9]"
.."bgcolor[#636D76FF;false]"
--..default.gui_bg
--..default.gui_bg_img
..default.gui_slots
--.."list[detached:safe_"..playername .. ";safe;1,1;"..modMinerTrade.size.width..","..modMinerTrade.size.height..";]" -- <= ATENCAO: Nao pode esquecer o prefixo 'detached:xxxxxxx'
.."list[detached:safe_"..playername .. ";safe;"
..((8 - modMinerTrade.size.width)/2)..","..((4 - modMinerTrade.size.height)/2)..";"
..modMinerTrade.size.width..","..modMinerTrade.size.height
..";]" -- <= ATENCAO: Nao pode esquecer o prefixo 'detached:xxxxxxx'
.."list[current_player;main;0,5;8,4;]"
.."listring[detached:safe_"..playername .. ";safe]"
.."listring[current_player;main]"
return formspec
end
modMinerTrade.isOpen = function(meta, player)
if player:get_player_name() == meta:get_string("owner")
or minetest.get_player_privs(player:get_player_name()).server
or minetest.get_player_privs(player:get_player_name()).checkchest
or (minetest.get_modpath("tradelands") and modTradeLands.canInteract(player:getpos(), player:get_player_name()))
then
return true
end
return false
end
modMinerTrade.getDetachedInventory = function(playername)
-- playername = player:get_player_name()
local newInv = minetest.create_detached_inventory("safe_"..playername, { --trunk
-- Called when a player wants to move items inside the inventory
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
return count
end,
-- Called when a player wants to put items into the inventory
allow_put = function(inv, listname, index, stack, player)
return stack:get_count()
end,
-- Called when a player wants to take items out of the inventory
allow_take = function(inv, listname, index, stack, player)
return stack:get_count()
end,
-- on_* - no return value
-- Called after the actual action has happened, according to what was allowed.
on_move = function(inv, from_list, from_index, to_list, to_index, count, player)
modMinerTrade.setSafeInventory(playername, inv:get_list("safe"))
--minetest.log('action',playername.." colocou "..stack:get_count().." '"..stack:get_name().."' em seu cofre!")
end,
on_put = function(inv, listname, index, stack, player)
modMinerTrade.setSafeInventory(playername, inv:get_list("safe"))
minetest.log('action',playername.." colocou "..stack:get_count().." '"..stack:get_name().."' em seu cofre!")
end,
on_take = function(inv, listname, index, stack, player)
modMinerTrade.setSafeInventory(playername, inv:get_list("safe"))
minetest.log('action',playername.." retirou "..stack:get_count().." '"..stack:get_name().."' de seu cofre!")
end,
})
local invList = modMinerTrade.getSafeInventory(playername)
if invList~=nil and #invList>=1 then
newInv:set_list("safe", invList)
else
newInv:set_size("safe", modMinerTrade.size.width*modMinerTrade.size.height)
end
return newInv
end

52
commands.lua Normal file
View file

@ -0,0 +1,52 @@
minetest.register_privilege("checkchest", {
description="Jogador pode usar cheat",
give_to_singleplayer=false,
})
modMinerTrade.doCheckStrongBox = function(playername, param)
local targetname = string.match(param, "^([^ ]+)$")
if type(targetname)=="string" and targetname~="" then
if modMinerTrade.safe and modMinerTrade.safe[targetname] then
local inv = modMinerTrade.getDetachedInventory(targetname)
minetest.show_formspec(
playername,
"safe_"..targetname,
modMinerTrade.getFormspec(targetname)
)
return true
else
minetest.chat_send_player(playername, "[STRONGBOX:ERRO] O cofre de "..dump(targetname).." nao foi criado ainda!")
end
else
minetest.chat_send_player(playername, "[STRONGBOX:ERRO] /checkstrongbox <PlayerName>")
end
return false
end
minetest.register_chatcommand("checkstrongbox", {
params = "<JogadorAlvo>",
description = "verifica o Cofre do jogador alvo",
privs = {checkchest=true},
func = function(playername, param)
return modMinerTrade.doCheckStrongBox(playername, param)
end,
})
minetest.register_chatcommand("csb", {
params = "<JogadorAlvo>",
description = "verifica o Cofre do jogador alvo",
privs = {checkchest=true},
func = function(playername, param)
return modMinerTrade.doCheckStrongBox(playername, param)
end,
})
minetest.register_chatcommand("checarcofre", {
params = "<JogadorAlvo>",
description = "verifica o Cofre do jogador alvo",
privs = {checkchest=true},
func = function(playername, param)
return modMinerTrade.doCheckStrongBox(playername, param)
end,
})

8
config.lua Normal file
View file

@ -0,0 +1,8 @@
modMinerTrade = {
urlTabela = minetest.get_worldpath().."/minertrade.db", --Extensao '.tbl' ou '.db'
delayConstruct = 1800, -- Após colocar o atm ou o strongbox no chão existe um intervalo 1800 segundos para começar a utilizá-los.
size = {
width = 6, --Slots number of atm and strongbox (Default:6 Max:8)
height = 2, --Slots number of atm and strongbox (Default:2 Max:4)
},
}

5
depends.txt Normal file
View file

@ -0,0 +1,5 @@
default
doors?
lunomods?
lunotrades?
tradelands?

0
depends2.txt Normal file
View file

10
description.txt Normal file
View file

@ -0,0 +1,10 @@
Habilita itens:
* Minemoedas
* Mesa de Escambo (P2P)
* Maquina de Escambo
Licence:
* GNU AGPL: https://pt.wikipedia.org/wiki/GNU_Affero_General_Public_License
Developers:
* Lunovox <lunovox@openmailbox.org>

10
description2.txt Normal file
View file

@ -0,0 +1,10 @@
Adiciona cofre interligado com o caixa eletronico para guardar seu dinheiros e pertences valiosos. O cofre precisa de 30 minutos para serem ativados apos seu posicionamento no mapa para evitar que os jogadores levem o cofre para sua exploracao do mapa. Se o mod lunotrades estiver ativado, o Caixa Eletronico so pode ser posicionado proximo a uma maquina de escambo.
Licence:
* GNU AGPL: https://pt.wikipedia.org/wiki/GNU_Affero_General_Public_License
Developers:
* Lunovox <lunovox@openmailbox.org>
Comandos:
* /csb ou /checkstrongbox -- Exibe o que um jogador tem no inventario (necessita de priv 'server').

32
init.lua Normal file
View file

@ -0,0 +1,32 @@
local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname)
dofile(modpath.."/config.lua")
dofile(modpath.."/api.lua")
dofile(modpath.."/commands.lua")
dofile(modpath.."/item_atm.lua")
dofile(modpath.."/item_strongbox.lua")
--dofile(modpath.."/item_strongbox_old.lua")
dofile(modpath.."/item_miner_cash.lua")
-- dofile(modpath.."/item_barter_table.lua")
dofile(modpath.."/item_dispensing_machine.lua")
-- --dofile(path.."/item_rent_door.lua")
modMinerTrade.doLoad()
minetest.register_on_leaveplayer(function(player)
modMinerTrade.doSave()
end)
minetest.register_on_shutdown(function()
modMinerTrade.doSave()
minetest.log('action',"[STRONGBOX] Salvando cofre de todos os jogadores no arquivo '"..modMinerTrade.urlTabela.."'!")
end)
minetest.log('action',"["..modname:upper().."] Carregado!")

0
init2.lua Normal file
View file

99
item_atm.lua Normal file
View file

@ -0,0 +1,99 @@
minetest.register_node("minertrade:atm", {
description = "Caixa Eletronico (ATM) - Guarde o seu dinheiro neste Caixa Eletrônico, e retire seu dinheiro em seu Cofre Pessoal ou qualquer outro Caixa Eletrônico espalhado pelo mapa.",
--inventory_image = minetest.inventorycube("text_atm_front_1.png"),
--inventory_image = "text_atm_front_1.png",
paramtype = "light",
sunlight_propagates = true,
light_source = default.LIGHT_MAX,
paramtype2 = "facedir",
--legacy_facedir_simple = true, --<=Nao sei para que serve!
tiles = {
"default_wood.png",
"default_wood.png",
"default_wood.png",
"default_wood.png",
"default_wood.png",
"text_atm_front_1.png",
},
is_ground_content = false,
--groups = {cracky=1},
groups = {cracky=3,oddly_breakable_by_hand=3},
--sounds = default.node_sound_glass_defaults(),
on_place = function(itemstack, placer, pointed_thing)
local playername = placer:get_player_name()
if not pointed_thing.type == "node" then
return itemstack
end
local posAbove = pointed_thing.above --acima
local posUnder = pointed_thing.under --abaixo
if not placer or not placer:is_player() or
not minetest.registered_nodes[minetest.get_node(posAbove).name].buildable_to
then --Verifica se pode construir sobre os objetos construiveis
return itemstack
end
local nodeUnder = minetest.get_node(posUnder)
if minetest.registered_nodes[nodeUnder.name].on_rightclick then --Verifica se o itema na mao do jogador tem funcao rightclick
return minetest.registered_nodes[nodeUnder.name].on_rightclick(posUnder, nodeUnder, placer, itemstack)
end
if
minetest.get_player_privs(playername).server
or modMinerTrade.getNodesInRange(posAbove, 2, "minertrade:dispensingmachine")>=1
then
local facedir = minetest.dir_to_facedir(placer:get_look_dir())
--minetest.chat_send_player(playername, "[ATM] aaaaaa")
minetest.set_node(posAbove, {
name = "minertrade:atm",
param2 = facedir,
})
local meta = minetest.get_meta(posAbove)
meta:set_string("infotext", "Caixa Eletronico (ATM) - Guarde o seu dinheiro neste Caixa Eletrônico, e retire seu dinheiro em seu Cofre Pessoal ou qualquer outro Caixa Eletrônico espalhado pelo mapa.")
local now = os.time() --Em milisegundos
if not minetest.get_player_privs(playername).server then
meta:set_string("opentime", now+modMinerTrade.delayConstruct)
else
meta:set_string("opentime", now)
end
itemstack:take_item() -- itemstack:take_item() = Ok
else
minetest.chat_send_player(playername, "[ATM] Voce nao pode por este caixa eletronico muito longe de uma Maquina Dispensadora!")
--return itemstack -- = Cancel
end
return itemstack
end,
on_rightclick = function(pos, node, clicker)
local playername = clicker:get_player_name()
local meta = minetest.get_meta(pos)
local opentime = tonumber(meta:get_string("opentime")) or 0
local now = os.time() --Em milisegundos
if now >= opentime or minetest.get_player_privs(playername).server then
local inv = modMinerTrade.getDetachedInventory(playername)
minetest.show_formspec(
playername,
"safe_"..playername,
modMinerTrade.getFormspec(playername)
)
else
minetest.chat_send_player(playername, "[ATM] O Caixa Eletronico so vai funcionar "..(opentime-now).." segundos depois de instalado!")
end
end,
})
minetest.register_craft({
output = 'minertrade:atm',
recipe = {
{"default:wood" ,"default:wood" ,"default:wood"},
{"default:wood" ,"default:obsidian_glass" ,"default:wood"},
{"default:wood" ,"default:mese" ,"default:wood"},
}
})
minetest.register_alias("atm" ,"minertrade:atm")
minetest.register_alias("atmbox" ,"minertrade:atm")
minetest.register_alias("caixaeletronico" ,"minertrade:atm")

205
item_barter_table.lua Normal file
View file

@ -0,0 +1,205 @@
lunotrades.balcaodeescambo = {}
lunotrades.balcaodeescambo.formspec = {
--[[
main = "size[8,9]"..
"list[current_name;pl1;0,0;3,4;]"..
"list[current_name;pl2;5,0;3,4;]"..
"list[current_player;main;0,5;8,4;]",
pl1 = {
start = "button[3,1;2,1;pl1_start;Oferecer]",
player = function(name) return "label[3,0;"..name.."]" end,
accept1 = "button[3,1;2,1;pl1_accept1;Confirmar]"..
"button[3,2;2,1;pl1_cancel;Cancelar]",
accept2 = "button[3,1;2,1;pl1_accept2;Trocar]"..
"button[3,2;2,1;pl1_cancel;Cancelar]",
},
pl2 = {
start = "button[4,1;2,1;pl2_start;Oferecer]",
player = function(name) return "label[4,0;"..name.."]" end,
accept1 = "button[4,1;2,1;pl2_accept1;Confirmar]"..
"button[4,2;2,1;pl2_cancel;Cancelar]",
accept2 = "button[4,1;2,1;pl2_accept2;Trocar]"..
"button[4,2;2,1;pl2_cancel;Cancelar]",
},
--]]
main = "size[10,9.5]"..
"label[3.5,0;MESA DE ESCAMBO (P2P)]"..
"list[current_name;pl1;0,1;3,4;]"..
"list[current_name;pl2;7,1;3,4;]"..
"label[1,5;Seu inventario:]"..
"list[current_player;main;1,5.5;8,4;]",
pl1 = {
start = "button[3,1;2.0,1;pl1_start;Abrir]",
player = function(name) return "label[0,0.5;"..name.." oferece:]" end,
accept1 = "button[3,1;2,1;pl1_accept1;Oferecer]"..
"button[3,2;2,1;pl1_cancel;Cancelar]",
accept2 = "button[3,1;2,1;pl1_accept2;Confirmar]"..
"button[3,2;2,1;pl1_cancel;Cancelar]",
},
pl2 = {
start = "button[5,1;2.0,1;pl2_start;Abrir]",
player = function(name) return "label[7,0.5;"..name.." oferece:]" end,
accept1 = "button[5,1;2,1;pl2_accept1;Oferecer]"..
"button[5,2;2,1;pl2_cancel;Cancelar]",
accept2 = "button[5,1;2,1;pl2_accept2;Confirmar]"..
"button[5,2;2,1;pl2_cancel;Cancelar]",
},
}
lunotrades.balcaodeescambo.getPrivilegios = function(listname,playername,meta)
if listname == "pl1" then
if playername ~= meta:get_string("pl1") then
return false
elseif meta:get_int("pl1step") ~= 1 then
return false
end
end
if listname == "pl2" then
if playername ~= meta:get_string("pl2") then
return false
elseif meta:get_int("pl2step") ~= 1 then
return false
end
end
return true
end
lunotrades.balcaodeescambo.update_formspec = function(meta)
local formspec = lunotrades.balcaodeescambo.formspec.main --10:18:33: ERROR[ServerThread]: Assignment to undeclared global "formspec" inside a function at /home/lunovox/.minetest/mods/lunotrades/balcaodeescambo.lua:68.
local pl_formspec = function (n)
if meta:get_int(n.."step")==0 then
formspec = formspec .. lunotrades.balcaodeescambo.formspec[n].start
else
formspec = formspec .. lunotrades.balcaodeescambo.formspec[n].player(meta:get_string(n))
if meta:get_int(n.."step") == 1 then
formspec = formspec .. lunotrades.balcaodeescambo.formspec[n].accept1
elseif meta:get_int(n.."step") == 2 then
formspec = formspec .. lunotrades.balcaodeescambo.formspec[n].accept2
end
end
end
pl_formspec("pl1") --10:18:33: ERROR[ServerThread]: Assignment to undeclared global "pl_formspec" inside a function at /home/lunovox/.minetest/mods/lunotrades/balcaodeescambo.lua:80.
pl_formspec("pl2")
meta:set_string("formspec",formspec)
end
lunotrades.balcaodeescambo.getInventario = function(inv,list,playername)
local player = minetest.env:get_player_by_name(playername)
if player then
for k,v in ipairs(inv:get_list(list)) do
player:get_inventory():add_item("main",v)
inv:remove_item(list,v)
end
end
end
lunotrades.balcaodeescambo.cancel = function(meta)
lunotrades.balcaodeescambo.getInventario(meta:get_inventory(),"pl1",meta:get_string("pl1"))
lunotrades.balcaodeescambo.getInventario(meta:get_inventory(),"pl2",meta:get_string("pl2"))
meta:set_string("pl1","")
meta:set_string("pl2","")
meta:set_int("pl1step",0)
meta:set_int("pl2step",0)
end
lunotrades.balcaodeescambo.exchange = function(meta)
lunotrades.balcaodeescambo.getInventario(meta:get_inventory(),"pl1",meta:get_string("pl2"))
lunotrades.balcaodeescambo.getInventario(meta:get_inventory(),"pl2",meta:get_string("pl1"))
meta:set_string("pl1","")
meta:set_string("pl2","")
meta:set_int("pl1step",0)
meta:set_int("pl2step",0)
end
minetest.register_node("lunotrades:balcaodeescambo", {
description = "Mesa de Escambo (Player to Player)",
tiles = {"balcao_topo.png", "balcao1_baixo.png", "balcao1_lado.png"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("infotext", "Mesa de Escambo (Player to Player)")
meta:set_string("pl1","")
meta:set_string("pl2","")
lunotrades.balcaodeescambo.update_formspec(meta)
local inv = meta:get_inventory()
inv:set_size("pl1", 3*4)
inv:set_size("pl2", 3*4)
end,
on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.env:get_meta(pos)
local pl_receive_fields = function(n)
if fields[n.."_start"] and meta:get_string(n) == "" then
minetest.sound_play("sfx_alert", {object=sender, max_hear_distance=5.0,})
meta:set_string(n,sender:get_player_name())
end
if meta:get_string(n) == "" then
meta:set_int(n.."step",0)
elseif meta:get_int(n.."step")==0 then
meta:set_int(n.."step",1)
end
if sender:get_player_name() == meta:get_string(n) then
if meta:get_int(n.."step")==1 and fields[n.."_accept1"] then
minetest.sound_play("sfx_alert", {object=sender, max_hear_distance=5.0,})
meta:set_int(n.."step",2)
end
if meta:get_int(n.."step")==2 and fields[n.."_accept2"] then
minetest.sound_play("sfx_alert", {object=sender, max_hear_distance=5.0,})
meta:set_int(n.."step",3)
if n == "pl1" and meta:get_int("pl2step") == 3 then lunotrades.balcaodeescambo.exchange(meta) end
if n == "pl2" and meta:get_int("pl1step") == 3 then lunotrades.balcaodeescambo.exchange(meta) end
end
if fields[n.."_cancel"] then
minetest.sound_play("sfx_alert", {object=sender, max_hear_distance=5.0,})
lunotrades.balcaodeescambo.cancel(meta)
end
end
end
pl_receive_fields("pl1") --10:18:33: ERROR[ServerThread]: Assignment to undeclared global "pl_receive_fields" inside a function at /home/lunovox/.minetest/mods/lunotrades/balcaodeescambo.lua:156.
pl_receive_fields("pl2")
-- End
lunotrades.balcaodeescambo.update_formspec(meta)
end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local meta = minetest.env:get_meta(pos)
if not lunotrades.balcaodeescambo.getPrivilegios(from_list,player:get_player_name(),meta) then return 0 end
if not lunotrades.balcaodeescambo.getPrivilegios(to_list,player:get_player_name(),meta) then return 0 end
return count
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.env:get_meta(pos)
if not lunotrades.balcaodeescambo.getPrivilegios(listname,player:get_player_name(),meta) then return 0 end
return stack:get_count()
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
local meta = minetest.env:get_meta(pos)
if not lunotrades.balcaodeescambo.getPrivilegios(listname,player:get_player_name(),meta) then return 0 end
return stack:get_count()
end,
})
--[[
minetest.register_craft({
output = 'lunotrades:balcaodeescambo',
recipe = {
{"group:wood" ,"group:wood" ,"group:wood"},
{"default:stick" ,"wool:red" ,"default:stick"},
{"default:stick" ,"wool:red" ,"default:stick"},
}
})
]]--
minetest.register_craft({
output = 'lunotrades:balcaodeescambo',
recipe = {
{"group:wood" ,"group:wood"},
{"group:wood" ,"group:wood"},
}
})
minetest.register_alias("balcaodeescambo" , "lunotrades:balcaodeescambo")
minetest.register_alias("balcaodetroca" , "lunotrades:balcaodeescambo")
minetest.register_alias("mesadeescambo" , "lunotrades:balcaodeescambo")
minetest.register_alias("mesadetroca" , "lunotrades:balcaodeescambo")

310
item_dispensing_machine.lua Normal file
View file

@ -0,0 +1,310 @@
modMinerTrade.dispensing = {
loja_atual = {}
}
modMinerTrade.dispensing.formspec = {
customer = function(pos)
local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z
local formspec = "size[8,10.5]"
--..default.gui_bg
--..default.gui_bg_img
--..default.gui_slots
.."bgcolor[#004400DD;false]"
--.."background[-0.5,0;8.5,11;dispensador_frente.png]"
--listcolors[slot_bg_normal;slot_bg_hover;slot_border;tooltip_bgcolor;tooltip_fontcolor]
.."listcolors[#00000055;#008800;#FFFFFF]"
.."label[2,-0.25;MÁQUINA DE DISPENSADORA]"
.."label[0,0.25;"..minetest.formspec_escape("* "..minetest.env:get_meta(pos):get_string("offer")).."]"
.."label[0,1.0;O Cliente Oferece:]"
.."list[current_player;customer_gives;0,1.5;3,2;]"
.."label[0,3.5;O Cliente Recebe:]"
.."list[current_player;customer_gets;0,4.0;3,2;]"
.."button[3,2.0;2,1;exchange;ACEITAR]"
.."label[0,6.0;Inventario atual do cliente:]"
.."list[current_player;main;0,6.5;8,4;]"
.."label[5,1.0;A Maquina Precisa:]"
.."list["..list_name..";owner_wants;5,1.5;3,2;]"
.."label[5,3.5;A Maquina Oferece:]"
.."list["..list_name..";owner_gives;5,4.0;3,2;]"
--.."listcolors[#00000000;#00000022;#00000000;#00000033;#FFFFFFFF]"
--.."listcolors[#00000000;#00000033]"
return formspec
end,
owner = function(pos)
local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z
local formspec = "size[8,11]"
.."bgcolor[#000000CC;false]"
--listcolors[slot_bg_normal;slot_bg_hover;slot_border;tooltip_bgcolor;tooltip_fontcolor]
.."listcolors[#88888844;#888888;#FFFFFF]"
.."label[0,0;Itens Recebido (Seu Lucro):]"
.."list["..list_name..";customers_gave;0,0.5;3,2;]"
.."label[0,2.5;Estoque a Oferetar:]"
.."list["..list_name..";stock;0,3;3,2;]"
.."label[5,0;Voce Precisa:]"
.."list["..list_name..";owner_wants;5,0.5;3,2;]"
.."label[5,2.5;Voce Oferece:]"
.."list["..list_name..";owner_gives;5,3;3,2;]"
--.."label[0,5;Proprietario: Pressione (E) + Botao(RMB) no Mouse para a interface com o cliente]"
--.."label[0,5;Vendedor: Evite o estoque baixo e guardar lucros no balcao.]"
.."field[0.29,5.75;8,0.85;txtOffer;"
.."Faça um anúncio sobre o que esta máquina dispensará:;"
..minetest.formspec_escape(
minetest.env:get_meta(pos):get_string("offer")
).."]"
.."label[0,6.25;Inventario atual do vendedor:]"
.."list[current_player;main;0,6.75.0;8,4;]"
.."label[2,10.75;(CTRL + Mouse = Interface do Cliente)]"
return formspec
end,
}
modMinerTrade.dispensing.getPrivilegio = function(listname,playername,meta)
--[[if listname == "pl1" then
if playername ~= meta:get_string("pl1") then
return false
elseif meta:get_int("pl1step") ~= 1 then
return false
end
end
if listname == "pl2" then
if playername ~= meta:get_string("pl2") then
return false
elseif meta:get_int("pl2step") ~= 1 then
return false
end
end]]
return true
end
modMinerTrade.dispensing.getInventario = function(inv,list,playername)
player = minetest.env:get_player_by_name(playername)
if player then
for k,v in ipairs(inv:get_list(list)) do
player:get_inventory():add_item("main",v)
inv:remove_item(list,v)
end
end
end
modMinerTrade.dispensing.cancel = function(meta)
--[[modMinerTrade.dispensing.getInventario(meta:get_inventory(),"pl1",meta:get_string("pl1"))
modMinerTrade.dispensing.getInventario(meta:get_inventory(),"pl2",meta:get_string("pl2"))
meta:set_string("pl1","")
meta:set_string("pl2","")
meta:set_int("pl1step",0)
meta:set_int("pl2step",0)]]
end
modMinerTrade.dispensing.exchange = function(meta)
--[[modMinerTrade.dispensing.getInventario(meta:get_inventory(),"pl1",meta:get_string("pl2"))
modMinerTrade.dispensing.getInventario(meta:get_inventory(),"pl2",meta:get_string("pl1"))
meta:set_string("pl1","")
meta:set_string("pl2","")
meta:set_int("pl1step",0)
meta:set_int("pl2step",0)]]
end
modMinerTrade.dispensing.canOpen = function(pos, playername)
local meta = minetest.env:get_meta(pos)
if
meta:get_string("owner")==playername
or (minetest.get_modpath("tradelands") and modTradeLands.canInteract(pos, playername))
then
return true
end
return false
end
local box_format = {
type = "fixed",
fixed = { {-.5,-.5,-.3125, .5,.5+1/3,.3125} }
}
minetest.register_node("minertrade:dispensingmachine", {
description = "Maquina Dispensadora (Vende itens por você)",
--tiles = {"balcao_topo.png", "balcao2_baixo.png", "balcao2_lado.png"},
drawtype = "nodebox",
paramtype = "light", --Nao sei pq, mas o blco nao aceita a luz se nao tiver esta propriedade
paramtype2 = "facedir",
sunlight_propagates = true,
light_source = LIGHT_MAX,
node_box = box_format,
selection_box = box_format,
tiles = {
"dispensador_cima.png",
"dispensador_baixo.png",
"dispensador_esquerda.png",
"dispensador_direita.png",
"dispensador_traz.png",
"dispensador_frente_grande.png"--.."^[transformfx"
},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
after_place_node = function(pos, placer, itemstack)
local owner = placer:get_player_name()
local meta = minetest.env:get_meta(pos)
meta:set_string("infotext", "Maquina Dispensadora de '"..owner.."'")
meta:set_string("owner",owner)
--[[meta:set_string("pl1","")
meta:set_string("pl2","")]]
local inv = meta:get_inventory()
inv:set_size("customers_gave", 3*2)
inv:set_size("stock", 3*2)
inv:set_size("owner_wants", 3*2)
inv:set_size("owner_gives", 3*2)
end,
on_rightclick = function(pos, node, clicker, itemstack)
--print("minertrade:dispensing.on_rightclick aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
clicker:get_inventory():set_size("customer_gives", 3*2)
clicker:get_inventory():set_size("customer_gets", 3*2)
modMinerTrade.dispensing.loja_atual[clicker:get_player_name()] = pos
local meta = minetest.env:get_meta(pos)
local clickername = clicker:get_player_name()
if modMinerTrade.dispensing.canOpen(pos, clickername) and not clicker:get_player_control().aux1 then
minetest.show_formspec(clickername,"modMinerTrade.balcaodeloja_formspec",modMinerTrade.dispensing.formspec.owner(pos))
else
minetest.show_formspec(clickername,"modMinerTrade.balcaodeloja_formspec",modMinerTrade.dispensing.formspec.customer(pos))
end
--return itemstack
end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local playername = player:get_player_name()
local meta = minetest.env:get_meta(pos)
if not modMinerTrade.dispensing.canOpen(pos, playername) then return 0 end
return count
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local playername = player:get_player_name()
local meta = minetest.env:get_meta(pos)
if not modMinerTrade.dispensing.canOpen(pos, playername) then return 0 end
return stack:get_count()
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
local playername = player:get_player_name()
local meta = minetest.env:get_meta(pos)
if not modMinerTrade.dispensing.canOpen(pos, playername) then return 0 end
return stack:get_count()
end,
can_dig = function(pos, player)
local playername = player:get_player_name()
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
local isCanDig = inv:is_empty("stock") and inv:is_empty("customers_gave") and inv:is_empty("owner_wants") and inv:is_empty("owner_gives")
if isCanDig~=true then
minetest.chat_send_player(playername,"[AVISO]: A Máquina Dispensadora não pode ser retirada antes de ser esvaziada!")
minetest.sound_play("sfx_alert", {object=player, max_hear_distance=5.0,})
end
return isCanDig
end
})
minetest.register_on_player_receive_fields(function(sender, formname, fields)
if formname == "modMinerTrade.balcaodeloja_formspec" then
local name = sender:get_player_name()
local pos = modMinerTrade.dispensing.loja_atual[name]
local meta = minetest.env:get_meta(pos)
local owner = meta:get_string("owner")
--minetest.chat_send_player(name,"owner('"..owner.."') == name('"..name.."')")
if modMinerTrade.dispensing.canOpen(pos, name) and sender:get_player_control().aux1 then
minetest.chat_send_player(name,"Voce nao pode trocar na sua propria maquina!")
minetest.sound_play("sfx_alert", {object=sender, max_hear_distance=5.0,})
return
else
--minetest.chat_send_player(name,"fields="..dump(fields))
if fields.txtOffer ~= nil then
if fields.txtOffer ~= "" then
meta:set_string("offer", fields.txtOffer)
meta:set_string("infotext",
"Maquina Dispensadora de '"..owner.."'.\n\n"
--.."Oferta: \n"..
.." * "..fields.txtOffer
)
else
meta:set_string("offer", "")
meta:set_string("infotext", "Maquina Dispensadora de '"..owner.."'.")
end
end
local minv = meta:get_inventory()
local pinv = sender:get_inventory()
local invlist_tostring = function(invlist)
local out = {}
for i, item in pairs(invlist) do
out[i] = item:to_string()
end
return out
end
local wants = minv:get_list("owner_wants")
local gives = minv:get_list("owner_gives")
if wants == nil or gives == nil then return end -- do not crash the server
-- Check if we can exchange
local can_exchange = true
local owners_fault = false
for i, item in pairs(wants) do
if not pinv:contains_item("customer_gives",item) then
can_exchange = false
end
end
for i, item in pairs(gives) do
if not minv:contains_item("stock",item) then
can_exchange = false
owners_fault = true
end
end
if can_exchange then
for i, item in pairs(wants) do
pinv:remove_item("customer_gives",item)
minv:add_item("customers_gave",item)
end
for i, item in pairs(gives) do
minv:remove_item("stock",item)
pinv:add_item("customer_gets",item)
end
minetest.chat_send_player(name,"Escambo feito!")
minetest.sound_play("sfx_cash_register", {object=sender, max_hear_distance=5.0,})
elseif fields.quit==nil then
if owners_fault then
minetest.chat_send_player(name,"O estoque de '"..owner.."' acabou. Contacte-o!")
else
minetest.chat_send_player(name,"O escambo nao pode ser feito. Verifique se voce ofereceu o que a maquina pede!")
end
minetest.sound_play("sfx_alert", {object=sender, max_hear_distance=5.0,})
end
end
end
end)
minetest.register_craft({
output = 'minertrade:dispensingmachine',
recipe = {
{"dye:dark_green" ,"default:steel_ingot" ,"default:steel_ingot"},
{"default:glass" ,"" ,"default:steel_ingot"},
{"dye:dark_green" ,"default:steel_ingot" ,"default:mese"},
--COMENTaRIO: dye:dark_green = dye:blue[B2] + dye:yellow[C2]
}
})
minetest.register_alias("maquinadispensadora" ,"minertrade:dispensingmachine")
minetest.register_alias("dispensadora" ,"minertrade:dispensingmachine")
minetest.register_alias("maquinadeloja" ,"minertrade:dispensingmachine")
minetest.register_alias("balcaodeloja" ,"minertrade:dispensingmachine")
minetest.register_alias("caixadeloja" ,"minertrade:dispensingmachine")
minetest.register_alias("loja" ,"minertrade:dispensingmachine")

120
item_miner_cash.lua Normal file
View file

@ -0,0 +1,120 @@
--#########################################################################################
minetest.register_craftitem("minertrade:minecoin", {
description = "Minermoeda (Dinheiro Craftável)",
inventory_image = "obj_minecoin.png",
stack_max=9, --Acumula 9 por slot
groups = { mobs=1 },
})
minetest.register_craft({
output = "minertrade:minecoin",
recipe = {
{"default:gold_ingot","default:steel_ingot","default:gold_ingot"},
},
--https://github.com/minetest/minetest_game/blob/master/mods/default/craftitems.lua
})
minetest.register_craft({
type = "cooking",
output = "default:gold_ingot",
recipe = "minertrade:minecoin",
cooktime = 5,
})
minetest.register_alias("minecoin", "minertrade:minecoin")
minetest.register_alias("minemoeda", "minertrade:minecoin")
--##########################################################################################################
minetest.register_craftitem("minertrade:minemoney", {
description = "Minercedula (Vale 9 Minermoedas)",
inventory_image = "obj_minemoney.png",
stack_max=9, --Acumula 9 por slot
groups = { mobs=1 },
})
minetest.register_craft({
output = "minertrade:minemoney",
recipe = {
{"minertrade:minecoin", "minertrade:minecoin", "minertrade:minecoin"},
{"minertrade:minecoin", "minertrade:minecoin", "minertrade:minecoin"},
{"minertrade:minecoin", "minertrade:minecoin", "minertrade:minecoin"}
},
})
minetest.register_craft({
output = "minertrade:minecoin 9",
recipe = {
{"minertrade:minemoney"},
},
})
minetest.register_alias("minemoney", "minertrade:minemoney")
minetest.register_alias("minedinheiro", "minertrade:minemoney")
--##########################################################################################################
minetest.register_craftitem("minertrade:piggybank", {
description = "Cofre Porquinho (Vale 9 Minercedulas)",
inventory_image = "obj_piggy_bank.png",
stack_max=9, --Acumula 9 por slot
groups = { mobs=1 },
})
minetest.register_craft({
output = "minertrade:piggybank",
recipe = {
{"minertrade:minemoney", "minertrade:minemoney", "minertrade:minemoney"},
{"minertrade:minemoney", "minertrade:minemoney", "minertrade:minemoney"},
{"minertrade:minemoney", "minertrade:minemoney", "minertrade:minemoney"}
},
})
minetest.register_craft({
output = "minertrade:minemoney 9",
recipe = {
{"minertrade:piggybank"},
},
})
minetest.register_alias("piggybank" , "minertrade:piggybank")
minetest.register_alias("cofreporquinho" , "minertrade:piggybank")
--##########################################################################################################
minetest.register_craftitem("minertrade:creditcard", {
description = "Cartão de Crédito (Vale 9 Cofre-Porquinhos)",
inventory_image = "obj_credit_card.png",
stack_max=9, --Acumula 9 por slot
groups = { mobs=1 },
})
minetest.register_craft({
output = "minertrade:creditcard",
recipe = {
{"minertrade:piggybank", "minertrade:piggybank", "minertrade:piggybank"},
{"minertrade:piggybank", "minertrade:piggybank", "minertrade:piggybank"},
{"minertrade:piggybank", "minertrade:piggybank", "minertrade:piggybank"}
},
})
minetest.register_craft({
output = "minertrade:piggybank 9",
recipe = {
{"minertrade:creditcard"},
},
})
minetest.register_alias("creditcard" , "minertrade:creditcard")
minetest.register_alias("cataodecredito" , "minertrade:creditcard")
--##########################################################################################################

234
item_rent_door.lua Normal file
View file

@ -0,0 +1,234 @@
lunotrades.rentdoorformspec = {
renter = function(pos)
local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z
local formspec = "size[8,10]"..
"label[2.5,0;PORTAL DE ALUGUEL]"..
--"label[0,0.5;O Locatador Oferece:]"..
--"list[current_player;customer_gives;0,1;3,2;]"..
--"label[0,3;O Cliente Recebe:]"..
--"list[current_player;customer_gets;0,3.5;3,2;]"..
"button[3,1.5;2,1;exchange;ACEITAR]"..
"label[5,0.5;O Locatario Precisa:]"..
"list["..list_name..";owner_wants;5,1;3,2;]"..
--"label[5,3;A Maquina Oferece:]"..
--"list["..list_name..";owner_gives;5,3.5;3,2;]"..
"label[0,5.5;Inventario atual do cliente:]"..
"list[current_player;main;0,6.0;8,4;]"
return formspec
end,
owner = function(pos)
local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z
local formspec = "size[8,10]"..
"label[0,0;Voce Recebe (Seu Lucro):]"..
"list["..list_name..";customers_gave;0,0.5;3,2;]"..
--"label[0,2.5;Estoque a Oferetar:]"..
--"list["..list_name..";stock;0,3;3,2;]"..
"label[5,0;Voce aluga por:]"..
"list["..list_name..";owner_wants;5,0.5;3,2;]"..
--"label[5,2.5;Voce Oferece:]"..
--"list["..list_name..";owner_gives;5,3;3,2;]"..
--"label[2,5;(CTRL + Mouse = Interface do Cliente)]"..
"label[0,5.5;Inventario atual do locatario:]"..
"list[current_player;main;0,6;8,4;]"
return formspec
end,
}
function lunotrades.doCTRLRightClick(pos, node, clicker)
if (
minetest.get_modpath("landrush")
and type(landrush.get_owner)=="function"
and landrush.get_owner(pos)~=nil
and landrush.get_owner(pos)~=""
) then
clicker:get_inventory():set_size("customer_gives", 3*2)
clicker:get_inventory():set_size("customer_gets", 3*2)
lunotrades.balcaodeloja.loja_atual[clicker:get_player_name()] = pos
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
if inv:is_empty("customers_gave") then
inv:set_size("customers_gave", 3*2)
end
--inv:set_size("stock", 3*2)
if inv:is_empty("owner_wants") then
inv:set_size("owner_wants", 3*2)
end
--inv:set_size("owner_gives", 3*2)
if landrush.get_owner(pos)~=clicker:get_player_name() then
--minetest.chat_send_player(clicker:get_player_name(), "aaaaa Vc nao ser o proprietario!")
minetest.show_formspec(clicker:get_player_name(),"lunotrades.rentdoor_formspec",lunotrades.rentdoorformspec.renter(pos))
else
--minetest.chat_send_player(clicker:get_player_name(), "bbbbb Vc SER o proprietario!")
minetest.show_formspec(clicker:get_player_name(),"lunotrades.rentdoor_formspec",lunotrades.rentdoorformspec.owner(pos))
end
end
end
function lunotrades.ifOpenDoor(pos, clicker)
if (
not minetest.get_modpath("landrush")
or type(landrush.get_owner)~="function"
or landrush.get_owner(pos)==nil
or landrush.get_owner(pos)==""
or landrush.get_owner(pos)==clicker:get_player_name()
) then
return true
else
local playername = clicker:get_player_name()
local meta = minetest.get_meta(pos)
local renter = meta:get_string("renter") --Jogador locatario
local expiration = meta:get_string("expiration") --Jogador locatario
local now = os.time()
--minetest.chat_send_player(clicker:get_player_name(), "Proprietario '"..dump(landrush.get_owner(pos)).."'!")
if expiration==nil or expiration=="" or now <= expiration then
if renter == playername then
return true
else
minetest.chat_send_player(clicker:get_player_name(), "Voce nao pode abrir esta porta alugada por '"..renter.."'!")
minetest.sound_play("sfx_falha", {object = clicker, gain = 2.0, max_hear_distance = 10})
end
else
minetest.chat_send_player(
clicker:get_player_name(),
"Seu tempo de aluguel desta porta acabou. Favor segure CTRL e clique sobre a porta para pagar nova temporada de aluguel para '"..dump(landrush.get_owner(pos)).."'!"
)
minetest.sound_play("sfx_falha", {object = clicker, gain = 2.0, max_hear_distance = 10})
end
return false
--[[
meta:set_string("infotext", "Owned by "..playername)
meta = minetest.get_meta(pt2)
meta:set_string("doors_owner", playername)
meta:set_string("infotext", "Owned by "..playername)
minetest.chat_send_player(clicker:get_player_name(), "Essa comeia nao pertece a voce!")
minetest.sound_play("sfx_falha", {object = clicker, gain = 2.0, max_hear_distance = 10})
]]--
end
end
function lunotrades.doOpenDoor(pos, dir, replace, replace_dir, params)
local p2 = minetest.get_node(pos).param2
p2 = params[p2+1]
local meta = minetest.get_meta(pos):to_table()
minetest.set_node(pos, {name=replace_dir, param2=p2})
minetest.get_meta(pos):from_table(meta)
pos.y = pos.y-dir
meta = minetest.get_meta(pos):to_table()
minetest.set_node(pos, {name=replace, param2=p2})
minetest.get_meta(pos):from_table(meta)
end
function lunotrades.on_rightclick(pos, dir, check_name, replace, replace_dir, params)
pos.y = pos.y+dir
if not minetest.get_node(pos).name == check_name then
return
end
lunotrades.doOpenDoor(pos, dir, replace, replace_dir, params)
end
doors.register_door("lunotrades:rent_door", {
description = "Porta de Aluguel (Aux+RightClick para Alugar)",
inventory_image = "rent_door_inv.png",
--groups = {snappy=1,bendy=2,cracky=1,melty=2,level=2,door=1},
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,door=1},
tiles_bottom = {"rent_door_b.png", "rent_door_side.png"},
tiles_top = {"rent_door_a.png", "rent_door_side.png"},
sounds = default.node_sound_wood_defaults(),
sound_open_door = "sfx_door_open",
sound_close_door = "sfx_door_close",
sunlight = false,
})
local instancias = {"lunotrades:rent_door_b_1", "lunotrades:rent_door_t_1", "lunotrades:rent_door_b_2", "lunotrades:rent_door_t_2"}
for _,ItemID in ipairs(instancias) do
print("rent_door.ItemID="..ItemID)
if minetest.registered_items[ItemID] ~= nil then
local props = minetest.registered_items[ItemID]
--[[
props.allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local playername = player:get_player_name()
local meta = minetest.env:get_meta(pos)
if player:get_player_name() ~= meta:get_string("owner") then return 0 end
return count
end,
props.allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local playername = player:get_player_name()
local meta = minetest.env:get_meta(pos)
if player:get_player_name() ~= meta:get_string("owner") then return 0 end
return stack:get_count()
end,
props.allow_metadata_inventory_take = function(pos, listname, index, stack, player)
local playername = player:get_player_name()
local meta = minetest.env:get_meta(pos)
if player:get_player_name() ~= meta:get_string("owner") then return 0 end
return stack:get_count()
end,
]]--
minetest.register_node(":"..ItemID, props)
end
end
minetest.register_craft({
output = 'lunotrades:rent_door',
recipe = {
{'default:steel_ingot','default:steel_ingot',''},
{'default:steel_ingot','lunotrades:moneybag"',''},
{'default:steel_ingot','default:steel_ingot',''}
}
})
minetest.registered_nodes['lunotrades:rent_door_b_1'].on_rightclick = function(pos, node, clicker)
if not clicker:get_player_control().aux1 then
if lunotrades.ifOpenDoor(pos, clicker) then
lunotrades.on_rightclick(pos, 1, "lunotrades:rent_door_t_1", "lunotrades:rent_door_b_2", "lunotrades:rent_door_t_2", {1,2,3,0})
end
else
lunotrades.doCTRLRightClick(pos, node, clicker)
end
end
minetest.registered_nodes['lunotrades:rent_door_t_1'].on_rightclick = function(pos, node, clicker)
if not clicker:get_player_control().aux1 then
if lunotrades.ifOpenDoor(pos, clicker) then
lunotrades.on_rightclick(pos, -1, "lunotrades:rent_door_b_1", "lunotrades:rent_door_t_2", "lunotrades:rent_door_b_2", {1,2,3,0})
end
else
lunotrades.doCTRLRightClick(pos, node, clicker)
end
end
-- Fix for duplicating Bug!
-- Bug was caused, because the reverse order of the on_rightclick was not taken into account
minetest.registered_nodes['lunotrades:rent_door_b_2'].on_rightclick = function(pos, node, clicker)
if not minetest.get_modpath("landrush") or landrush.can_interact(pos,clicker:get_player_name()) then
lunotrades.on_rightclick(pos, 1, "lunotrades:rent_door_t_2", "lunotrades:rent_door_b_1", "lunotrades:rent_door_t_1", {3,0,1,2})
end
end
minetest.registered_nodes['lunotrades:rent_door_t_2'].on_rightclick = function(pos, node, clicker)
if not minetest.get_modpath("landrush") or landrush.can_interact(pos,clicker:get_player_name()) then
lunotrades.on_rightclick(pos, -1, "lunotrades:rent_door_b_2", "lunotrades:rent_door_t_1", "lunotrades:rent_door_b_1", {3,0,1,2})
end
end

69
item_strongbox.lua Normal file
View file

@ -0,0 +1,69 @@
minetest.register_node("minertrade:strongbox", {
description = "Cofre - Guarde seu dinheiro neste cofre e retire seu dinheiro em qualquer loja que possua um Caixa Eletrônico",
--inventory_image = "safe_front.png",
paramtype = "light",
paramtype2 = "facedir",
tiles = {
"safe_side.png",
"safe_side.png",
"safe_side.png",
"safe_side.png",
"safe_side.png",
"safe_front.png",
},
is_ground_content = false,
groups = {cracky=1},
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name() or "")
meta:set_string("infotext", "Cofre (Propriedade de "..meta:get_string("owner")..") - Guarde seu dinheiro neste cofre e retire seu dinheiro em qualquer loja que possua um Caixa Eletrônico.")
local now = os.time() --Em milisegundos
meta:set_string("opentime", now+modMinerTrade.delayConstruct)
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
if modMinerTrade.isOpen(meta, player) then
--local inv = meta:get_inventory()
--inv:set_list("safe", { })
--return inv:is_empty("main") and modMinerTrade.isOpen(meta, player)
return true
else
return false
end
end,
on_rightclick = function(pos, node, clicker)
local playername = clicker:get_player_name()
local meta = minetest.get_meta(pos)
local ownername = meta:get_string("owner")
if modMinerTrade.isOpen(meta, clicker) then
local opentime = tonumber(meta:get_string("opentime")) or 0
local now = os.time() --Em milisegundos
if now >= opentime or minetest.get_player_privs(playername).server then
local inv = modMinerTrade.getDetachedInventory(ownername)
minetest.show_formspec(
playername,
"safe_"..ownername,
modMinerTrade.getFormspec(ownername)
)
else
minetest.chat_send_player(playername, "[COFRE] O cofre so vai funcionar "..(opentime-now).." segundos depois de instalado!")
end
else
minetest.chat_send_player(playername, "[COFRE] Este cofre pertence a '"..ownername.."'!")
end
end,
})
minetest.register_craft({
output = 'minertrade:strongbox',
recipe = {
{"default:steel_ingot" ,"default:steel_ingot" ,"default:steel_ingot"},
{"default:steel_ingot" ,"" ,"default:mese_crystal"},
{"default:steel_ingot" ,"default:steel_ingot" ,"default:steel_ingot"},
}
})
minetest.register_alias("strongbox" ,"minertrade:strongbox")
minetest.register_alias("cofre" ,"minertrade:strongbox")
minetest.register_alias("cofreforte" ,"minertrade:strongbox")
minetest.register_alias("caixaforte" ,"minertrade:strongbox")

104
item_strongbox_old.lua Normal file
View file

@ -0,0 +1,104 @@
minetest.register_node("strongbox:safe", {
description = "Cofre (12 Espacos)",
--inventory_image = "safe_front.png",
paramtype = "light",
paramtype2 = "facedir",
tiles = {
"safe_side.png",
"safe_side.png",
"safe_side.png",
"safe_side.png",
"safe_side.png",
"safe_front.png",
},
is_ground_content = false,
groups = {cracky=1},
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name() or "")
meta:set_string("infotext", "Cofre (Propriedade de "..meta:get_string("owner")..")")
end,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("owner", "")
meta:set_string("infotext", "Cofre")
local inv = meta:get_inventory()
inv:set_size("main", 6*2)
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
return inv:is_empty("main") and strongbox.isOpen(meta, player)
end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local meta = minetest.get_meta(pos)
if not strongbox.isOpen(meta, player) then
minetest.log("action",
player:get_player_name().." tentou mover um objeto no cofre de "..meta:get_string("owner").." em "..minetest.pos_to_string(pos)
)
return 0
end
return count
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
if not strongbox.isOpen(meta, player) then
minetest.log("action", player:get_player_name()..
" tentou por um objeto no cofre de "..
meta:get_string("owner").." em "..
minetest.pos_to_string(pos))
return 0
end
return stack:get_count()
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
if not strongbox.isOpen(meta, player) then
minetest.log("action", player:get_player_name()..
" tentou pegar um objeto no cofre de "..
meta:get_string("owner").." em "..
minetest.pos_to_string(pos))
return 0
end
return stack:get_count()
end,
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
minetest.log("action", player:get_player_name()..
" moveu um item no cofre em "..minetest.pos_to_string(pos))
end,
on_metadata_inventory_put = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name()..
" colocou um item no cofre em "..minetest.pos_to_string(pos))
end,
on_metadata_inventory_take = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name()..
" removeu um item no cofre em "..minetest.pos_to_string(pos))
end,
on_rightclick = function(pos, node, clicker)
local meta = minetest.get_meta(pos)
if strongbox.isOpen(meta, clicker) then
minetest.show_formspec(
clicker:get_player_name(),
"strongbox:safe",
strongbox.getFormspec(pos)
)
end
end,
})
minetest.register_craft({
output = 'strongbox:safe',
recipe = {
{"default:steelblock" ,"default:steelblock" ,"default:steelblock"},
{"default:steelblock" ,"" ,"default:mese"},
{"default:steelblock" ,"default:steelblock" ,"default:steelblock"},
}
})
minetest.register_alias("strongbox" ,"strongbox:safe")
minetest.register_alias("safe" ,"strongbox:safe")
minetest.register_alias("safeall" ,"strongbox:safe")
minetest.register_alias("safe-all" ,"strongbox:safe")
minetest.register_alias("caixaforte" ,"strongbox:safe")
minetest.register_alias("cofreforte" ,"strongbox:safe")
minetest.register_alias("cofre" ,"strongbox:safe")

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
screenshot2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
sounds/sfx_alert.ogg Normal file

Binary file not shown.

Binary file not shown.

BIN
textures/balcao1_baixo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
textures/balcao1_lado.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

BIN
textures/balcao2_baixo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
textures/balcao2_lado.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB

BIN
textures/balcao_topo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 461 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
textures/obj_minecoin.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
textures/obj_minecoin.xcf Normal file

Binary file not shown.

BIN
textures/obj_minemoney.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
textures/obj_piggy_bank.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

BIN
textures/rent_door_a.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 B

BIN
textures/rent_door_b.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

BIN
textures/rent_door_inv.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

BIN
textures/rent_door_side.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 B

BIN
textures/safe_front.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

BIN
textures/safe_side.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB