[mod] Display All Installed Nodes (for design and building)

dgm5555
Member
 
Posts: 244
Joined: Tue Apr 08, 2014 19:45

[mod] Display All Installed Nodes (for design and building)

by dgm5555 » Sun Feb 22, 2015 13:23

The code excludes lava water and fire from display (else it obscures your view, or combusts everything)
just paste it into an init.lua file in a directory of your choice, or extract the zip file
https://dl.dropboxusercontent.com/u/21225632/displayallnodes.zip
BTW in 0.4.11 debug (F5) tells which node you're pointing at if you want to identify them

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 displayAllNodes = function(pos)
   local nodeCount = 0
   -- key is node name, eg default:stone   value is definition table
   for key, value in pairs(minetest.registered_nodes) do
      print (key)         
      nodeCount = nodeCount + 1
   end

   local manip = minetest.get_voxel_manip()
   minetest.chat_send_all("placing".. nodeCount.. " nodes")

   local curY = pos.y + math.sqrt(nodeCount * 2)
   local curX = pos.x
   local curZ = pos.z
   local startX = pos.x
   local startZ = pos.z
   local curRowMax = 1
   local rowCount = 1

   for key, value in pairs(minetest.registered_nodes) do         

      if ((string.find(key,"lava") == nil) and (string.find(key,"fire")) == nil and (string.find(key,"water") == nil) and (string.find(key,"air") == nil)) then
         local p = {x=curX, y=curY, z=curZ}
         manip:read_from_map(p, p)
         minetest.env:add_node(p, {name=key})
         -- use the voxelmanip to fix lighting problems
         manip:calc_lighting()

         rowCount = rowCount + 1
      
         if rowCount > curRowMax then
            rowCount = 1
            curRowMax = curRowMax + 1   --2
            --startX = startX - 1
            startZ = startZ - 1
            curY = curY - 1
            curX = startX
            curZ = startZ
         else
            curX = curX + 1
            curZ = curZ + 1
         end
      end
   end
   return true
end

minetest.register_chatcommand("/dan", {
   params = "",
   description = "Display All registered Nodes",
   func = function(name, param)
      local pos = minetest.get_player_by_name(name):getpos()
      pos.x, pos.y, pos.z = math.floor(pos.x + 0.5), math.floor(pos.y + 0.5), math.floor(pos.z + 0.5)

      displayAllNodes(pos)
      return true
   end,
})



In the foreground is minetest_game, and the background is with moreblocks included
Image
Image



EDIT: This was my original post, left for posterity

I'd really like a mod which can place every registered node in a game so I can view them.
I'm considering making one, but don't know how to list all registered nodes.
I know there is minetest.registered_nodes[nodename], but that's indexed by name. As a start, I want a list I can iterate through to return the names.
Does anyone know how to do that (or can supply code to get me more or less of the way along)?
Last edited by dgm5555 on Sun Mar 01, 2015 17:58, edited 3 times in total.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: How can I list or place all installed nodes?

by rubenwardy » Sun Feb 22, 2015 13:42

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
for key, value in ipairs(minetest.registered_nodes) do
      -- key is node name, eg default:stone
      -- value is definition table
end
 

User avatar
Bas080
Member
 
Posts: 398
Joined: Mon May 21, 2012 15:54
GitHub: bas080
IRC: bas080
In-game: bas080

Re: How can I list or place all installed nodes?

by Bas080 » Sun Feb 22, 2015 16:54

I could use this when working on my OCD texture/nodebox-pack. Could you place the node in a slanted/diagonal fassion. The same way you often see when texture packs are presented? Or was that not your intention for this mod?
 

dgm5555
Member
 
Posts: 244
Joined: Tue Apr 08, 2014 19:45

Re: How can I list or place all installed nodes?

by dgm5555 » Sun Feb 22, 2015 18:20

This is my code to create the chat command ('/dan')
It should create an inverted pyramid starting above the players head and going out and down, but
Unfortunately the for loop doesn't work, it returns a node count of 0, so I'm no further on...

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 displayAllNodes = function(pos)
   local nodeCount = 0
   -- key is node name, eg default:stone   value is definition table
   for key, value in ipairs(minetest.registered_nodes) do
      print (key)         
      nodeCount = nodeCount + 1
   end

   local manip = minetest.get_voxel_manip()
   minetest.chat_send_all("placing".. nodeCount.. " nodes")

   local curY = pos.y + math.sqrt(nodeCount * 2)
   local curX = pos.x
   local curZ = pos.z
   local startX = pos.x
   local startZ = pos.z
   local curRowMax = 1

   for key, value in ipairs(minetest.registered_nodes) do         

      local p = {x=curX, y=curY, z=curZ}
      manip:read_from_map(p, p)
      minetest.env:add_node(p, {name=key})

      local rowCount = rowCount + 1
      
      if rowCount > curRowMax then
         rowCount = 1
         curRowMax = curRowMax + 2
         startX = startX - 1
         startZ = startZ - 1
         curY = curY - 1
         curX = startX
         curZ = startZ
      else
         curX = curX + 1
         curZ = curZ + 1
      end
   end
   return true
