Page 1 of 1

Command block clear hand command?

PostPosted: Tue Apr 01, 2014 19:41
by mcfan
Is there a command I can put into a command block to clear your hand so I could have a pressure plate you could step on to clear your hand?

PostPosted: Tue Apr 01, 2014 22:32
by PilzAdam
/pulverize

PostPosted: Tue Apr 01, 2014 23:03
by mcfan
That only pulverizes the item in your hand. I want one to pulverize your inventory.

PostPosted: Wed Apr 02, 2014 11:42
by mcfan
So is there no command for that? There is a button in the inventory+ mob that clears your hand and I wondered if that command could be used for a command block.

PostPosted: Wed Apr 02, 2014 12:23
by kaeza
You could create your own command.

P.S: There's a topic dedicated to modding questions.

PostPosted: Wed Apr 02, 2014 16:34
by mcfan
I'm terrible at creating commands though. I'm better at graphics and mod revision. Could you give me a idea of what I should do to make such a command?

...and I've posted on those before but no one ever answered. lol

PostPosted: Wed Apr 02, 2014 16:43
by rubenwardy
Not everyone reads that topic.
It ruins the point of a forum, IMO.

Get an inventory: https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L1429

The inventory table: https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L1855

Set lists: https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L1868

Maybe something like inv:set_lists(nil)

PostPosted: Wed Apr 02, 2014 20:09
by Casimir

PostPosted: Wed Apr 02, 2014 21:29
by mcfan
I know how to pulverize Casimir but I want a command that clears the whole inventory. Like the "clear" button in the inventory mod.

PostPosted: Wed Apr 02, 2014 21:48
by CraigyDavi
Firstly you can create a chatcommand, this is a starter:
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("clearinv", {


Then when they type it it clears their inventory, you can use this code:
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
player:get_inventory():set_list("main", {})

PostPosted: Thu Apr 03, 2014 01:45
by mcfan
Ok, trying it now.

PostPosted: Thu Apr 03, 2014 17:23
by mcfan
Didn't work. Posting the error soon.

PostPosted: Fri Apr 04, 2014 11:40
by mcfan
21:49:06: ERROR[main]: ========== ERROR FROM LUA ===========
21:49:06: ERROR[main]: Failed to load and run script from
21:49:06: ERROR[main]: /usr/share/minetest/builtin/builtin.lua:
21:49:06: ERROR[main]: /usr/share/minetest/builtin/chatcommands.lua:690: attempt to index global 'player' (a nil value)
21:49:06: ERROR[main]: stack traceback:
21:49:06: ERROR[main]: /usr/share/minetest/builtin/chatcommands.lua:690: in main chunk
21:49:06: ERROR[main]: [C]: in function 'dofile'
21:49:06: ERROR[main]: /usr/share/minetest/builtin/builtin.lua:23: in main chunk
21:49:06: ERROR[main]: =======END OF ERROR FROM LUA ========

PostPosted: Fri Apr 04, 2014 12:06
by Calinou
I think you need to replace "player" in the 2nd line with the player name of the person who typed it.

Such a command should be added to the default game, though; it's tedious to pulverize all your inventory by hand.

Re: Command block clear hand command?

PostPosted: Fri Aug 08, 2014 20:58
by ronan_patrick
The command for clearing your entire inventory is "/clear".
In the command block, try "/clear @p"

Re: Command block clear hand command?

PostPosted: Fri Aug 08, 2014 21:42
by Evergreen
ronan_patrick wrote:The command for clearing your entire inventory is "/clear".
In the command block, try "/clear @p"

eh, this is not minecraft. :P

Re: Command block clear hand command?

PostPosted: Sat Aug 09, 2014 13:44
by Krock
ronan_patrick wrote:The command for clearing your entire inventory is "/clear".
In the command block, try "/clear @p"

Soulation above, /pulverize

Re: Command block clear hand command?

PostPosted: Sat Jun 20, 2015 00:32
by minermoder27
Untested, but here goes:

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
core.register_chatcommand("pulverizeall", {
   description = "Pulverize inventory",
   func = function(name, param)
      local player = core.get_player_by_name(name)
      player:get_inventory():set_list("main", {})
      return true, "An inventory was pulverized."
   end,
})