[SOLVED] First Mod - List all available nodes

MultiPlus
New member
 
Posts: 3
Joined: Fri Sep 16, 2016 10:27
GitHub: MultiPlus
In-game: MultiPlus

[SOLVED] First Mod - List all available nodes

by MultiPlus » Fri Sep 16, 2016 10:39

Hello everybody,

Today i make my first mod to test development MineTest. Il want to do a mod that lists all available nodes on game via mintetest.registered_nodes but it does not work...

I fallowed the exemples on this topic... https://forum.minetest.net/viewtopic.php?f=9&t=11294

List all :
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 pairs(minetest.registered_nodes) do
      minetest.debug("Node " .. key)       
   end

Nothing...

Or display count :
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.debug("Count " ..table.getn( minetest.registered_nodes))

Count 0


I do not have the lua file available, I send later.

Thx.
Last edited by MultiPlus on Fri Sep 16, 2016 17:27, edited 2 times in total.
 

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: First Mod - List all available nodes

by Wuzzy » Fri Sep 16, 2016 13:57

Please check the Lua API reference again.
Minetest.debug takes TWO arguments, the first one is for the message type, not the message itself.

Also, what's table.getn? I don't see it in the Lua documentation. I am surprised that it works in the first place. Did you maybe mean table.maxn? Well, check the Lua documentation again. It only shows the largest NUMERIC index. minetest.registered_nodes is indexed by itemstrings. There are no numeric indexes in this table, so the answer of this function is correct.

Note this function has been removed in later Lua versions (but not Lua 5.1), so I don't recommend to use it.
I'm creating MineClone 2, a Minecraft clone for Minetest.
I made the Help modpack, adding in-game help to Minetest.
 

MultiPlus
New member
 
Posts: 3
Joined: Fri Sep 16, 2016 10:27
GitHub: MultiPlus
In-game: MultiPlus

Re: First Mod - List all available nodes

by MultiPlus » Fri Sep 16, 2016 14:11

OK thank you for this information I look tonight.
 

MultiPlus
New member
 
Posts: 3
Joined: Fri Sep 16, 2016 10:27
GitHub: MultiPlus
In-game: MultiPlus

Re: First Mod - List all available nodes

by MultiPlus » Fri Sep 16, 2016 17:26

Perfect, thanks for your help.
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: First Mod - List all available nodes

by kaeza » Fri Sep 16, 2016 18:59

Wuzzy wrote:Also, what's table.getn? I don't see it in the Lua documentation.

IIRC, it's a function from 5.0, removed in 5.1. Its need was mostly replaced by the length operator (`#t`).
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 5 guests

cron