Ayuda con una funcion :/

Spanish
Post Reply
libahunt
Member
Posts: 14
Joined: Tue Aug 19, 2014 09:54
In-game: libahunt
Location: Barcelona
Contact:

Ayuda con una funcion :/

by libahunt » Post

Hola! actualmente estoy intentando hacer que pueda detectar si hay agua en algunos de los lados de la torch (arriba y abajo no)... el problema es que no consigo averiguar la manera de comprobarlo!!!
Ademas que e estado mirando en http://dev.minetest.net/Category:Methods y no soy capaz de encontrar el metodo que de al player su item de nuevo (en este caso una torch)

PD. En lua soy bastante novato a sin que no os extrañe si el código le faltan cosas o le sobran! como no hay nadie que ayude (al menos en español) y encima que mi ingles es básico... Cualquier ayuda me serviría mucho!!!

Code: Select all

minetest.register_abm({
	nodenames = {"minimal:torch"},
	interval = 1,0,
	chance = 1,
	action = function(pos, node, active_object_count, active_object_count_wider)
	local node = minetest.get_node(pos)
	--Si es liquido directamente quitar el objeto
		if node.drawtype == "liquid" then
			minetest.set_node(pos, {name = "air"})
					--pos.y no varia (es siempre 0)
				end
																	-- x-1 y0 z1
		else if node.drawtype == "liquid" then
			pos.x=pos.x-1

			pos.z=pos.z+1
			if node.drawtype == "liquid" then
			minetest.set_node(pos, {name = "air"})
			end
		end
																	-- x0 y0 z1
		else if node.drawtype == "liquid" then
			pos.x=pos.x+1

			pos.z=pos.z+1
			if node.drawtype == "liquid" then
			minetest.set_node(pos, {name = "air"})
			end
		end

																	-- x1 y0 z1
		else if node.drawtype == "liquid" then
			pos.x=pos.x+1

			---pos.z=pos.z1
			if node.drawtype == "liquid" then
			minetest.set_node(pos, {name = "air"})
			end
		end
		
																	-- x-1 y0 z0
		else if node.drawtype== "liquid" then
			---pos.x=pos.x-1

			pos.z=pos.z-1
			if node.drawtype== "liquid" then
			minetest.set_node(pos, {name = "air"})
			end
		end
		
																	-- x1 y0 z0
		else if node.drawtype== "liquid" then
			pos.x=pos.x+2

			---pos.z=pos.z1
			if node.drawtype== "liquid" then
			minetest.set_node(pos, {name = "air"})
			end
		end
		
																	-- x-1 y0 z-1
		else if node.drawtype== "liquid" then
			pos.x=pos.x-2

			pos.z=pos.z-1
			if node.drawtype== "liquid" then
			minetest.set_node(pos, {name = "air"})
			end
		end
		
																	-- x0 y0 z-1	
		else if node.drawtype== "liquid" then
			pos.x=pos.x+1

			---pos.z=pos.z1
			if node.drawtype== "liquid" then
			minetest.set_node(pos, {name = "air"})
			end
		end
		
																	-- x1 y0 z-1
		else if node.drawtype== "liquid" then
			pos.x=pos.x+1

			---pos.z=pos.z1
			if node.drawtype == "liquid" then
			minetest.set_node(pos, {name = "air"})
			end
		end
		else
		print("no hay agua :D")
		end
end,

libahunt
Member
Posts: 14
Joined: Tue Aug 19, 2014 09:54
In-game: libahunt
Location: Barcelona
Contact:

Re: Ayuda con una funcion :/

by libahunt » Post

Ya solucione el problema de la antorcha :D
pero ahora me surge otro, al querer hacer una función que de un numero aleatorio no consigo hacerlo! ese numero tendría que ser el return de la función...

Code: Select all

local mat = {}

function mat.aleatorio(num1, num2)
if num1 >= num2 then
    print ("el primero numero no puede ser mayor o igual al segundo!")
end
math.randomseed(os.time())
while true do
    return math.random(num1, num2)
end

end
PD: Para la antorcha aun no e conseguido encontrar el metodo que añada la antorcha al inventario al quitarla :/

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests