[Mod] What is this? [whatisthis]

Post Reply
User avatar
QwertyDragon
Member
Posts: 20
Joined: Sat Dec 24, 2016 15:37
Contact:

[Mod] What is this? [whatisthis]

by QwertyDragon » Post

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:

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:

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

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
My GitLab, and Obior pages, and YouTube as QuixoticalPig, and Twitter as vuvvobUd. irc as QwertyDragon

User avatar
octacian
Member
Posts: 597
Joined: Mon Dec 21, 2015 22:18
GitHub: octacian
IRC: octacian
In-game: octacian
Location: Canada

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

by octacian » Post

Interesting, though simple, but why don't you provide this as an actual mod rather than having people copy-paste code?
MicroExpansion, Working Computers, All Projects - Check out my YouTube channel! (octacian)
I'm currently inactive in the Minetest community! So if I don't respond, that's why.

User avatar
QwertyDragon
Member
Posts: 20
Joined: Sat Dec 24, 2016 15:37
Contact:

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

by QwertyDragon » Post

My GitLab, and Obior pages, and YouTube as QuixoticalPig, and Twitter as vuvvobUd. irc as QwertyDragon

User avatar
azekill_DIABLO
Member
Posts: 7507
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

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

by azekill_DIABLO » Post

;) +1
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

Post Reply

Who is online

Users browsing this forum: No registered users and 33 guests