telepro/balao.lua

75 lines
1.6 KiB
Lua
Raw Permalink Normal View History

2017-06-18 08:06:25 -07:00
--[[
Mod Telepro 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/>.
Balao
]]
2018-07-12 21:13:10 -07:00
local S = telepro.S
2017-06-18 08:06:25 -07:00
-- Pegar node distante nao carregado
local function pegar_node(pos)
local node = minetest.get_node(pos)
if node.name == "ignore" then
minetest.get_voxel_manip():read_from_map(pos, pos)
node = minetest.get_node(pos)
end
return node
end
2018-07-11 14:46:22 -07:00
-- Node
minetest.register_node("telepro:balao_jogador", {
2018-07-12 21:13:10 -07:00
description = S("Balao Decorativo"),
2018-07-11 14:46:22 -07:00
tiles = {"telepro_balao.png"},
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
drawtype = "mesh",
mesh = "telepro_node_balao.b3d",
visual_scale = 0.45,
2018-07-11 15:04:52 -07:00
groups = {choppy = 2, oddly_breakable_by_hand = 2, not_in_creative_inventory = 1},
2018-07-11 14:46:22 -07:00
sounds = default.node_sound_wood_defaults(),
drop = "",
})
2017-06-18 08:06:25 -07:00
2018-07-11 14:46:22 -07:00
-- Verifica se tem bau ativo
minetest.register_abm{
nodenames = {"telepro:balao_jogador"},
2018-07-13 13:56:07 -07:00
interval = telepro.var.tempo_verificar_balao,
2018-07-11 14:46:22 -07:00
chance = 1,
action = function(pos)
2017-06-18 08:06:25 -07:00
2018-07-11 14:46:22 -07:00
-- Pos bau
local pos_bau = {x=pos.x, y=pos.y-25, z=pos.z}
-- Bau
local node = pegar_node(pos_bau)
-- Verifica se tem bau
if node.name ~= "telepro:bau" then
minetest.remove_node(pos)
2017-06-18 08:06:25 -07:00
return
end
2018-07-11 14:46:22 -07:00
-- Pegar metadados do bau
local meta = minetest.get_meta(pos_bau)
-- Verifica se o bau tem dono
if meta:get_string("dono") == "" then
minetest.remove_node(pos)
return
2017-06-18 08:06:25 -07:00
end
2018-07-11 14:46:22 -07:00
-- Verifica se o bau ta ativo
if meta:get_string("status") ~= "ativo" then
minetest.remove_node(pos)
return
end
2017-06-18 08:06:25 -07:00
end,
2018-07-11 14:46:22 -07:00
}