end

minetest.register_chatcommand("/dan", {
   params = "",
   description = "Display All registered Nodes",
   func = function(name, param)
      local pos = minetest.get_player_by_name(name):getpos()
      pos.x, pos.y, pos.z = math.floor(pos.x + 0.5), math.floor(pos.y + 0.5), math.floor(pos.z + 0.5)

      displayAllNodes(pos)
      return true
   end,
})

 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: How can I list or place all installed nodes?

by rubenwardy » Sun Feb 22, 2015 19:13

try pairs rather than ipairs, maybe (ipair cancels when it gets to nil)
 

dgm5555
Member
 
Posts: 244
Joined: Tue Apr 08, 2014 19:45

Re: How can I list or place all installed nodes?

by dgm5555 » Sun Feb 22, 2015 20:41

That worked. thanks - and dropped a pillar of lava on my head :-(
The code now excludes lava and water from display
just paste it into an init.lua file in a directory of your choice
BTW in 0.4.11 debug (F5) tells which node you're pointing at if you want to identify them

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 displayAllNodes = function(pos)
   local nodeCount = 0
   -- key is node name, eg default:stone   value is definition table
   for key, value in pairs(minetest.registered_nodes) do
      print (key)         
      nodeCount = nodeCount + 1
   end

   local manip = minetest.get_voxel_manip()
   minetest.chat_send_all("placing".. nodeCount.. " nodes")

   local curY = pos.y + math.sqrt(nodeCount * 2)
   local curX = pos.x
   local curZ = pos.z
   local startX = pos.x
   local startZ = pos.z
   local curRowMax = 1
   local rowCount = 1

   for key, value in pairs(minetest.registered_nodes) do         

      if ((string.find(key,"lava") == nil) and (string.find(key,"fire")) == nil and (string.find(key,"water") == nil) and (string.find(key,"air") == nil)) then
         local p = {x=curX, y=curY, z=curZ}
         manip:read_from_map(p, p)
         minetest.env:add_node(p, {name=key})

         rowCount = rowCount + 1
      
         if rowCount > curRowMax then
            rowCount = 1
            curRowMax = curRowMax + 1   --2
            --startX = startX - 1
            startZ = startZ - 1
            curY = curY - 1
            curX = startX
            curZ = startZ
         else
            curX = curX + 1
            curZ = curZ + 1
         end
      end
   end
   return true
end

minetest.register_chatcommand("/dan", {
   params = "",
   description = "Display All registered Nodes",
   func = function(name, param)
      local pos = minetest.get_player_by_name(name):getpos()
      pos.x, pos.y, pos.z = math.floor(pos.x + 0.5), math.floor(pos.y + 0.5), math.floor(pos.z + 0.5)

      displayAllNodes(pos)
      return true
   end,
})



In the foreground is minetest_game, and the background is with moreblocks included
Image
Image
Last edited by dgm5555 on Sun Feb 22, 2015 20:57, edited 2 times in total.
 

User avatar
ExeterDad
Member
 
Posts: 1121
Joined: Sun Jun 01, 2014 20:00
In-game: ExeterDad

Re: How can I list or place all installed nodes?

by ExeterDad » Sun Feb 22, 2015 20:45

Strangely beautiful.
٩(̾●̮̮̃̾•̃̾)۶

Kibbie and I have a beautiful public server now! HOMETOWN
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: How can I list or place all installed nodes?

by rubenwardy » Sun Feb 22, 2015 21:20

BTW, you could write

local function display_all_nodes()

It does the same - assigns the function to a local variable.
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: [mod] Display All Installed Nodes (for design and buildi

by Hybrid Dog » Sat Mar 21, 2015 08:47

it tells me "placing3616 nodes", these nodes appear but then saplings and other stuff grows
Image
Attachments
afshdkjn.png
afshdkjn.png (329.33 KiB) Viewed 1141 times
 

dgm5555
Member
 
Posts: 244
Joined: Tue Apr 08, 2014 19:45

Re: [mod] Display All Installed Nodes (for design and buildi

by dgm5555 » Sun Mar 22, 2015 07:37

the mod just places blocks. if they've got abms (which i would have thought saplings probably have) they will then do whatever they'd normally do after being placed (eg grow.)
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 19 guests

cron