Page 1 of 1

[Mod] What is this? [whatisthis]

PostPosted: Sun Mar 05, 2017 18:17
by QwertyDragon
This is something worth being passed along.

09:42 Elon_Satoshi> I'm trying to find a minetest mod that allowed a command that would
identify the ID of whatever object you were holding
09:47 sfan5> that's pretty trivial
09:47 sfan5> might be easier to just write your own
09:53 nore> sfan5: it is possible to get the ID from lua?
09:53 Elon_Satoshi> sfan5: Hmm
09:53 Elon_Satoshi> sfan5: It was something like /whatisthis
09:53 sfan5> nore: i'm assuming he means the "default:sandstonebrick" thing
09:55 calculon> you can just use F5, it shows the id of the object you are pointing
09:55 nore> calculon: yes, pointing but not holding
09:55 nore> that's the problem
09:56 calculon> sure, that depends on what you really want
09:56 calculon> that's what i do to identify an object, drop it and see what it says
09:57 sfan5> Elon_Satoshi:
minetest.register_chatcommand("whatisthis",{func=function(name) return
true,"You are holding:
"..minetest.get_player_by_name(name):get_wielded_item():get_name() end})
10:03 Elon_Satoshi> sfan5: What's the func=function(name) part for?
10:03 sfan5> it defines the function that runs when you call the command
10:07 Elon_Satoshi> Thanks sfan5, it works
10:08 sfan5> like i said: trivial
12:48 QwertyDragon> sfan5 Can I pass that on to people with LGPL 2.1 as "sfan5" as author?
...He said yes.
...well, his exact words were:
12:48 sfan5> use whatever license you want, i don't care

So to use this just go into /minetest/mods and create folder called "whatisthis".
Inside folder /minetest/mods/whatisthis create a file named init.lua
and paste this:
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_chatcommand("whatisthis", {
   func=function(name)
   return true,"You are holding:"..
   minetest.get_player_by_name(name):get_wielded_item():get_name()
   end,
})


Also include a file readme.txt and paste:
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
whatisthis mod tells you what you are holding.
Author: sfan5
Licence: LGPL 2.1


Then go into /minetest/worlds/world
If the world you are using is "something-else"
Then go into /minetest/worlds/something-else
and add this line in world.mt file
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
load_mod_whatisthis = true


Now in game you have a new command that will tell you the
correct name of the item you are holding.
/whatisthis

Re: [Mod] What is this? [whatisthis]

PostPosted: Sun Mar 05, 2017 18:52
by octacian
Interesting, though simple, but why don't you provide this as an actual mod rather than having people copy-paste code?

Re: [Mod] What is this? [whatisthis]

PostPosted: Sun Mar 05, 2017 20:29
by QwertyDragon

Re: [Mod] What is this? [whatisthis]

PostPosted: Wed Mar 08, 2017 13:21
by azekill_DIABLO
;) +1