Lançamento
|
@ -0,0 +1,165 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
36
README.md
|
@ -1 +1,35 @@
|
|||
telepro
|
||||
# Telepro v1.0.0
|
||||
|
||||
[![Baixar](https://img.shields.io/badge/Baixar-v1.0.0-green.svg)](https://github.com/BrunoMine/telepro/archive/v1.0.0.zip)
|
||||
[![Projeto](https://img.shields.io/badge/Git-Projeto-green.svg)](https://github.com/BrunoMine/telepro)
|
||||
[![Licença](https://img.shields.io/badge/Licença-LGPL_v3.0-blue.svg)](https://github.com/BrunoMine/telepro/blob/master/LICENSE)
|
||||
|
||||
## Descrição
|
||||
Transporte para jogadores
|
||||
|
||||
## Recursos do projeto
|
||||
|
||||
* [Baixar](https://github.com/BrunoMine/telepro/archive/v1.0.0.zip)
|
||||
* [Projeto](https://github.com/BrunoMine/telepro)
|
||||
|
||||
## Requisitos
|
||||
|
||||
* Minetest 0.4.15 ou superior
|
||||
* Mod default
|
||||
* Mod memor (opcional)
|
||||
|
||||
## Licença
|
||||
Veja LICENSE.txt para informações detalhadas da licença LGPL 3.0
|
||||
|
||||
### Autores do código fonte
|
||||
Originalmente por BrunoMine, Bruno Borges <borgesdossantosbruno@gmail.com> (LGPL 3.0)
|
||||
|
||||
### Autores de mídias (texturas, modelos and sons)
|
||||
BrunoMine, Bruno Borges <borgesdossantosbruno@gmail.com> (CC BY-SA 3.0)
|
||||
|
||||
Zeg'9 (CC BY-SA 3.0)
|
||||
telepro_balao.png (tecidos)
|
||||
|
||||
philipbenr (WTFPL)
|
||||
telepro_balao.png (madeira)
|
||||
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
--[[
|
||||
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/>.
|
||||
|
||||
Gerar balao automaticamente
|
||||
]]
|
||||
|
||||
minetest.register_on_newplayer(function(player)
|
||||
if not player then return end
|
||||
|
||||
minetest.after(3, minetest.show_formspec, player:get_player_name(), "telepro:intro", "size[10,8]"
|
||||
..default.gui_bg
|
||||
..default.gui_bg_img
|
||||
.."image[0,0;12,4.5;telepro_intro.png]"
|
||||
|
||||
.."image[1,4;1.5,1;telepro_pt.png]"
|
||||
.."label[2.5,4;Esse Bau pode te teleportar de sua casa para \no centro e vice versa]"
|
||||
|
||||
.."image[1,5.5;1.5,1;telepro_es.png]"
|
||||
.."label[2.5,5.5;Este Bau que puede teletransportarse desde su \ncasa al centro y viceversa]"
|
||||
|
||||
.."image[1,7;1.5,1;telepro_en.png]"
|
||||
.."label[2.5,7;This Block can teleport you from your home \nto the center and vice versa]"
|
||||
)
|
||||
|
||||
telepro.gerar_balao_aleatorio(player)
|
||||
end)
|
||||
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
--[[
|
||||
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
|
||||
]]
|
||||
|
||||
-- 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
|
||||
|
||||
|
||||
-- Registro da entidade
|
||||
minetest.register_entity("telepro:balao", {
|
||||
hp_max = 1,
|
||||
physical = true,
|
||||
weight = 5,
|
||||
collisionbox = {-7,0,-7, 7,25,7},
|
||||
visual = "mesh",
|
||||
visual_size = {x=5, y=5},
|
||||
mesh = "telepro_balao.b3d",
|
||||
textures = {"telepro_balao.png"}, -- number of required textures depends on visual
|
||||
spritediv = {x=1, y=1},
|
||||
initial_sprite_basepos = {x=0, y=0},
|
||||
is_visible = true,
|
||||
makes_footstep_sound = false,
|
||||
automatic_rotate = false,
|
||||
on_step = function(self, dtime)
|
||||
self.timer = (self.timer or 0) + dtime
|
||||
|
||||
if self.timer > 4 then
|
||||
self.timer = 0
|
||||
|
||||
-- Pegar nome do jogador
|
||||
local name = self.dono
|
||||
|
||||
-- Pegar coordenada do balao
|
||||
local pos = self.object:getpos()
|
||||
|
||||
-- Pegar coordenada do bau
|
||||
local bau_pos = {x=pos.x, y=pos.y-23, z=pos.z}
|
||||
|
||||
-- Verifica se ainda tem o bau
|
||||
|
||||
if pegar_node(bau_pos).name == "telepro:bau" then
|
||||
|
||||
-- Verifica se o bau eh do dono
|
||||
|
||||
-- Pegar metadados
|
||||
local meta = minetest.get_meta(bau_pos)
|
||||
|
||||
if
|
||||
meta:get_string("dono") == name
|
||||
and meta:get_string("status") == "ativo"
|
||||
then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- Remover cordas
|
||||
do
|
||||
local y = -1
|
||||
while y <= 24 do
|
||||
if pegar_node({x=pos.x, y=pos.y-y, z=pos.z}).name == "telepro:corda_balao" then
|
||||
minetest.remove_node({x=pos.x, y=pos.y-y, z=pos.z})
|
||||
end
|
||||
y = y + 1
|
||||
end
|
||||
end
|
||||
|
||||
-- Remove o objeto pois nao encontrou o bau do dono
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
end,
|
||||
|
||||
on_activate = function(self, staticdata)
|
||||
if staticdata ~= "" then
|
||||
self.dono = minetest.serialize({dono=self.dono,name=self.name}).dono
|
||||
self.name = minetest.serialize({dono=self.dono,name=self.name}).name
|
||||
end
|
||||
end,
|
||||
|
||||
get_staticdata = function(self)
|
||||
return minetest.serialize({dono=self.dono,name=self.name})
|
||||
end,
|
||||
})
|
||||
|
||||
-- Criar um balao
|
||||
telepro.criar_balao = function(pos, bau_pos, name)
|
||||
if not pos then
|
||||
minetest.log("error", "[Telepro] pos == nil (em telepro.criar_balao)")
|
||||
return false
|
||||
end
|
||||
if not bau_pos then
|
||||
minetest.log("error", "[Telepro] bau_pos == nil (em telepro.criar_balao)")
|
||||
return false
|
||||
end
|
||||
if not name then
|
||||
minetest.log("error", "[Telepro] name == nil (em telepro.criar_balao)")
|
||||
return false
|
||||
end
|
||||
|
||||
-- Cria o objeto
|
||||
local obj = minetest.add_entity(pos, "telepro:balao")
|
||||
|
||||
-- Verifica se foi criado
|
||||
if not obj then
|
||||
minetest.log("error", "[Telepro] Falha ao cria o objeto (em telepro.criar_balao)")
|
||||
return false
|
||||
end
|
||||
|
||||
-- Cria animação no objeto
|
||||
obj:set_animation({x=1,y=40}, 5, 0)
|
||||
|
||||
-- Pega a entidade
|
||||
local ent = obj:get_luaentity()
|
||||
|
||||
-- Cria o temporizador
|
||||
ent.timer = 0
|
||||
|
||||
-- Salva o nome do dono
|
||||
ent.dono = name
|
||||
|
||||
-- Salva nome da entidade
|
||||
ent.name = "telepro:balao"
|
||||
|
||||
return true
|
||||
end
|
|
@ -0,0 +1,141 @@
|
|||
--[[
|
||||
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/>.
|
||||
|
||||
Bau do balao
|
||||
]]
|
||||
|
||||
-- Node
|
||||
minetest.register_node("telepro:bau", {
|
||||
description = "Bau do Balao",
|
||||
tiles = {
|
||||
"default_chest_top.png^telepro_bau_cima.png", -- Cima
|
||||
"default_chest_top.png", -- Baixo
|
||||
"default_chest_side.png^telepro_bau_direita.png", -- Direita
|
||||
"default_chest_side.png^telepro_bau_esquerda.png", -- Esquerda
|
||||
"default_chest_side.png^telepro_bau_fundo.png", -- Fundo
|
||||
"default_chest_front.png" -- Frente
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_rightclick = function(pos, node, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if (meta:get_string("dono") or "") == player:get_player_name() then
|
||||
telepro.acessar_bau(player)
|
||||
else
|
||||
minetest.chat_send_player(player:get_player_name(), "Esse Balao nao lhe pertence.")
|
||||
end
|
||||
end,
|
||||
drop = "",
|
||||
})
|
||||
|
||||
-- Atualização constante do balão
|
||||
minetest.register_abm{
|
||||
nodenames = {"telepro:bau"},
|
||||
interval = 2,
|
||||
chance = 1,
|
||||
action = function(pos)
|
||||
|
||||
-- Pegar metadados do bau
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
-- Verifica se o bau tem dono
|
||||
if meta:get_string("dono") == "" then return end
|
||||
|
||||
--
|
||||
-- Verificar se ta tudo ok
|
||||
--
|
||||
|
||||
-- Salvar o nome do dono
|
||||
if meta:get_string("status") == "ativo" then
|
||||
|
||||
-- Verificar cordas
|
||||
do
|
||||
-- Pegar os nodes
|
||||
local nodes = minetest.find_nodes_in_area(
|
||||
{x=pos.x, y=pos.y+1, z=pos.z},
|
||||
{x=pos.x, y=pos.y+24, z=pos.z},
|
||||
{"telepro:corda_balao"}
|
||||
)
|
||||
-- Verificar se estao todos
|
||||
if table.maxn(nodes) < 24 then
|
||||
-- Desativa o bau
|
||||
meta:set_string("status", "inativo")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- Verifica balao
|
||||
do
|
||||
local r = false -- Variavel que avisa se achou o balao
|
||||
for _,obj in ipairs(minetest.get_objects_inside_radius(pos, 30)) do
|
||||
local ent = obj:get_luaentity() or {}
|
||||
-- Verifica se eh o balao
|
||||
if ent and ent.name == "telepro:balao" and ent.dono == meta:get_string("dono") then
|
||||
r = true -- achou balao
|
||||
end
|
||||
end
|
||||
if r == false then
|
||||
-- Desativa o bau
|
||||
meta:set_string("status", "inativo")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- Tudo ok
|
||||
return
|
||||
end
|
||||
|
||||
--
|
||||
-- Verificar se consegue colocar o balao e cordas
|
||||
--
|
||||
|
||||
-- Verificar se consegue colocar cordas
|
||||
do
|
||||
-- Pegar os nodes que podem ser substituidos por corda normalmente
|
||||
local nodes = minetest.find_nodes_in_area(
|
||||
{x=pos.x, y=pos.y+1, z=pos.z},
|
||||
{x=pos.x, y=pos.y+24, z=pos.z},
|
||||
{"air", "telepro:corda_balao"}
|
||||
)
|
||||
-- Verificar se esta tudo livre
|
||||
if table.maxn(nodes) < 24 then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- Verificar se consegue colocar balao
|
||||
do
|
||||
-- Pegar nodes
|
||||
local nodes = minetest.find_nodes_in_area(
|
||||
{x=pos.x-7, y=pos.y+24, z=pos.z-7},
|
||||
{x=pos.x+7, y=pos.y+24+25, z=pos.z+7},
|
||||
{"air", "telepro:corda_balao"}
|
||||
)
|
||||
|
||||
-- Verifica se pegou todos nodes de ar
|
||||
if table.maxn(nodes) < 5850 then -- 15 * 15 * 26
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- Verificar entidades na area do balao
|
||||
if table.maxn(minetest.get_objects_inside_radius({x=pos.x, y=pos.y+23+15, z=pos.z}, 15)) > 0 then
|
||||
return
|
||||
end
|
||||
|
||||
--
|
||||
-- Montar o balao e cordas
|
||||
--
|
||||
|
||||
telepro.montar_balao(pos, meta:get_string("dono"))
|
||||
|
||||
meta:set_string("status", "ativo")
|
||||
|
||||
end,
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
--[[
|
||||
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/>.
|
||||
|
||||
Bau do balao do spawn
|
||||
]]
|
||||
|
||||
-- Node
|
||||
minetest.register_node("telepro:bau_spawn", {
|
||||
description = "Bau do Balao do Centro",
|
||||
tiles = {
|
||||
"default_chest_top.png^telepro_bau_cima.png", -- Cima
|
||||
"default_chest_top.png", -- Baixo
|
||||
"default_chest_side.png^telepro_bau_direita.png", -- Direita
|
||||
"default_chest_side.png^telepro_bau_esquerda.png", -- Esquerda
|
||||
"default_chest_side.png^telepro_bau_fundo.png", -- Fundo
|
||||
"default_chest_front.png" -- Frente
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_rightclick = function(pos, node, player)
|
||||
telepro.acessar_bau_spawn(player)
|
||||
end,
|
||||
drop = "",
|
||||
})
|
|
@ -0,0 +1,29 @@
|
|||
--[[
|
||||
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/>.
|
||||
|
||||
Comandos
|
||||
]]
|
||||
|
||||
-- Reivindicar balao
|
||||
minetest.register_chatcommand("sethome", {
|
||||
privs = {},
|
||||
params = "Nenhum",
|
||||
description = "Reivindica um balao no local",
|
||||
func = function(name, param)
|
||||
telepro.acessar(minetest.get_player_by_name(name))
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("home", {
|
||||
privs = {},
|
||||
params = "Nenhum",
|
||||
description = "Vai para o balao",
|
||||
func = function(name, param)
|
||||
minetest.chat_send_player(name, "Utilize o Bau do Balao para isso.")
|
||||
end
|
||||
})
|
|
@ -0,0 +1,11 @@
|
|||
--[[
|
||||
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/>.
|
||||
|
||||
Ajuste de compatibilidade com outros mods
|
||||
]]
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
--[[
|
||||
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/>.
|
||||
|
||||
Funções simples e comuns
|
||||
]]
|
||||
|
||||
-- Verificar se o bau de balaode um jogador está perto
|
||||
telepro.verif_prox_bau = function(player)
|
||||
|
||||
-- Pegar nome do jogador
|
||||
local name = player:get_player_name()
|
||||
|
||||
-- Pegar coordenada do jogador
|
||||
local pos = player:getpos()
|
||||
|
||||
-- Pegar nodes de Bau de Balao proximos
|
||||
local nodes = minetest.find_nodes_in_area(
|
||||
{x=pos.x-8, y=pos.y-8, z=pos.z-8},
|
||||
{x=pos.x+8, y=pos.y+8, z=pos.z+8},
|
||||
{"telepro:bau"}
|
||||
)
|
||||
|
||||
-- Verifica todos os baus encontrados
|
||||
for _,p in ipairs(nodes) do
|
||||
-- Pega os metadados do bau
|
||||
local meta = minetest.get_meta(p)
|
||||
-- Pega o nome do dono do bau
|
||||
local n = meta:get_string("dono") or ""
|
||||
-- Verifica se é o mesmo nome do jogador
|
||||
if n == name then
|
||||
-- Retorna que encontrou o bau do jogador
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
-- Retorna que nao encontrou o bau do jogador
|
||||
return false
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- Criar balao e cordas para um bau de balao (ignora verificações)
|
||||
telepro.montar_balao = function(pos, name)
|
||||
|
||||
-- Colocar cordas
|
||||
do
|
||||
-- Desativa as verificações das cordas
|
||||
telepro.cordas_f = false
|
||||
|
||||
local y = 1
|
||||
while y <= 24 do
|
||||
minetest.set_node({x=pos.x, y=pos.y+y, z=pos.z}, {name="telepro:corda_balao"})
|
||||
y = y + 1
|
||||
end
|
||||
|
||||
-- Reativa as verificações das cordas
|
||||
telepro.cordas_f = true
|
||||
end
|
||||
|
||||
-- Colocar balao
|
||||
telepro.criar_balao({x=pos.x, y=pos.y+23, z=pos.z}, pos, name)
|
||||
|
||||
end
|
|
@ -0,0 +1,45 @@
|
|||
--[[
|
||||
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/>.
|
||||
|
||||
Corda do Balao
|
||||
]]
|
||||
|
||||
-- Variavel que impede que cordas sejam colocadas (ativa as verificações da fisica das cordas)
|
||||
telepro.cordas_f = true
|
||||
|
||||
-- Node
|
||||
minetest.register_node("telepro:corda_balao", {
|
||||
description = "Corda de Balao",
|
||||
drawtype = "torchlike",
|
||||
tiles = {"telepro_corda_balao.png"},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {0, 0, 0, 0, 0, 0},
|
||||
},
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 2, not_in_creative_inventory = 1},
|
||||
drop = "",
|
||||
|
||||
-- Ao ser removido de uma pos
|
||||
after_destruct = function(pos)
|
||||
-- Remove corda abaixo
|
||||
if telepro.cordas_f == true and minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name == "telepro:corda_balao" then
|
||||
minetest.remove_node({x=pos.x,y=pos.y-1,z=pos.z})
|
||||
end
|
||||
end,
|
||||
|
||||
-- Ao ser colocado de uma pos
|
||||
on_construct = function(pos)
|
||||
-- Remove caso nao tenha corda em cima
|
||||
if telepro.cordas_f == true and minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}).name ~= "telepro:corda_balao" then
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
end,
|
||||
})
|
|
@ -0,0 +1,2 @@
|
|||
memor?
|
||||
default
|
|
@ -0,0 +1,113 @@
|
|||
--[[
|
||||
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/>.
|
||||
|
||||
Gerar um Balao Aleatorio
|
||||
]]
|
||||
|
||||
-- Finaliza o procedimento de gerar balao
|
||||
local finalizar = function(player, pos)
|
||||
if not player then return end
|
||||
|
||||
-- Carregar mapa
|
||||
minetest.get_voxel_manip():read_from_map({x=pos.x-10,y=pos.y-10, z=pos.z-10}, {x=pos.x+10,y=pos.y+80, z=pos.z+10})
|
||||
|
||||
-- Procura grama
|
||||
local nodes = minetest.find_nodes_in_area({x=pos.x-10,y=pos.y-10, z=pos.z-10}, {x=pos.x+10,y=pos.y+80, z=pos.z+10}, {"group:spreading_dirt_type"})
|
||||
|
||||
-- Verifica se encontrou uma terra superficial
|
||||
if table.maxn(nodes) == 0 then
|
||||
return telepro.gerar_balao_aleatorio(player)
|
||||
end
|
||||
|
||||
local name = player:get_player_name()
|
||||
|
||||
-- Pegar uma coordenada
|
||||
local p = nodes[1]
|
||||
|
||||
-- Cordenada do bau
|
||||
local pb = {x=p.x, y=p.y+1, z=p.z}
|
||||
|
||||
-- Colocar balao
|
||||
-- Desativa o bau anterior
|
||||
do
|
||||
-- Verificar se existe registro no banco de dados
|
||||
if telepro.bd:verif(name, "pos") == true then
|
||||
-- Pega a coordenada
|
||||
local pp = telepro.bd:pegar(name, "pos")
|
||||
-- Acessa os metadados
|
||||
local meta = minetest.get_meta(pp)
|
||||
-- Limpa o parametro dono
|
||||
meta:set_string("dono", "")
|
||||
end
|
||||
end
|
||||
|
||||
-- Colocar Bau
|
||||
minetest.set_node(pb, {name="telepro:bau"})
|
||||
-- Pega os metadados do bau
|
||||
local meta = minetest.get_meta(pb)
|
||||
-- Salvar o nome do dono
|
||||
meta:set_string("dono", name)
|
||||
meta:set_string("status", "ativo") -- Salvar status inicial
|
||||
|
||||
-- Salva a coordenada do novo bau no banco de dados
|
||||
telepro.bd:salvar(name, "pos", pb)
|
||||
|
||||
-- Montar balao
|
||||
telepro.montar_balao(pb, name)
|
||||
|
||||
-- Levar o jogador um pouco pra cima
|
||||
player:setpos({x=pb.x, y=pb.y+1.5, z=pb.z})
|
||||
|
||||
-- Travar por 24 horas para impedir ficar gerando em vaios locais
|
||||
telepro.travados[name] = true
|
||||
minetest.after(3600, telepro.destravar, name)
|
||||
|
||||
-- Finaliza
|
||||
minetest.chat_send_player(name, "Novo local gerado. Mantenha o local do balao bem aberto.")
|
||||
|
||||
end
|
||||
|
||||
-- Gerar um balao aleatorio (ignora verificações)
|
||||
telepro.gerar_balao_aleatorio = function(player)
|
||||
|
||||
-- Pegar uma coordenada aleatória
|
||||
local pos = {x=math.random(-25000, 25000), y = 10, z=math.random(-25000, 25000)}
|
||||
|
||||
local name = player:get_player_name()
|
||||
|
||||
-- Verificar area protegida
|
||||
if minetest.is_protected({x=pos.x+5, y=pos.y, z=pos.z+5}, name)
|
||||
or minetest.is_protected({x=pos.x-5, y=pos.y, z=pos.z+5}, name)
|
||||
or minetest.is_protected({x=pos.x+5, y=pos.y, z=pos.z-5}, name)
|
||||
or minetest.is_protected({x=pos.x-5, y=pos.y, z=pos.z-5}, name)
|
||||
-- Em uma distancia maior
|
||||
or minetest.is_protected({x=pos.x+20, y=pos.y, z=pos.z+20}, name)
|
||||
or minetest.is_protected({x=pos.x-20, y=pos.y, z=pos.z+20}, name)
|
||||
or minetest.is_protected({x=pos.x+20, y=pos.y, z=pos.z-20}, name)
|
||||
or minetest.is_protected({x=pos.x-20, y=pos.y, z=pos.z-20}, name)
|
||||
-- Em cima
|
||||
or minetest.is_protected({x=pos.x+5, y=pos.y+25, z=pos.z+5}, name)
|
||||
or minetest.is_protected({x=pos.x-5, y=pos.y+25, z=pos.z+5}, name)
|
||||
or minetest.is_protected({x=pos.x+5, y=pos.y+25, z=pos.z-5}, name)
|
||||
or minetest.is_protected({x=pos.x-5, y=pos.y+25, z=pos.z-5}, name)
|
||||
-- Em uma distancia maior (em cima)
|
||||
or minetest.is_protected({x=pos.x+20, y=pos.y+25, z=pos.z+20}, name)
|
||||
or minetest.is_protected({x=pos.x-20, y=pos.y+25, z=pos.z+20}, name)
|
||||
or minetest.is_protected({x=pos.x+20, y=pos.y+25, z=pos.z-20}, name)
|
||||
or minetest.is_protected({x=pos.x-20, y=pos.y+25, z=pos.z-20}, name)
|
||||
then
|
||||
return telepro.gerar_balao_aleatorio(player)
|
||||
end
|
||||
|
||||
-- Inicia geração de mapa
|
||||
minetest.emerge_area({x=pos.x-10,y=pos.y-10, z=pos.z-10}, {x=pos.x+10,y=pos.y+80, z=pos.z+10})
|
||||
|
||||
-- Espera um tempo para continuar
|
||||
minetest.after(8, finalizar, player, pos)
|
||||
|
||||
end
|
|
@ -0,0 +1,65 @@
|
|||
--[[
|
||||
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/>.
|
||||
|
||||
Inicializador de variaveis e scripts
|
||||
]]
|
||||
|
||||
-- Notificador de Inicializador
|
||||
local notificar = function(msg)
|
||||
if minetest.setting_get("log_mods") then
|
||||
minetest.debug("[Telepro]"..msg)
|
||||
end
|
||||
end
|
||||
|
||||
local modpath = minetest.get_modpath("telepro")
|
||||
|
||||
-- Variavel global
|
||||
telepro = {}
|
||||
|
||||
-- Spawn do servidor (para onde os baloes permitem ir)
|
||||
telepro.spawn = minetest.setting_get_pos("static_spawnpoint") or {x=0, y=0, z=0}
|
||||
|
||||
-- Carregar scripts
|
||||
notificar("Carregando scripts...")
|
||||
|
||||
-- Scripts mod memor embarcado
|
||||
dofile(modpath.."/memor/init.lua")
|
||||
-- Criação do banco de dados
|
||||
telepro.bd = memor.montar_bd()
|
||||
-- Criar tabela de jogadores online
|
||||
telepro.online = memor.online()
|
||||
|
||||
-- Funções
|
||||
dofile(modpath.."/reivindicar.lua")
|
||||
dofile(modpath.."/ir_balao.lua")
|
||||
dofile(modpath.."/comum.lua")
|
||||
dofile(modpath.."/reparar_balao.lua")
|
||||
dofile(modpath.."/gerar_balao_aleatorio.lua")
|
||||
|
||||
-- Interfaces
|
||||
dofile(modpath.."/interface_bau.lua")
|
||||
dofile(modpath.."/interface_jogador.lua")
|
||||
|
||||
-- Balao
|
||||
dofile(modpath.."/balao.lua")
|
||||
|
||||
-- Nodes
|
||||
dofile(modpath.."/corda.lua")
|
||||
dofile(modpath.."/bau.lua")
|
||||
dofile(modpath.."/bau_spawn.lua")
|
||||
|
||||
-- Comandos
|
||||
dofile(modpath.."/comandos.lua")
|
||||
|
||||
-- Gerador de balao automatico
|
||||
dofile(modpath.."/autogen.lua")
|
||||
|
||||
-- Ajuste de compatibilidade com outros mods
|
||||
dofile(modpath.."/compatibilidade.lua")
|
||||
notificar("OK")
|
||||
|
|
@ -0,0 +1,156 @@
|
|||
--[[
|
||||
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/>.
|
||||
|
||||
Interface do Bau do balao
|
||||
]]
|
||||
|
||||
|
||||
-- Acessar um Bau de Balao
|
||||
telepro.acessar_bau = function(player)
|
||||
if not player then
|
||||
minetest.log("error", "[Telepro] player == nil (em telepro.acessar)")
|
||||
return false
|
||||
end
|
||||
|
||||
-- Verificar se tem um Bau de Balao perto do jogador que pertenca a ele
|
||||
if telepro.verif_prox_bau(player) == false then
|
||||
minetest.chat_send_player(player:get_player_name(), "Muito distante do seu Bau de Balao")
|
||||
return false
|
||||
end
|
||||
|
||||
-- Exibir formulario de opcoes ao jogador
|
||||
|
||||
-- Cria formspec
|
||||
local formspec = "size[6,4.8]"
|
||||
..default.gui_bg
|
||||
..default.gui_bg_img
|
||||
.."image[0,0;7.3,3;telepro_intro.png]"
|
||||
.."button_exit[0,3;6,1;ir_centro;Ir para Centro]"
|
||||
.."button_exit[0,4;6,1;reparar;Reparar Balao]"
|
||||
|
||||
-- Exibir formspec
|
||||
minetest.show_formspec(player:get_player_name(), "telepro:bau", formspec)
|
||||
|
||||
end
|
||||
|
||||
-- Acessar um Bau de Centro de Balao
|
||||
telepro.acessar_bau_spawn = function(player)
|
||||
if not player then
|
||||
minetest.log("error", "[Telepro] player == nil (em telepro.acessar)")
|
||||
return false
|
||||
end
|
||||
|
||||
-- Exibir formulario de opcoes ao jogador
|
||||
|
||||
-- Cria formspec
|
||||
local formspec = "size[6,4]"
|
||||
..default.gui_bg
|
||||
..default.gui_bg_img
|
||||
.."image[0,0;7.3,3;telepro_intro.png]"
|
||||
.."button_exit[0,3;6,1;ir_balao;Ir para o posto de seu Balao]"
|
||||
|
||||
-- Exibir formspec
|
||||
minetest.show_formspec(player:get_player_name(), "telepro:bau_spawn", formspec)
|
||||
|
||||
end
|
||||
|
||||
-- Receber botoes
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
|
||||
-- Bau do jogador
|
||||
if formname == "telepro:bau" then
|
||||
|
||||
-- Botao de ir para o centro
|
||||
if fields.ir_centro then
|
||||
|
||||
-- Pegar nome do jogador
|
||||
local name = player:get_player_name()
|
||||
|
||||
-- Pegar coordenada do jogador
|
||||
local pos = player:getpos()
|
||||
|
||||
-- Verificar se tem um Bau de Balao perto do jogador que pertenca a ele
|
||||
if telepro.verif_prox_bau(player) == false then
|
||||
minetest.chat_send_player(name, "Muito distante do seu Bau de Balao")
|
||||
return
|
||||
end
|
||||
|
||||
-- Verifica status do bau do balao
|
||||
do
|
||||
-- Pega os metadados do bau
|
||||
local meta = minetest.get_meta(telepro.bd:pegar(name, "pos"))
|
||||
|
||||
if meta:get_string("status") ~= "ativo" then
|
||||
minetest.chat_send_player(name, "Balao inoperante. Aguarde mantenha o local limpo e aberto e aguarde ele ficar pronto.")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- Teleportar jogador
|
||||
player:setpos(telepro.spawn)
|
||||
minetest.chat_send_player(name, "Viagem ao Centro realizada.")
|
||||
elseif fields.reparar then
|
||||
|
||||
-- Pegar nome do jogador
|
||||
local name = player:get_player_name()
|
||||
|
||||
-- Verificar se tem um Bau de Balao perto do jogador que pertenca a ele
|
||||
if telepro.verif_prox_bau(player) == false then
|
||||
minetest.chat_send_player(name, "Muito distante do seu Bau de Balao")
|
||||
return
|
||||
end
|
||||
|
||||
-- Pegar coordenada do bau
|
||||
local pos = telepro.bd:pegar(name, "pos")
|
||||
|
||||
-- Verificar se o balao ja esta ativo
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_string("status") == "ativo" then
|
||||
minetest.chat_send_player(name, "O Balao ja esta ativo. Nao precisa reparar.")
|
||||
return
|
||||
end
|
||||
|
||||
-- Reparar o balao
|
||||
telepro.reparar_balao(name, pos)
|
||||
|
||||
end
|
||||
|
||||
-- Bau do Spawn
|
||||
elseif formname == "telepro:bau_spawn" then
|
||||
|
||||
-- Teleportar para o posto do balao do jogador
|
||||
if fields.ir_balao then
|
||||
|
||||
-- Pegar nome do jogador
|
||||
local name = player:get_player_name()
|
||||
|
||||
-- Pegar coordenada do jogador
|
||||
local pos = player:getpos()
|
||||
|
||||
-- Verificar se tem um Bau de Centro de Balao por perto
|
||||
if not minetest.find_node_near({x=pos.x, y=pos.y-2, z=pos.z}, 8, {"telepro:bau_spawn"}) then
|
||||
minetest.chat_send_player(name, "Muito distante do Bau de Balao do Centro")
|
||||
return
|
||||
end
|
||||
|
||||
-- Verificar se o jogador tem um balao
|
||||
if telepro.bd:verif(name, "pos") ~= true then
|
||||
return telepro.acessar(minetest.get_player_by_name(name))
|
||||
end
|
||||
|
||||
-- Verificar se o balao esta ativo
|
||||
if minetest.get_meta(telepro.bd:pegar(name, "pos")):get_string("status") ~= "ativo" then
|
||||
minetest.chat_send_player(name, "O Seu Balao nao esta funcionando. O local foi destruido ou obstruido.")
|
||||
end
|
||||
|
||||
-- Tenta teleportar o jogador
|
||||
telepro.ir_balao(player)
|
||||
return
|
||||
end
|
||||
end
|
||||
end)
|
|
@ -0,0 +1,56 @@
|
|||
--[[
|
||||
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/>.
|
||||
|
||||
Interface do Jogador
|
||||
]]
|
||||
|
||||
-- Acesar interface do jogador
|
||||
telepro.acessar = function(player)
|
||||
if not player then
|
||||
minetest.log("error", "[Telepro] player == nil (em telepro.acessar)")
|
||||
return false
|
||||
end
|
||||
|
||||
-- Cria formspec
|
||||
local formspec = "size[3,5]"
|
||||
..default.gui_bg
|
||||
..default.gui_bg_img
|
||||
.."image[0,0;3.5,3.5;telepro_mapa.png]"
|
||||
.."button_exit[0,3.25;3,1;gerar_balao;Gerar Balao]"
|
||||
.."button_exit[0,4.25;3,1;por_balao_aqui;Por Balao Aqui]"
|
||||
|
||||
-- Exibir formspec
|
||||
minetest.show_formspec(player:get_player_name(), "telepro:jogador", formspec)
|
||||
end
|
||||
|
||||
-- Receber botoes
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
|
||||
if formname == "telepro:jogador" then
|
||||
|
||||
if fields.gerar_balao then
|
||||
|
||||
if telepro.travados[name] == true then
|
||||
minetest.chat_send_player(player:get_player_name(), "Nao pode gerar um novo balao ainda. (sao necessarias 24 horas desde a ultima vez que gerou)")
|
||||
return
|
||||
end
|
||||
|
||||
minetest.chat_send_player(player:get_player_name(), "Aguarde alguns segundos enquanto o balao esta endo preparado.")
|
||||
telepro.gerar_balao_aleatorio(player)
|
||||
elseif fields.por_balao_aqui then
|
||||
if telepro.travados[name] == true then
|
||||
minetest.chat_send_player(player:get_player_name(), "Nao pode colocar um novo balao ainda. (sao necessarias 24 horas desde a ultima vez que gerou ou colocou)")
|
||||
return
|
||||
end
|
||||
|
||||
telepro.reivindicar(player)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end)
|
|
@ -0,0 +1,71 @@
|
|||
--[[
|
||||
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/>.
|
||||
|
||||
Função para teleportar para balao
|
||||
]]
|
||||
|
||||
-- Pegar node, mesmo que não esteja na memoria
|
||||
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
|
||||
|
||||
-- Teleportar jogador para o posto de seu balao
|
||||
telepro.ir_balao = function(player)
|
||||
if not player then
|
||||
minetest.log("error", "[Telepro] player == nil (em telepro.reivindicar)")
|
||||
return false
|
||||
end
|
||||
|
||||
-- Pegar nome do jogador
|
||||
local name = player:get_player_name()
|
||||
|
||||
-- Verifica se o registro de balao existe no banco de dados
|
||||
if telepro.bd:verif(name, "pos") == false then
|
||||
minetest.chat_send_player(player:get_player_name(), "Sem nenhum balao ainda.")
|
||||
return false
|
||||
end
|
||||
|
||||
-- Pegar coordenada do bau
|
||||
local pos = telepro.bd:pegar(name, "pos")
|
||||
|
||||
-- Verificar se o balao existente no banco de dados ainda existe no mapa
|
||||
do
|
||||
|
||||
-- Verificar se o nome do bloco é o de uma bau
|
||||
if pegar_node(pos).name ~= "telepro:bau" then
|
||||
minetest.chat_send_player(player:get_player_name(), "Seu balao foi destruido.")
|
||||
return false
|
||||
end
|
||||
|
||||
-- Pega os metadados do bau
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
-- Pega o nome do dono do bau
|
||||
local n = meta:get_string("dono") or ""
|
||||
|
||||
-- Verifica se é o mesmo nome do jogador
|
||||
if n ~= name then
|
||||
minetest.chat_send_player(player:get_player_name(), "Seu balao foi destruido.")
|
||||
return false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--Teleporta o jogador para o balao
|
||||
player:setpos({x=pos.x, y=pos.y+1.5, z=pos.z})
|
||||
|
||||
-- Finaliza
|
||||
minetest.chat_send_player(player:get_player_name(), "Viagem para o posto de seu balao realizada.")
|
||||
return true
|
||||
|
||||
end
|
|
@ -0,0 +1,99 @@
|
|||
Mod Memor para Minetest
|
||||
Memor v1.2 Copyright (C) 2016 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/>.
|
||||
|
||||
API
|
||||
|
||||
===================================> Montar um banco de dados rápido <===================================
|
||||
Esse banco de dados fica em uma subpasta com o nome do mod especificado portanto não deve existir nenhum
|
||||
arquivo ou pasta com o nome do mod dentro da pasta do mundo pois isso ocasionaria um conflito de nomes
|
||||
|
||||
memor.montar_bd(<nome do mod>) -- Função que retorna uma tabela de funções para gerenciar o banco de
|
||||
dados do mod
|
||||
|
||||
<nome do mod> OPCIONAL é o nome do mod que usará o banco de dados
|
||||
Se nulo, fica sendo o nome do mod que executar a função
|
||||
|
||||
Chamadas de função para o banco de dados criado
|
||||
|
||||
salvar(tb, index, valor) -- Salva um valor no banco de dados (cria as tabelas se não existirem)
|
||||
|
||||
<tb> é o nome da tabela (exemplo: players, nodes, casas)
|
||||
<index> é o endereço do valor (exemplo: fome, altura, dono)
|
||||
<valor> é o valor armazenado (exemplo: 6, 30, "Caio")
|
||||
|
||||
pegar(tb, index) -- Retorna o valor armazenado (ou nulo caso seja inexistente)
|
||||
|
||||
<tb> é o nome da tabela (exemplo: players, nodes, casas)
|
||||
<index> é o endereço do valor (exemplo: fome, altura, dono)
|
||||
|
||||
verif(tb, index) -- Verifica se um determinado registro existe (retorna 'true' se existir)
|
||||
|
||||
<tb> é o nome da tabela (exemplo: players, nodes, casas)
|
||||
<index> é o endereço do valor (exemplo: fome, altura, dono)
|
||||
|
||||
remover(tb, index) -- Remove um valor da tabela (apaga o dado armazenado)
|
||||
|
||||
<tb> é o nome da tabela (exemplo: players, nodes, casas)
|
||||
<index> é o endereço do valor (exemplo: fome, altura, dono)
|
||||
|
||||
drop_tb(tb) -- Remove uma tabela (apagando todos os seus dados)
|
||||
|
||||
<tb> é o nome da tabela (exemplo: players, nodes, casas)
|
||||
|
||||
listar(tb) -- Retorna uma tabela ordenada com strings dos nomes de tabelas ou indices
|
||||
|
||||
<tb> OPICIONAL é uma tabela a qual desejar listar os sues indices
|
||||
^ Se nulo, retorna as listagem das tabelas do banco de dados
|
||||
|
||||
Exemplo de uso:
|
||||
|
||||
-- Montar um banco de dados na variavel 'registro'
|
||||
local registro = memor.montar_bd(minetest.get_current_modname())
|
||||
|
||||
-- Criar uma tabela de "medalhas" onde "Maria" terá 15
|
||||
registro:salvar("medalhas", "Maria", 15)
|
||||
|
||||
-- Verifica se "Maria" existe na tabela de "Medalhas"
|
||||
if registro:verif("medalhas", "Maria") then
|
||||
|
||||
-- Consulta quantas "medalhas" "Maria" tem
|
||||
local medalhas = registro:pegar("medalhas", "Maria") -- retorna 15
|
||||
|
||||
minetest.chat_send_all("Maria tem " .. medalhas .. " medalhas")
|
||||
|
||||
end
|
||||
|
||||
-- Remover "Maria" da tabela "medalhas"
|
||||
registro:remover("medalhas", "Maria")
|
||||
|
||||
-- Remove a tabela "medalhas"
|
||||
registro:drop_tb("medalhas")
|
||||
|
||||
=========================================================================================================
|
||||
|
||||
=====================================> Tabela de jogadores online <======================================
|
||||
|
||||
memor.online(<nome do mod>) -- Retorna uma tabela desordenada com índices com nomes dos jogadores online
|
||||
^ A tabela só mantém dados dos índices de jogadores online
|
||||
^ Caso um nome de jogador que não esteja online for inserido, ele vai
|
||||
ser apagado assim que algum jogador sair do servidor
|
||||
|
||||
<nome do mod> OPCIONAL é uma string com o nome do mod dono da tabela (o que opera a tabela)
|
||||
Se nulo, fica sendo o nome do mod que executar a função
|
||||
|
||||
Exemplo de uso:
|
||||
|
||||
-- Tabela que guarda quem é o convidado de um jogador (controlada para manter apenas jogadores online)
|
||||
local convidados = memor.online()
|
||||
|
||||
-- Jogador "Arnaldo" tem "Luiz" como convidado
|
||||
convidados["Arnaldo"] = "Luiz"
|
||||
|
||||
-- Quando o jogador "Arnaldo" sair do servidor, esse dado será apagado da memória
|
||||
|
||||
=========================================================================================================
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
--[[
|
||||
Mod Memor para Minetest
|
||||
Memor v1.2 Copyright (C) 2016 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/>.
|
||||
|
||||
Operadores de arquivamento e leitura
|
||||
]]
|
||||
|
||||
|
||||
-- Diretorio do mundo
|
||||
local wpath = minetest.get_worldpath()
|
||||
|
||||
-- Cria um diretório na pasta do mundo
|
||||
function memor.mkdir(dir, sub)
|
||||
if not dir then
|
||||
minetest.log("error", "[Memor] Nenhum diretorio especificado (em memor.mkdir)")
|
||||
return false
|
||||
end
|
||||
|
||||
dir = wpath.."/"..dir
|
||||
|
||||
if minetest.mkdir then
|
||||
minetest.mkdir(dir)
|
||||
else
|
||||
os.execute('mkdir "' .. dir .. '"')
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
-- Criar um arquivo com os dados serializados (Salvar)
|
||||
function memor.escrever(mod, dir, arquivo, dados)
|
||||
if mod == nil or dir == nil or arquivo == nil or dados == nil then
|
||||
minetest.log("error", "[Memor] Faltou dados (em memor.escrever)")
|
||||
return false
|
||||
end
|
||||
|
||||
local dados = minetest.serialize(dados)
|
||||
if dados == "" then
|
||||
minetest.log("error", "[Memor] Dado fornecido invalido (em memor.escrever)")
|
||||
return false
|
||||
end
|
||||
|
||||
local saida = io.open(wpath .. "/" .. mod .. "/" .. dir .. "/" .. arquivo, "w")
|
||||
if saida then
|
||||
saida:write(dados)
|
||||
io.close(saida)
|
||||
return true
|
||||
else
|
||||
minetest.log("info", "[Memor] memor.escrever tentou escrever num diretorio inexistente")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Ler dados de um arquivo de memória (Carregar)
|
||||
function memor.ler(mod, dir, arquivo)
|
||||
if mod == nil or dir == nil or arquivo == nil then
|
||||
minetest.log("error", "[Memor] Faltou dados (em memor.ler)")
|
||||
return nil
|
||||
end
|
||||
|
||||
local entrada = io.open(wpath .. "/" .. mod .. "/" .. dir .. "/" .. arquivo, "r")
|
||||
if entrada then
|
||||
local dados = entrada:read("*l")
|
||||
if dados ~= "" or dados ~= nil then
|
||||
dados = minetest.deserialize(dados)
|
||||
end
|
||||
io.close(entrada)
|
||||
return dados
|
||||
else
|
||||
minetest.log("error", "[Memor] pasta e/ou arquivo inexiste(s) (em memor.ler)")
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
-- Deletar um arquivo
|
||||
function memor.deletar(mod, dir, arquivo)
|
||||
if not mod or not dir or not arquivo then
|
||||
minetest.log("error", "[Memor] Faltou dados (em memor.deletar)")
|
||||
return false
|
||||
end
|
||||
|
||||
os.remove(wpath .. "/" .. mod .. "/" .. dir .. "/" .. arquivo)
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
-- Deletar um diretório
|
||||
function memor.deletar_dir(mod, dir)
|
||||
if not mod or not dir then
|
||||
minetest.log("error", "[Memor] Faltou dados (em memor.deletar_dir)")
|
||||
return false
|
||||
end
|
||||
|
||||
local list = minetest.get_dir_list(wpath .. "/" .. mod .. "/" .. dir)
|
||||
|
||||
for n, arquivo in ipairs(list) do
|
||||
os.remove(wpath .. "/" .. mod .. "/" .. dir .. "/" .. arquivo)
|
||||
end
|
||||
|
||||
os.remove(wpath .. "/" .. mod .. "/" .. dir)
|
||||
return true
|
||||
end
|
|
@ -0,0 +1,129 @@
|
|||
--[[
|
||||
Mod Memor para Minetest
|
||||
Memor v1.2 Copyright (C) 2016 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/>.
|
||||
|
||||
Operadores de consulta
|
||||
]]
|
||||
|
||||
-- Diretório do Mundo
|
||||
local wpath = minetest.get_worldpath()
|
||||
|
||||
-- Verifica diretorios e corrige
|
||||
verificar = function(dir, subdir)
|
||||
|
||||
-- Verifica e corrige diretorio
|
||||
local list = minetest.get_dir_list(minetest.get_worldpath(), true)
|
||||
local r = false
|
||||
for n, ndir in ipairs(list) do
|
||||
if ndir == dir then
|
||||
r = true
|
||||
break
|
||||
end
|
||||
end
|
||||
-- Diretorio inexistente
|
||||
if r == false then
|
||||
memor.mkdir(dir)
|
||||
end
|
||||
|
||||
-- Verifica e corrige subdiretorio
|
||||
list = minetest.get_dir_list(minetest.get_worldpath().."/"..dir, true)
|
||||
r = false
|
||||
for n, ndir in ipairs(list) do
|
||||
if ndir == subdir then
|
||||
r = true
|
||||
break
|
||||
end
|
||||
end
|
||||
-- Subdiretorio inexistente
|
||||
if r == false then
|
||||
memor.mkdir(dir.."/"..subdir)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- Inserir dados
|
||||
memor.inserir = function(mod, tb, index, valor)
|
||||
|
||||
-- Tenta inserir direto
|
||||
if memor.escrever(mod, tb, index, valor) == true then return true end
|
||||
|
||||
verificar(mod, tb)
|
||||
|
||||
if memor.escrever(mod, tb, index, valor) then
|
||||
return true
|
||||
else
|
||||
minetest.log("error", "[Memor] Impossivel salvar dados (em memor.inserir)")
|
||||
return false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- Ler dados
|
||||
memor.consultar = function(mod, tb, index)
|
||||
|
||||
local r = memor.ler(mod, tb, index)
|
||||
if r == nil then
|
||||
minetest.log("error", "[Memor] Registro acessado inexistente ("..dump(mod).."/"..dump(tb).."/"..dump(index)..") (em memor.consultar)")
|
||||
end
|
||||
|
||||
return r
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- Verificar dados
|
||||
memor.verificar = function(dir, subdir, arquivo)
|
||||
|
||||
list = minetest.get_dir_list(wpath .. "/" .. dir .. "/" .. subdir)
|
||||
r = false
|
||||
for n, arq in ipairs(list) do
|
||||
if arq == arquivo then
|
||||
r = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if r then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Listar
|
||||
memor.listar = function(dir, subdir)
|
||||
if dir == nil then
|
||||
minetest.log("error", "[Memor] Diretorio inexistente (em memor.listar)")
|
||||
return false
|
||||
end
|
||||
|
||||
if subdir then
|
||||
|
||||
local list = minetest.get_dir_list(wpath .. "/" .. dir .. "/" .. subdir)
|
||||
|
||||
if list == nil then
|
||||
minetest.log("error", "[Memor] Impossivel listar diretorio (em memor.listar)")
|
||||
return false
|
||||
else
|
||||
return list
|
||||
end
|
||||
|
||||
else
|
||||
local list = minetest.get_dir_list(wpath .. "/" .. dir)
|
||||
|
||||
if list == nil then
|
||||
minetest.log("error", "[Memor] Impossivel listar diretorio (em memor.listar)")
|
||||
return false
|
||||
else
|
||||
return list
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
--[[
|
||||
Mod Memor para Minetest
|
||||
Memor v1.2 Copyright (C) 2016 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/>.
|
||||
|
||||
Inicializador de scripts
|
||||
]]
|
||||
|
||||
--[[
|
||||
Script alterado para permitir funcionamento dentro do mod telepro
|
||||
]]
|
||||
|
||||
-- Verifica se o mod memor original esta ativo
|
||||
if minetest.get_modpath("memor") then return end
|
||||
|
||||
-- Notificador de Inicializador
|
||||
local notificar = function(msg)
|
||||
if minetest.setting_get("log_mods") then
|
||||
minetest.debug("[Aventuras/Memor]"..msg)
|
||||
end
|
||||
end
|
||||
|
||||
local modpath = minetest.get_modpath("telepro").."/memor"
|
||||
|
||||
-- Variavel global
|
||||
memor = {}
|
||||
|
||||
-- Carregar scripts
|
||||
notificar("Carregando scripts...")
|
||||
dofile(modpath.."/arquivo.lua")
|
||||
dofile(modpath.."/consulta.lua")
|
||||
dofile(modpath.."/montagem.lua")
|
||||
dofile(modpath.."/online.lua")
|
||||
notificar("OK")
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
--[[
|
||||
Mod Memor para Minetest
|
||||
Memor v1.2 Copyright (C) 2016 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/>.
|
||||
|
||||
Montagem de bando de dados
|
||||
]]
|
||||
|
||||
|
||||
-- Montar banco de dados em um mod
|
||||
function memor.montar_bd(mod)
|
||||
v = {}
|
||||
v.mod = mod or minetest.get_current_modname()
|
||||
|
||||
-- Inserir dados
|
||||
v.salvar = function(v, tb, index, valor)
|
||||
return memor.inserir(v.mod, tb, index, valor)
|
||||
end
|
||||
|
||||
-- Consultar dados
|
||||
v.pegar = function(v, tb, index)
|
||||
return memor.consultar(v.mod, tb, index)
|
||||
end
|
||||
|
||||
-- Verificar dados
|
||||
v.verif = function(v, tb, index)
|
||||
return memor.verificar(v.mod, tb, index)
|
||||
end
|
||||
|
||||
-- Remover dados
|
||||
v.remover = function(v, tb, index)
|
||||
return memor.deletar(v.mod, tb, index)
|
||||
end
|
||||
|
||||
-- Remover tabela
|
||||
v.drop_tb = function(v, tb)
|
||||
return memor.deletar_dir(v.mod, tb)
|
||||
end
|
||||
|
||||
-- Listar dados
|
||||
v.listar = function(v, tb)
|
||||
return memor.listar(v.mod, tb)
|
||||
end
|
||||
|
||||
return v
|
||||
end
|
|
@ -0,0 +1,37 @@
|
|||
--[[
|
||||
Mod Memor para Minetest
|
||||
Memor v1.3 Copyright (C) 2016 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/>.
|
||||
|
||||
Controle de jogadores online
|
||||
]]
|
||||
|
||||
|
||||
-- Controle de jogadores de cada mod
|
||||
memor.online_mods = {}
|
||||
|
||||
-- Montar banco de dados simples de jogadores online
|
||||
function memor.online(mod)
|
||||
local mod = mod or minetest.get_current_modname()
|
||||
|
||||
memor.online_mods[mod] = {}
|
||||
|
||||
return memor.online_mods[mod]
|
||||
end
|
||||
|
||||
-- Adiciona o jogador em todas listas quando entrar no servidor
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
for mod,l in pairs(memor.online_mods) do
|
||||
memor.online_mods[mod][player:get_player_name()] = {}
|
||||
end
|
||||
end)
|
||||
|
||||
-- Remove o jogador de todas listas quando entrar no servidor
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
for mod,l in pairs(memor.online_mods) do
|
||||
memor.online_mods[mod][player:get_player_name()] = nil
|
||||
end
|
||||
end)
|
|
@ -0,0 +1,148 @@
|
|||
--[[
|
||||
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/>.
|
||||
|
||||
Função para Reivindicar balao
|
||||
]]
|
||||
|
||||
-- Lista de jogadores que não podem gerar novo balao
|
||||
telepro.travados = {}
|
||||
|
||||
-- Metodo para destravar jogador (apos um tempo)
|
||||
telepro.destravar = function(name)
|
||||
telepro.travados[name] = false
|
||||
end
|
||||
|
||||
-- Metodo para reivindicar balao no local
|
||||
telepro.reivindicar = function(player)
|
||||
if not player then
|
||||
minetest.log("error", "[Telepro] player == nil (em telepro.reivindicar)")
|
||||
return false
|
||||
end
|
||||
|
||||
-- Pegar nome do jogador
|
||||
local name = player:get_player_name()
|
||||
|
||||
-- Verificar se está travado
|
||||
if telepro.travados[name] == true then
|
||||
minetest.chat_send_player(name, "Nao pode gerar um novo balao ainda. (sao necessarias 24 horas desde a ultima vez que gerou)")
|
||||
return false
|
||||
end
|
||||
|
||||
-- Pegar coordenada do jogador
|
||||
local pos = player:getpos()
|
||||
|
||||
-- Verifica se está numa coordenada muito baixa (menor que o nível do mar)
|
||||
if pos.y < 0 then
|
||||
minetest.chat_send_player(name, "Local muito baixo. Precisa subir para um local mais alto.")
|
||||
return false
|
||||
end
|
||||
|
||||
-- Verificar se está na luz do dia (força estar na superficie)
|
||||
do
|
||||
local luz = minetest.get_node_light(pos)
|
||||
if not luz or luz < 13 then
|
||||
minetest.chat_send_player(name, "Precisa estar na luz do dia.")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Verifica se cabe o balao
|
||||
|
||||
--[[
|
||||
- Caminho de bloco para cima totalmente livre 40 blocos
|
||||
- Cubo de espaço onde fica o balão
|
||||
]]
|
||||
|
||||
-- Verificar caminho de bloco para cima
|
||||
do
|
||||
-- Pegar nodes
|
||||
local nodes = minetest.find_nodes_in_area(
|
||||
{x=pos.x, y=pos.y, z=pos.z},
|
||||
{x=pos.x, y=pos.y+24, z=pos.z},
|
||||
{"air"}
|
||||
)
|
||||
|
||||
-- Verifica se pegou nodes de ar
|
||||
if table.maxn(nodes) < 25 then
|
||||
minetest.chat_send_player(name, "O caminho para cima esta obstruido. Encontre um lugar onde de para o balao descer.")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Verificar espaço onde fica o balão
|
||||
do
|
||||
-- Pegar nodes
|
||||
local nodes = minetest.find_nodes_in_area(
|
||||
{x=pos.x-7, y=pos.y+24, z=pos.z-7},
|
||||
{x=pos.x+7, y=pos.y+24+25, z=pos.z+7},
|
||||
{"air"}
|
||||
)
|
||||
|
||||
-- Verifica se pegou todos nodes de ar
|
||||
if table.maxn(nodes) < 5850 then -- 15 * 15 * 26
|
||||
minetest.chat_send_player(name, "Parte de cima obstruida. Libere o local ou suba.")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Verificar area protegida
|
||||
if minetest.is_protected(pos, name) -- local do bau
|
||||
-- corda para subir no balao
|
||||
or minetest.is_protected({x=pos.x, y=pos.y+5, z=pos.z}, name)
|
||||
or minetest.is_protected({x=pos.x, y=pos.y+10, z=pos.z}, name)
|
||||
or minetest.is_protected({x=pos.x, y=pos.y+15, z=pos.z}, name)
|
||||
or minetest.is_protected({x=pos.x, y=pos.y+20, z=pos.z}, name)
|
||||
then
|
||||
minetest.chat_send_player(name, "Local protegido.")
|
||||
return
|
||||
end
|
||||
|
||||
-- Verificar entidades na area do balao
|
||||
if table.maxn(minetest.get_objects_inside_radius({x=pos.x, y=pos.y+23, z=pos.z}, 15)) > 0 then
|
||||
minetest.chat_send_player(name, "Objetos obstruem a parte de cima. Libere o local ou suba.")
|
||||
return
|
||||
end
|
||||
|
||||
-- Desativa o bau anterior
|
||||
do
|
||||
-- Verificar se existe registro no banco de dados
|
||||
if telepro.bd:verif(name, "pos") == true then
|
||||
-- Pega a coordenada
|
||||
local p = telepro.bd:pegar(name, "pos")
|
||||
-- Acessa os metadados
|
||||
local meta = minetest.get_meta(p)
|
||||
-- Limpa o parametro dono
|
||||
meta:set_string("dono", "")
|
||||
end
|
||||
end
|
||||
|
||||
-- Colocar Bau
|
||||
minetest.set_node(pos, {name="telepro:bau"})
|
||||
-- Pega os metadados do bau
|
||||
local meta = minetest.get_meta(pos)
|
||||
-- Salvar o nome do dono
|
||||
meta:set_string("dono", name)
|
||||
meta:set_string("status", "ativo") -- Salvar status inicial
|
||||
|
||||
-- Salva a coordenada do novo bau no banco de dados
|
||||
telepro.bd:salvar(name, "pos", pos)
|
||||
|
||||
-- Montar balao
|
||||
telepro.montar_balao(pos, name)
|
||||
|
||||
-- Levar o jogador um pouco pra cima
|
||||
player:setpos({x=pos.x, y=pos.y+1.5, z=pos.z})
|
||||
|
||||
-- Travar por 24 horas para impedir ficar gerando em vaios locais
|
||||
telepro.travados[name] = true
|
||||
minetest.after(3600, telepro.destravar, name)
|
||||
|
||||
-- Finaliza
|
||||
minetest.chat_send_player(name, "Balao reivindicado com sucesso.")
|
||||
return true
|
||||
end
|
|
@ -0,0 +1,72 @@
|
|||
--[[
|
||||
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/>.
|
||||
|
||||
Reparar Balao
|
||||
]]
|
||||
|
||||
-- Metodo para reparar o balao
|
||||
telepro.reparar_balao = function(name, pos)
|
||||
|
||||
-- Verificar se está na luz do dia (força estar na superficie)
|
||||
do
|
||||
local luz = minetest.get_node_light({x=pos.x, y=pos.y+1, z=pos.z+1})
|
||||
if not luz or luz < 13 then
|
||||
minetest.chat_send_player(name, "Precisa estar na luz do dia.")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Verificar caminho de bloco para cima
|
||||
do
|
||||
-- Pegar nodes
|
||||
local nodes = minetest.find_nodes_in_area(
|
||||
{x=pos.x, y=pos.y, z=pos.z},
|
||||
{x=pos.x, y=pos.y+24, z=pos.z},
|
||||
{"air", "telepro:corda_balao"}
|
||||
)
|
||||
|
||||
-- Verifica se pegou nodes de ar
|
||||
if table.maxn(nodes) < 24 then
|
||||
minetest.chat_send_player(name, "O caminho para cima esta obstruido (corda). Abra mais o local."..table.maxn(nodes))
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Verificar espaço onde fica o balão
|
||||
do
|
||||
-- Pegar nodes
|
||||
local nodes = minetest.find_nodes_in_area(
|
||||
{x=pos.x-7, y=pos.y+24, z=pos.z-7},
|
||||
{x=pos.x+7, y=pos.y+24+25, z=pos.z+7},
|
||||
{"air", "telepro:corda_balao"}
|
||||
)
|
||||
|
||||
-- Verifica se pegou todos nodes de ar
|
||||
if table.maxn(nodes) < 5850 then -- 15 * 15 * 26
|
||||
minetest.chat_send_player(name, "Parte de cima obstruida (onde fica o balao). Libere o local ou suba.")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Verificar entidades na area do balao
|
||||
if table.maxn(minetest.get_objects_inside_radius({x=pos.x, y=pos.y+23, z=pos.z}, 15)) > 0 then
|
||||
minetest.chat_send_player(name, "Objetos obstruem a parte de cima. remova os objetos e tente novamente.")
|
||||
return
|
||||
end
|
||||
|
||||
-- Montar balao
|
||||
telepro.montar_balao(pos, name)
|
||||
|
||||
-- Ativa o balao
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("status", "ativo")
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 326 B |
After Width: | Height: | Size: 355 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 187 B |
After Width: | Height: | Size: 288 B |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 69 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 6.1 KiB |