[Mod] What is this? [whatisthis]

User avatar
QwertyDragon
Member
 
Posts: 11
Joined: Sat Dec 24, 2016 15:37
GitHub: QwertyDragon
IRC: QwertyDragon
In-game: QwertyDragon LittleBigBunny

[Mod] What is this? [whatisthis]

by QwertyDragon » Sun Mar 05, 2017 18:17

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
 

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

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

by octacian » Sun Mar 05, 2017 18:52

Interesting, though simple, but why don't you provide this as an actual mod rather than having people copy-paste code?
God isn't dead!

My Coolest Mods:
MicroExpansion, Working Computers, Interchangeable Hands

Check out my YouTube channel! (octacian)
 

User avatar
QwertyDragon
Member
 
Posts: 11
Joined: Sat Dec 24, 2016 15:37
GitHub: QwertyDragon
IRC: QwertyDragon
In-game: QwertyDragon LittleBigBunny

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

by QwertyDragon » Sun Mar 05, 2017 20:29

 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

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

by azekill_DIABLO » Wed Mar 08, 2017 13:21

;) +1
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
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 50 guests

cron