Remodelação geral
parent
5d3b190ad8
commit
31ee876e15
2
API.txt
2
API.txt
|
@ -15,7 +15,7 @@ definir um comportamento para ele)
|
|||
|
||||
|
||||
=================> Estrutura das tavernas <=================
|
||||
Devem ter exatos 12 blocos de cada lado e altura de 15
|
||||
Devem ter exatos 13 blocos de cada lado e altura de 15
|
||||
blocos.
|
||||
Deve conter o carpete especifico para tavernas
|
||||
(itemstring: taverna_barbara:carpete)
|
||||
|
|
78
barman.lua
78
barman.lua
|
@ -12,6 +12,10 @@
|
|||
o NPC barman que atende os jogadores na taverna barbara
|
||||
]]
|
||||
|
||||
-- Encurtamento de variaveis uteis
|
||||
local item_moeda = taverna_barbara.item_moeda
|
||||
local desc_item_moeda = taverna_barbara.desc_item_moeda
|
||||
|
||||
local def = {
|
||||
|
||||
-- Geral
|
||||
|
@ -58,9 +62,9 @@ local def = {
|
|||
minetest.show_formspec(clicker:get_player_name(), "taverna_barbara:barman",
|
||||
"size[9,4]"
|
||||
.."label[0,0;BARMAN]"
|
||||
.."label[0,0.5;3 macros]"
|
||||
.."label[3,0.5;4 macros]"
|
||||
.."label[6,0.5;2 macros]"
|
||||
.."label[0,0.5;"..taverna_barbara.custo_cerveja.." "..taverna_barbara.item_moeda_code.."]"
|
||||
.."label[3,0.5;"..taverna_barbara.custo_whisky.." "..taverna_barbara.item_moeda_code.."]"
|
||||
.."label[6,0.5;"..taverna_barbara.custo_batanoura_defumada.." "..taverna_barbara.item_moeda_code.."]"
|
||||
.."item_image_button[0,1;3,3;taverna_barbara:cerveja;cerveja;]"
|
||||
.."item_image_button[3,1;3,3;taverna_barbara:whisky;whisky;]"
|
||||
.."item_image_button[6,1;3,3;taverna_barbara:batanoura_defumada;batanoura_defumada;]"
|
||||
|
@ -100,58 +104,42 @@ creatures.register_mob(def)
|
|||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname == "taverna_barbara:barman" then
|
||||
if fields.cerveja then
|
||||
local sender_name = player:get_player_name()
|
||||
local sender_inv = player:get_inventory()
|
||||
if not sender_inv:contains_item("main", "macromoney:macro 3") then
|
||||
minetest.chat_send_player(sender_name, "Voce precisa de macros para comprar Cerveja")
|
||||
return
|
||||
elseif not sender_inv:room_for_item("main", "taverna_barbara:cerveja 1") then
|
||||
minetest.chat_send_player(sender_name, "Inventario Lotado")
|
||||
|
||||
local custo = taverna_barbara.custo_cerveja
|
||||
|
||||
if taverna_barbara.tror.trocar_plus(player, {taverna_barbara.item_moeda.." "..custo}, {"taverna_barbara:cerveja 1"}) == false then
|
||||
local desc_item = minetest.registered_items["taverna_barbara:cerveja"].description
|
||||
local desc_moeda = taverna_barbara.desc_item_moeda
|
||||
minetest.chat_send_player(
|
||||
player:get_player_name(),
|
||||
"Voce precisa de "..tostring(custo).." "..desc_moeda.." para comprar "..desc_item)
|
||||
return
|
||||
end
|
||||
-- retirando itens do inventario
|
||||
local i = 0
|
||||
while i < tonumber(3) do -- 1 eh o tanto que quero tirar
|
||||
sender_inv:remove_item("main", "macromoney:macro 1") -- tira 1 por vez
|
||||
i = i + 1
|
||||
end
|
||||
sender_inv:add_item("main", "taverna_barbara:cerveja 1")
|
||||
|
||||
elseif fields.whisky then
|
||||
local sender_name = player:get_player_name()
|
||||
local sender_inv = player:get_inventory()
|
||||
if not sender_inv:contains_item("main", "macromoney:macro 4") then
|
||||
minetest.chat_send_player(sender_name, "Voce precisa de macros para comprar Whisky")
|
||||
return
|
||||
elseif not sender_inv:room_for_item("main", "taverna_barbara:whisky 1") then
|
||||
minetest.chat_send_player(sender_name, "Inventario Lotado")
|
||||
|
||||
local custo = taverna_barbara.custo_whisky
|
||||
|
||||
if taverna_barbara.tror.trocar_plus(player, {item_moeda.." "..custo}, {"taverna_barbara:whisky 1"}) == false then
|
||||
local desc_item = minetest.registered_items["taverna_barbara:whisky"].description
|
||||
minetest.chat_send_player(
|
||||
player:get_player_name(),
|
||||
"Voce precisa de "..tostring(custo).." "..desc_item_moeda.." para comprar "..desc_item)
|
||||
return
|
||||
end
|
||||
-- retirando itens do inventario
|
||||
local i = 0
|
||||
while i < tonumber(4) do -- 1 eh o tanto que quero tirar
|
||||
sender_inv:remove_item("main", "macromoney:macro 1") -- tira 1 por vez
|
||||
i = i + 1
|
||||
end
|
||||
sender_inv:add_item("main", "taverna_barbara:whisky 1")
|
||||
|
||||
elseif fields.batanoura_defumada then
|
||||
local sender_name = player:get_player_name()
|
||||
local sender_inv = player:get_inventory()
|
||||
if not sender_inv:contains_item("main", "macromoney:macro 2") then
|
||||
minetest.chat_send_player(sender_name, "Voce precisa de macros para comprar Batanoura Defumada")
|
||||
return
|
||||
elseif not sender_inv:room_for_item("main", "taverna_barbara:batanoura_defumada 1") then
|
||||
minetest.chat_send_player(sender_name, "Inventario Lotado")
|
||||
|
||||
local custo = taverna_barbara.custo_batanoura_defumada
|
||||
|
||||
if taverna_barbara.tror.trocar_plus(player, {item_moeda.." "..custo}, {"taverna_barbara:batanoura_defumada 1"}) == false then
|
||||
local desc_item = minetest.registered_items["taverna_barbara:batanoura_defumada"].description
|
||||
minetest.chat_send_player(
|
||||
player:get_player_name(),
|
||||
"Voce precisa de "..tostring(custo).." "..desc_item_moeda.." para comprar "..desc_item)
|
||||
return
|
||||
end
|
||||
-- retirando itens do inventario
|
||||
local i = 0
|
||||
while i < tonumber(2) do -- 1 eh o tanto que quero tirar
|
||||
sender_inv:remove_item("main", "macromoney:macro 1") -- tira 1 por vez
|
||||
i = i + 1
|
||||
end
|
||||
sender_inv:add_item("main", "taverna_barbara:batanoura_defumada 1")
|
||||
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
|
|
@ -15,7 +15,7 @@ minetest.register_craftitem("taverna_barbara:cerveja", {
|
|||
description = "Cerveja",
|
||||
inventory_image = "taverna_barbara_cerveja.png",
|
||||
stack_max = 1,
|
||||
on_use = core.item_eat(4),
|
||||
on_use = core.item_eat(taverna_barbara.saciamento_cerveja),
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if minetest.is_protected(pointed_thing.above, placer:get_player_name()) == false then
|
||||
minetest.set_node(pointed_thing.above, {name="taverna_barbara:node_cerveja"})
|
||||
|
@ -26,7 +26,7 @@ minetest.register_craftitem("taverna_barbara:cerveja", {
|
|||
end,
|
||||
})
|
||||
if hbhunger then
|
||||
hbhunger.register_food("taverna_barbara:cerveja", 4, "macronodes:garrafa_vidro", nil, 2, "taverna_barbara_bebendo_garrafa_de_vidro")
|
||||
hbhunger.register_food("taverna_barbara:cerveja", taverna_barbara.saciamento_cerveja, "macronodes:garrafa_vidro", nil, 2, "taverna_barbara_bebendo_garrafa_de_vidro")
|
||||
end
|
||||
|
||||
-- Whisky
|
||||
|
@ -34,7 +34,7 @@ minetest.register_craftitem("taverna_barbara:whisky", {
|
|||
description = "Whisky",
|
||||
inventory_image = "taverna_barbara_whisky.png",
|
||||
stack_max = 1,
|
||||
on_use = core.item_eat(5),
|
||||
on_use = core.item_eat(taverna_barbara.saciamento_whisky),
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if minetest.is_protected(pointed_thing.above, placer:get_player_name()) == false then
|
||||
minetest.set_node(pointed_thing.above, {name="taverna_barbara:node_whisky"})
|
||||
|
@ -45,7 +45,7 @@ minetest.register_craftitem("taverna_barbara:whisky", {
|
|||
end,
|
||||
})
|
||||
if hbhunger then
|
||||
hbhunger.register_food("taverna_barbara:whisky", 5, "macronodes:garrafa_vidro", nil, 4, "taverna_barbara_bebendo_garrafa_de_vidro")
|
||||
hbhunger.register_food("taverna_barbara:whisky", taverna_barbara.saciamento_whisky, "macronodes:garrafa_vidro", nil, 4, "taverna_barbara_bebendo_garrafa_de_vidro")
|
||||
end
|
||||
|
||||
-- Amendoim Crocante
|
||||
|
@ -53,10 +53,10 @@ minetest.register_craftitem("taverna_barbara:amendoim", {
|
|||
description = "Amendoim Crocante",
|
||||
inventory_image = "taverna_barbara_amendoim.png",
|
||||
stack_max = 20,
|
||||
on_use = core.item_eat(2),
|
||||
on_use = core.item_eat(taverna_barbara.saciamento_amendoim),
|
||||
})
|
||||
if hbhunger then
|
||||
hbhunger.register_food("taverna_barbara:amendoim", 20, nil, nil, nil, "taverna_barbara_comendo_amendoim")
|
||||
hbhunger.register_food("taverna_barbara:amendoim", taverna_barbara.saciamento_amendoim, nil, nil, nil, "taverna_barbara_comendo_amendoim")
|
||||
end
|
||||
|
||||
-- Balinha Sortida
|
||||
|
@ -65,10 +65,10 @@ minetest.register_craftitem("taverna_barbara:balinha_sortida", {
|
|||
inventory_image = "taverna_barbara_balinha_sortida_inv.png",
|
||||
wield_image = "taverna_barbara_balinha_sortida.png",
|
||||
stack_max = 20,
|
||||
on_use = core.item_eat(0)
|
||||
on_use = core.item_eat(taverna_barbara.saciamento_balinha_sortida)
|
||||
})
|
||||
if hbhunger then
|
||||
hbhunger.register_food("taverna_barbara:balinha_sortida", 0, nil, nil, nil, "taverna_barbara_balinha_sortida")
|
||||
hbhunger.register_food("taverna_barbara:balinha_sortida", taverna_barbara.saciamento_balinha_sortida, nil, nil, nil, "taverna_barbara_balinha_sortida")
|
||||
end
|
||||
|
||||
-- Batanoura Defumada (Cruzamento de Batata com Cenoura)
|
||||
|
@ -76,8 +76,8 @@ minetest.register_craftitem("taverna_barbara:batanoura_defumada", {
|
|||
description = "Batanoura Defumada (Cruzamento de Batata com Cenoura)",
|
||||
inventory_image = "taverna_barbara_batanoura_defumada.png",
|
||||
stack_max = 10,
|
||||
on_use = core.item_eat(4)
|
||||
on_use = core.item_eat(taverna_barbara.saciamento_batanoura_defumada)
|
||||
})
|
||||
if hbhunger then
|
||||
hbhunger.register_food("taverna_barbara:batanoura_defumada", 4)
|
||||
hbhunger.register_food("taverna_barbara:batanoura_defumada", taverna_barbara.saciamento_batanoura_defumada)
|
||||
end
|
||||
|
|
|
@ -2,6 +2,5 @@ default
|
|||
hbhunger?
|
||||
creatures
|
||||
vessels
|
||||
macromoney
|
||||
areas?
|
||||
areas
|
||||
wool
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--[[
|
||||
Mod Taverna_Barbara para Minetest
|
||||
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
|
||||
Copyright (C) 2018 BrunoMine (https://github.com/BrunoMine)
|
||||
|
||||
Recebeste uma cópia da GNU Lesser General
|
||||
Public License junto com esse software,
|
||||
|
@ -17,18 +17,36 @@
|
|||
|
||||
-- Raridade de tavernas bárbaras no mapa
|
||||
--[[
|
||||
Ao menos 1 ofeta deve estar disponivel nessa lista/tabela
|
||||
* Apenas numeros inteiros
|
||||
* Raridade de 1 em N (valor definidos)
|
||||
* Quanto maior, mais raro
|
||||
* Valor mínimo é 1
|
||||
Porcentagem de probabilidade de gerar uma taverna barbara quando possivel
|
||||
0% não gera
|
||||
100% gera sempre que possivel
|
||||
]]
|
||||
local RARIDADE = 15 -- recomendado 15
|
||||
local PROBABILIDADE_GERAR_TAVERNA = tonumber(minetest.settings:get("taverna_barbara_probabilidade_gerar_taverna") or 7)
|
||||
|
||||
|
||||
-- Tempo para um trambiqueiro oferecer outra troca (em segundos)
|
||||
local TEMPO_PARA_NOVO_TRAMBIQUE = 600 -- 10 minutos
|
||||
|
||||
-- Quantidade de arquivos de tavernas
|
||||
local QUANTIDADE_TAVERNAS = 1
|
||||
|
||||
-- Item de troca
|
||||
local ITEM_MOEDA = minetest.settings:get("taverna_barbara_moeda") or "default:apple"
|
||||
local ITEM_MOEDA_CODE = minetest.settings:get("taverna_barbara_moeda_code") or ""
|
||||
|
||||
-- Custos no barman
|
||||
local CUSTO_CERVEJA = tonumber(minetest.settings:get("taverna_barbara_custo_cerveja") or 3)
|
||||
local CUSTO_WHISKY = tonumber(minetest.settings:get("taverna_barbara_custo_whisky") or 4)
|
||||
local CUSTO_BATANOURA_DEFUMADA = tonumber(minetest.settings:get("taverna_barbara_custo_batanoura_defumada") or 2)
|
||||
local CUSTO_AMENDOIM = tonumber(minetest.settings:get("taverna_barbara_custo_amendoim") or 1)
|
||||
local CUSTO_BALINHA_SORTIDA = tonumber(minetest.settings:get("taverna_barbara_custo_balinha_sortida") or 1)
|
||||
|
||||
-- Saciamento de alimentos
|
||||
local SACIAMENTO_CERVEJA = tonumber(minetest.settings:get("taverna_barbara_saciamento_cerveja") or 4)
|
||||
local SACIAMENTO_WHISKY = tonumber(minetest.settings:get("taverna_barbara_saciamento_whisky") or 5)
|
||||
local SACIAMENTO_BATANOURA_DEFUMADA = tonumber(minetest.settings:get("taverna_barbara_saciamento_batanoura_defumada") or 4)
|
||||
local SACIAMENTO_AMENDOIM = tonumber(minetest.settings:get("taverna_barbara_saciamento_amendoim") or 1)
|
||||
local SACIAMENTO_BALINHA_SORTIDA = tonumber(minetest.settings:get("taverna_barbara_saciamento_balinha_sortida") or 0)
|
||||
|
||||
-- Trocas oferecidas pelos trambiqueiros
|
||||
--[[
|
||||
|
@ -40,25 +58,11 @@ local TEMPO_PARA_NOVO_TRAMBIQUE = 600 -- 10 minutos
|
|||
local OFERTAS_TRAMBIQUEIRO = {
|
||||
-- exemplo
|
||||
-- {custo = "currency:macro 1", item = "default:paper 3"},
|
||||
{custo = "macromoney:macro 5", item = "default:mese_crystal 1"},
|
||||
{custo = "macromoney:macro 2", item = "esqueiro:esqueiro 1"},
|
||||
{custo = "macromoney:macro 10", item = "oficios_pacotes_estruturais:cabana_simples 1"},
|
||||
{custo = "macromoney:macro 5", item = "shields:shield_enhanced_wood 1"},
|
||||
{custo = "macromoney:macro 15", item = "default:pick_diamond 1"},
|
||||
{custo = ITEM_MOEDA.." 12", item = "default:mese_crystal 1"},
|
||||
{custo = ITEM_MOEDA.." 5", item = "shields:shield_enhanced_wood 1"},
|
||||
{custo = ITEM_MOEDA.." 15", item = "default:pick_diamond 1"},
|
||||
}
|
||||
|
||||
|
||||
|
||||
-- Quantidade de arquivos de tavernas
|
||||
local QUANTIDADE_TAVERNAS = 2
|
||||
|
||||
|
||||
|
||||
-- Gerenciador das areas protegidas das tavernas
|
||||
local GERENTE_AREAS = "BrunoMine"
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Ajuste de dados
|
||||
--
|
||||
|
@ -66,6 +70,19 @@ taverna_barbara.trambiqueiro = {
|
|||
ofertas = OFERTAS_TRAMBIQUEIRO,
|
||||
tempo_restauro_trambique = TEMPO_PARA_NOVO_TRAMBIQUE
|
||||
}
|
||||
taverna_barbara.raridade = RARIDADE
|
||||
taverna_barbara.probabilidade_gen = PROBABILIDADE_GERAR_TAVERNA
|
||||
taverna_barbara.qtd_arquivos = QUANTIDADE_TAVERNAS
|
||||
taverna_barbara.gerente_areas = GERENTE_AREAS
|
||||
taverna_barbara.item_moeda = ITEM_MOEDA
|
||||
taverna_barbara.desc_item_moeda = minetest.registered_items[ITEM_MOEDA].description
|
||||
taverna_barbara.item_moeda_code = ITEM_MOEDA_CODE
|
||||
taverna_barbara.custo_cerveja = CUSTO_CERVEJA
|
||||
taverna_barbara.custo_whisky = CUSTO_WHISKY
|
||||
taverna_barbara.custo_batanoura_defumada = CUSTO_BATANOURA_DEFUMADA
|
||||
taverna_barbara.custo_amendoim = CUSTO_AMENDOIM
|
||||
taverna_barbara.custo_balinha_sortida = CUSTO_BOLINHA_SORTIDA
|
||||
taverna_barbara.saciamento_cerveja = SACIAMENTO_CERVEJA
|
||||
taverna_barbara.saciamento_whisky = SACIAMENTO_WHISKY
|
||||
taverna_barbara.saciamento_batanoura_defumada = SACIAMENTO_BATANOURA_DEFUMADA
|
||||
taverna_barbara.saciamento_amendoim = SACIAMENTO_AMENDOIM
|
||||
taverna_barbara.saciamento_balinha_sortida = SACIAMENTO_BALINHA_SORTIDA
|
||||
|
|
Binary file not shown.
6
init.lua
6
init.lua
|
@ -22,9 +22,15 @@ local modpath = minetest.get_modpath("taverna_barbara")
|
|||
-- Variavel global
|
||||
taverna_barbara = {}
|
||||
|
||||
-- Versao
|
||||
taverna_barbara.versao = "1"
|
||||
|
||||
-- Plagen
|
||||
taverna_barbara.plagen = dofile(modpath.."/lib/plagen.lua")
|
||||
|
||||
-- Tror
|
||||
taverna_barbara.tror = dofile(modpath.."/lib/tror.lua")
|
||||
|
||||
dofile(modpath.."/tradutor.lua")
|
||||
|
||||
-- Carregar scripts
|
||||
|
|
|
@ -0,0 +1,148 @@
|
|||
--[[
|
||||
Lib Tror para Minetest
|
||||
Copyright (C) 2017 BrunoMine (https://github.com/BrunoMine)
|
||||
|
||||
Recebeste uma cópia da GNU Lesser General
|
||||
Public License junto com esse software,
|
||||
se não, veja em <http://www.gnu.org/licenses/>.
|
||||
|
||||
Operações de troca de itens
|
||||
]]
|
||||
|
||||
local tror = {}
|
||||
|
||||
-- Verificar viabilidade de uma troca
|
||||
tror.verificar = function(player, item_rem, item_add)
|
||||
|
||||
if not player or not item_add or not item_rem then
|
||||
minetest.log("error", "[Tror] Faltou dados em (em tror.verificar)")
|
||||
return false
|
||||
end
|
||||
|
||||
local inv = player:get_inventory()
|
||||
|
||||
-- Verificar jogador
|
||||
if not inv:contains_item("main", item_rem) then
|
||||
return 1 -- Jogador nao pode pagar
|
||||
elseif not inv:room_for_item("main", item_add) then
|
||||
return 2 -- Jogador com inventario lotado
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
-- Realizar uma troca entre com um jogador
|
||||
tror.trocar = function(player, item_rem, item_add, msg)
|
||||
|
||||
if not player or not item_add or not item_rem then
|
||||
minetest.log("error", "[Tror] Faltou dados em (em tror.trocar)")
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
local v = tror.verificar(player, item_rem, item_add)
|
||||
if v ~= true then
|
||||
if v == 1 then
|
||||
if msg and msg.ins then
|
||||
minetest.chat_send_player(player:get_player_name(), msg.ins)
|
||||
end
|
||||
return 1
|
||||
elseif v == 2 then
|
||||
if msg and msg.lot then
|
||||
minetest.chat_send_player(player:get_player_name(), msg.lot)
|
||||
end
|
||||
return 2
|
||||
else
|
||||
minetest.log("error", "[Tror] Resultado inesperado em tror.trocar (v = "..dump(v)..")")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
local inv = player:get_inventory()
|
||||
|
||||
-- Retirar itens do inventario
|
||||
local i = string.split(item_rem, " ")
|
||||
local n = i[2] or 1
|
||||
i = i[1]
|
||||
for r=1, tonumber(n) do -- 1 eh o tanto que quero tirar
|
||||
inv:remove_item("main", i) -- tira 1 por vez
|
||||
end
|
||||
|
||||
inv:add_item("main", item_add)
|
||||
|
||||
|
||||
if msg and msg.ok then
|
||||
minetest.chat_send_player(player:get_player_name(), msg.ok)
|
||||
end
|
||||
return true
|
||||
|
||||
end
|
||||
|
||||
-- Realizar uma troca com um jogador
|
||||
--[[
|
||||
Retorna false caso o jogador nao tenha os itens requisitados
|
||||
e dropa no local todos os itens que não couberem no inventario
|
||||
]]
|
||||
tror.trocar_plus = function(player, item_rem, item_add)
|
||||
|
||||
if not player then
|
||||
minetest.log("error", "[Tror] Faltou player (em tror.trocar_plus)")
|
||||
return false
|
||||
end
|
||||
|
||||
if item_rem and not item_rem[1] then
|
||||
minetest.log("error", "[Tror] argumento item_rem invalido (em tror.trocar_plus)")
|
||||
return false
|
||||
end
|
||||
|
||||
if item_add and not item_add[1] then
|
||||
minetest.log("error", "[Tror] argumento item_add invalido (em tror.trocar_plus)")
|
||||
return false
|
||||
end
|
||||
|
||||
local pos = player:getpos()
|
||||
|
||||
local inv = player:get_inventory()
|
||||
|
||||
-- Verificar se o jogador possui os itens requisitados
|
||||
local possui = true
|
||||
for _,item in ipairs(item_rem) do
|
||||
if not inv:contains_item("main", item) then
|
||||
possui = false
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- Retorna false por jogador não ter os itens requisitados
|
||||
if possui == false then
|
||||
return false
|
||||
end
|
||||
|
||||
-- Retira itens do jogador
|
||||
for _,item in ipairs(item_rem) do
|
||||
local i = string.split(item, " ")
|
||||
local n = i[2] or 1
|
||||
i = i[1]
|
||||
for r=1, tonumber(n) do -- 1 eh o tanto que quero tirar
|
||||
inv:remove_item("main", i) -- tira 1 por vez
|
||||
end
|
||||
end
|
||||
|
||||
-- Transfere todos os itens ao jogador (e dropa os que nao couberem no inventario)
|
||||
local dropou = false
|
||||
if item_add ~= nil then
|
||||
for _,item in ipairs(item_add) do
|
||||
if inv:room_for_item("main", item) then
|
||||
inv:add_item("main", item)
|
||||
else
|
||||
dropou = true
|
||||
minetest.env:add_item({x = pos.x + math.random() * 2 - 1, y = pos.y+1, z = pos.z + math.random() * 2 - 1}, item)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
|
||||
end
|
||||
|
||||
return tror
|
16
mapgen.lua
16
mapgen.lua
|
@ -75,7 +75,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
if pos_ref == nil then return end
|
||||
|
||||
-- Sortear (apenas diminui a ocorrencia antes dos cálculos)
|
||||
if math.random(1, taverna_barbara.raridade) ~= 1 then return end
|
||||
if math.random(1, 100) > taverna_barbara.probabilidade_gen then return end
|
||||
|
||||
|
||||
--[[
|
||||
|
@ -324,7 +324,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
end
|
||||
|
||||
-- Planificar area
|
||||
if taverna_barbara.plagen.planificar(pos, "quadrada", 14, 40, {solo=node.name, subsolo="default:dirt", rocha="default:stone"}, 6, true, true) == false then
|
||||
if taverna_barbara.plagen.planificar(pos, "quadrada", 13, 40, {solo=node.name, subsolo="default:dirt", rocha="default:stone"}, 6, true, true) == false then
|
||||
return false
|
||||
end
|
||||
|
||||
|
@ -332,8 +332,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
|
||||
-- Proteger area
|
||||
taverna_barbara.proteger_area(
|
||||
taverna_barbara.gerente_areas,
|
||||
taverna_barbara.gerente_areas,
|
||||
"Taverna_Barbara:Taverna",
|
||||
"Taverna Barbara",
|
||||
{x=pos.x-20, y=pos.y-15, z=pos.z-20},
|
||||
{x=pos.x+20, y=pos.y+2000, z=pos.z+20},
|
||||
|
@ -343,8 +342,13 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||
-- Montar taverna
|
||||
local numero_arquivo = math.random(1, taverna_barbara.qtd_arquivos)
|
||||
minetest.place_schematic({x=pos.x-6,y=pos.y,z=pos.z-6}, modpath.."/estruturas/taverna_barbara_"..numero_arquivo..".mts", nil, nil, true)
|
||||
|
||||
|
||||
|
||||
-- Fundamento
|
||||
minetest.set_node(pos, {name="taverna_barbara:fundamento"})
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("versao", taverna_barbara.versao)
|
||||
meta:set_string("numero_schem", numero_arquivo)
|
||||
|
||||
return true
|
||||
|
||||
end)
|
||||
|
|
61
nodes.lua
61
nodes.lua
|
@ -146,41 +146,29 @@ minetest.register_node("taverna_barbara:expositor_balinhas", {
|
|||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname == "taverna_barbara:expositor_balinhas" then
|
||||
if fields.comprar then
|
||||
local sender_name = player:get_player_name()
|
||||
local sender_inv = player:get_inventory()
|
||||
if not sender_inv:contains_item("main", "currency:macro 1") then
|
||||
minetest.chat_send_player(sender_name, "Voce precisa de macros para comprar Balinha Sortida")
|
||||
return
|
||||
elseif not sender_inv:room_for_item("main", "taverna_barbara:balinha_sortida 1") then
|
||||
minetest.chat_send_player(sender_name, "Inventario Lotado")
|
||||
|
||||
local custo = taverna_barbara.custo_balinha_sortida
|
||||
|
||||
if taverna_barbara.tror.trocar_plus(player, {item_moeda.." "..custo}, {"taverna_barbara:balinha_sortida 1"}) == false then
|
||||
local desc_item = minetest.registered_items["taverna_barbara:balinha_sortida"].description
|
||||
minetest.chat_send_player(
|
||||
player:get_player_name(),
|
||||
"Voce precisa de "..tostring(custo).." "..desc_item_moeda.." para comprar "..desc_item)
|
||||
return
|
||||
end
|
||||
-- retirando itens do inventario
|
||||
local i = 0
|
||||
while i < tonumber(1) do -- 1 eh o tanto que quero tirar
|
||||
sender_inv:remove_item("main", "currency:macro 1") -- tira 1
|
||||
i = i + 1
|
||||
end
|
||||
sender_inv:add_item("main", "taverna_barbara:balinha_sortida 1")
|
||||
end
|
||||
elseif formname == "taverna_barbara:expositor_amendoim" then
|
||||
if fields.comprar then
|
||||
local sender_name = player:get_player_name()
|
||||
local sender_inv = player:get_inventory()
|
||||
if not sender_inv:contains_item("main", "currency:macro 1") then
|
||||
minetest.chat_send_player(sender_name, "Voce precisa de macros para comprar Amendoim Crocante")
|
||||
return
|
||||
elseif not sender_inv:room_for_item("main", "taverna_barbara:amendoim 1") then
|
||||
minetest.chat_send_player(sender_name, "Inventario Lotado")
|
||||
|
||||
local custo = taverna_barbara.custo_amendoim
|
||||
|
||||
if taverna_barbara.tror.trocar_plus(player, {item_moeda.." "..custo}, {"taverna_barbara:amendoim 1"}) == false then
|
||||
local desc_item = minetest.registered_items["taverna_barbara:amendoim"].description
|
||||
minetest.chat_send_player(
|
||||
player:get_player_name(),
|
||||
"Voce precisa de "..tostring(custo).." "..desc_item_moeda.." para comprar "..desc_item)
|
||||
return
|
||||
end
|
||||
-- retirando itens do inventario
|
||||
local i = 0
|
||||
while i < tonumber(1) do -- 1 eh o tanto que quero tirar
|
||||
sender_inv:remove_item("main", "currency:macro 1") -- tira 1
|
||||
i = i + 1
|
||||
end
|
||||
sender_inv:add_item("main", "taverna_barbara:amendoim 1")
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
@ -238,3 +226,20 @@ minetest.register_node("taverna_barbara:node_whisky", {
|
|||
sounds = default.node_sound_defaults(),
|
||||
})
|
||||
|
||||
-- Fundamento da taverna
|
||||
minetest.register_node("taverna_barbara:fundamento", {
|
||||
description = "Fundamento da Taverna",
|
||||
tiles = {"default_cobble.png"},
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 1,not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = {},
|
||||
|
||||
-- Nao pode ser escavado/quebrado por jogadores
|
||||
on_dig = function() end,
|
||||
|
||||
-- Impede explosão
|
||||
on_blast = function() end,
|
||||
})
|
||||
|
||||
|
|
35
protetor.lua
35
protetor.lua
|
@ -11,39 +11,10 @@
|
|||
]]
|
||||
|
||||
-- Proteger uma area
|
||||
taverna_barbara.proteger_area = function(name, PlayerName, AreaName, pos1, pos2, silencio)
|
||||
if not tostring(PlayerName) or not tostring(AreaName) then return "Faltam argumentos ou estao incorretos" end
|
||||
if not areas or not areas.add then return "Faltou mod areas" end
|
||||
local param = tostring(PlayerName).." "..tostring(AreaName)
|
||||
local found, _, ownername, areaname = param:find('^([^ ]+) (.+)$')
|
||||
|
||||
if not found then
|
||||
return "Incorrect usage, see /help set_owner"
|
||||
end
|
||||
|
||||
if pos1 and pos2 then
|
||||
pos1, pos2 = areas:sortPos(pos1, pos2)
|
||||
else
|
||||
return "Você precisa selecionar a area primeiro"
|
||||
end
|
||||
|
||||
if not areas:player_exists(ownername) then
|
||||
return "O jogador \""..ownername.."\" não existe."
|
||||
end
|
||||
|
||||
minetest.log("action", name.." runs /set_owner. Owner = "..ownername..
|
||||
" AreaName = "..areaname..
|
||||
" StartPos = "..minetest.pos_to_string(pos1)..
|
||||
" EndPos = " ..minetest.pos_to_string(pos2))
|
||||
|
||||
local id = areas:add(ownername, areaname, pos1, pos2, nil)
|
||||
taverna_barbara.proteger_area = function(PlayerName, AreaName, pos1, pos2, silencio)
|
||||
|
||||
local id = areas:add(PlayerName, AreaName, pos1, pos2, nil)
|
||||
areas:save()
|
||||
|
||||
if silencio == nil or silencio == false then
|
||||
minetest.chat_send_player(ownername,
|
||||
"Voce registrou essa area para o jogador #"..
|
||||
id..". Use /lista para ver as areas.")
|
||||
minetest.chat_send_player(name, "Area protected. ID: "..id)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
# Configurações aplicaveis para o menu gráfico
|
||||
|
||||
#
|
||||
# Outros
|
||||
#
|
||||
|
||||
# Item usado como moeda para compra de itens na taverna
|
||||
# Porcentagem de probabilidade de gerar uma taverna barbara quando possivel
|
||||
# 0 (%) não gera
|
||||
# 100 (%) gera sempre que possivel
|
||||
# Por padrão é 7
|
||||
taverna_barbara_custo_batanoura_defumada (Probabilidade de surgir vilas) int 7 0 100
|
||||
|
||||
#
|
||||
# Vendas
|
||||
#
|
||||
|
||||
# Item usado como moeda para compra de itens na taverna
|
||||
# Deve ser um itemstring
|
||||
taverna_barbara_moeda (Moeda de troca da Taverna) string default:apple
|
||||
|
||||
# Nome encurtado da moeda
|
||||
# Exemplos: Apple, Dollar, Libra, Fruta, Macro
|
||||
# Não traduzivel
|
||||
taverna_barbara_moeda_code (Nome curto da moeda) string
|
||||
|
||||
# Custo de compra de Cerveja
|
||||
# Por padrão é 3
|
||||
taverna_barbara_custo_cerveja (Custa de Cerveja) int 3 1
|
||||
|
||||
# Custo de compra de Whisky
|
||||
# Por padrão é 4
|
||||
taverna_barbara_custo_whisky (Custa de Whisky) int 4 1
|
||||
|
||||
# Custo de compra de Batanoura Defumada
|
||||
# Por padrão é 2
|
||||
taverna_barbara_custo_batanoura_defumada (Custa de Batanoura Defumada) int 2 1
|
||||
|
||||
# Custo de compra de Amendoim
|
||||
# Por padrão é 1
|
||||
taverna_barbara_custo_amendoim (Custa de Amendoim) int 1 1
|
||||
|
||||
# Custo de compra de Balinha Sortida
|
||||
# Por padrão é 1
|
||||
taverna_barbara_custo_balinha_sortida (Custa de Balinha Sortida) int 1 1
|
||||
|
||||
#
|
||||
# Saciamento
|
||||
#
|
||||
|
||||
# Quantidade de saude ou fome restaurada ou saciada pela Cerveja
|
||||
# (1 equivale a meio unidade de saude ou fome)
|
||||
# Por padrão é 4
|
||||
taverna_barbara_saciamento_cerveja (Saciamento da Cerveja) int 4 0
|
||||
|
||||
# Quantidade de saude ou fome restaurada ou saciada pelo Whisky
|
||||
# (1 equivale a meio unidade de saude ou fome)
|
||||
# Por padrão é 5
|
||||
taverna_barbara_saciamento_whisky (Saciamento da Whisky) int 5 0
|
||||
|
||||
# Quantidade de saude ou fome restaurada ou saciada pela Batanoura Defumada
|
||||
# (1 equivale a meio unidade de saude ou fome)
|
||||
# Por padrão é 4
|
||||
taverna_barbara_saciamento_batanoura_defumada (Saciamento da Batanoura Defumada) int 4 0
|
||||
|
||||
# Quantidade de saude ou fome restaurada ou saciada pelo Amendoim
|
||||
# (1 equivale a meio unidade de saude ou fome)
|
||||
# Por padrão é 1
|
||||
taverna_barbara_saciamento_amendoim (Saciamento da Amendoim) int 1 0
|
||||
|
||||
# Quantidade de saude ou fome restaurada ou saciada pela Balinha Sortida
|
||||
# (1 equivale a meio unidade de saude ou fome)
|
||||
# Por padrão é 0
|
||||
taverna_barbara_saciamento_balinha_sortida (Saciamento da Balinha Sortida) int 0 0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -69,21 +69,21 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
|
||||
local self = acesso[sender_name]
|
||||
if self.disp then
|
||||
local sender_inv = player:get_inventory()
|
||||
if not sender_inv:contains_item("main", self.trambique.custo[1].." "..self.trambique.custo[2]) then
|
||||
minetest.chat_send_player(sender_name, "Voce precisa de macros para aceitar a oferta")
|
||||
return
|
||||
elseif not sender_inv:room_for_item("main", self.trambique.item[1].." "..self.trambique.item[2]) then
|
||||
minetest.chat_send_player(sender_name, "Inventario Lotado")
|
||||
|
||||
local item_custo = self.trambique.custo[1]
|
||||
local custo = self.trambique.custo[2]
|
||||
local item_oferta = self.trambique.item[1]
|
||||
local oferta = self.trambique.item[2]
|
||||
|
||||
if taverna_barbara.tror.trocar_plus(player, {item_custo.." "..custo}, {item_oferta.." "..oferta}) == false then
|
||||
local desc_item = minetest.registered_items[item_oferta].description
|
||||
local desc_item_custo = minetest.registered_items[item_custo].description
|
||||
minetest.chat_send_player(
|
||||
player:get_player_name(),
|
||||
"Voce precisa de "..tostring(custo).." "..desc_item_custo.." para comprar "..desc_item)
|
||||
return
|
||||
end
|
||||
-- retirando itens do inventario
|
||||
local i = 0
|
||||
while i < tonumber(self.trambique.custo[2]) do -- 1 eh o tanto que quero tirar
|
||||
sender_inv:remove_item("main", self.trambique.custo[1].." 1") -- tira 1 por vez
|
||||
i = i + 1
|
||||
end
|
||||
sender_inv:add_item("main", self.trambique.item[1].." "..self.trambique.item[2])
|
||||
|
||||
minetest.show_formspec(sender_name, "taverna_barbara:trambiqueiro", formspec_dispensa)
|
||||
self.disp = false
|
||||
self.trambique = sortear_trambique()
|
||||
|
|
Loading…
Reference in New Issue