Ayuda con una funcion :/

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

Ayuda con una funcion :/

by libahunt » Sun Nov 16, 2014 12:27

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!!!

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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

Re: Ayuda con una funcion :/

by libahunt » Fri Nov 21, 2014 00:50

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...

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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 :/
 


Return to Español

Who is online

Users browsing this forum: No registered users and 1 guest

cron