Change tool default range

Post Reply
User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Change tool default range

by texmex » Post

I've managed to increase the range of the hand (":") by range = 12, but whenever another item is wielded the range falls back to something undefined, some default. How do I make it so that the player always has a minimum range of, say, 12?

User avatar
Desour
Member
Posts: 1472
Joined: Thu Jun 19, 2014 19:49
GitHub: Desour
IRC: Desour
In-game: DS
Location: I'm scared that if this is too exact, I will be unable to use my keyboard.

Re: Change tool default range

by Desour » Post

he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: Change tool default range

by texmex » Post

What? Did you read my post? :P

User avatar
Krock
Developer
Posts: 4650
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: Change tool default range

by Krock » Post

Add the wieldhand item to the player's "hand" slot. Otherwise it will fall back to 4m because Minetest doesn't know what to do in case an item without specified range is selected.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: Change tool default range

by texmex » Post

Krock wrote:Add the wieldhand item to the player's "hand" slot. Otherwise it will fall back to 4m because Minetest doesn't know what to do in case an item without specified range is selected.
I don’t quite understand. I thought that was what I did. Are there extra steps past register_item(”:”)?

User avatar
Hybrid Dog
Member
Posts: 2834
Joined: Thu Nov 01, 2012 12:46
GitHub: HybridDog

Re: Change tool default range

by Hybrid Dog » Post

If I understand that code correctly, it should set the range to the wielded item's range if available.
If the wielded item's range is unavailable, it sets the range to the hand's range,
except if both are inavailable, then it sets the range to 4.

I think that code does not do what it should do. Either all items have a range implicitly set to 4 at another place in code (except items which had range set during minetest.register_item), or the hand inventory list does not actually contain a hand?

‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪

User avatar
Desour
Member
Posts: 1472
Joined: Thu Jun 19, 2014 19:49
GitHub: Desour
IRC: Desour
In-game: DS
Location: I'm scared that if this is too exact, I will be unable to use my keyboard.

Re: Change tool default range

by Desour » Post

texmex wrote:What? Did you read my post? :P
Of course I did.
I thought that creative does what you want.
I have questions for you:
Do you also use MTG?
What are you trying to do exactly? Do you want that items which have their range set to eg. 3 have a bigger range (probably not)?
(hand invlist in lua_api.txt)
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests