Is there a way to temporarily make the players hand stronger?

Post Reply
LC Creations
Member
Posts: 77
Joined: Mon Feb 18, 2019 02:53

Is there a way to temporarily make the players hand stronger?

by LC Creations » Post

I'm making a power rangers mod. I have functionality for the ranger to "morph", meaning to change into the power ranger form. There is also a function that allows them to "demorph" to go back to being a regular player. This is all done, but... when the player is morphed, I want them to have a stronger hand in combat then when they demorph I want their hand to become back to normal so it is no longer as strong as it was. Is there a way to change the strongness of a players hand when in game then change it back and if so how? Are there any work arounds? I want this to work on mods too. Basically on anything. I do not want to need a specific tool or craft item in the players hand to do this.

Skamiz Kazzarch
Member
Posts: 134
Joined: Fri Mar 09, 2018 20:34
GitHub: Skamiz
In-game: Skamiz
Location: la lojbaugag.

Re: Is there a way to temporarily make the players hand stronger?

by Skamiz Kazzarch » Post

From the lua API:

Code: Select all

Player Inventory lists
----------------------
* `hand`: list containing an override for the empty hand
    * Is not created automatically, use `InvRef:set_size`
    * Is only used to enhance the empty hand's tool capabilities
It combines a bit oddly with the parameters of held tools and I have not tried it for combat purposes yet, but that's probably a good starting point.

User avatar
AiTechEye
Member
Posts: 775
Joined: Fri May 29, 2015 21:14
GitHub: AiTechEye
Location: ¯\_(ツ)_/¯

Re: Is there a way to temporarily make the players hand stronger?

by AiTechEye » Post

you cant change the hand or item properties in gameplay, but you can replace them, i dont finding the function right now, but its somethig about set wield hand

User avatar
rubenwardy
Moderator
Posts: 6077
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: United Kingdom
Contact:

Re: Is there a way to temporarily make the players hand stronger?

by rubenwardy » Post

You can change the tool capability of the hand at any time, either by overriding that specific item or by replacing the item.

The ItemStack `set_tool_capabilities` method allows you to set the caps of a specific item. The hand inventory list contains a single slot, which is the player's hand item. The default player hand has an item name of "".

Code: Select all

-- untested
local inv = player:get_inventory()
local stack = inv:get_stack("hand", 1)
stack:set_tool_capabilities(caps)
inv:set_stack("hand", 1, stack)
Caps is a tool capability, as found in a tool registration. See the definitions of pick axes for examples

If that doesn't work, you may need to create the hand slot (inv:set_size) and put a stack in it
AiTechEye wrote:
Fri May 22, 2020 21:19
you cant change the hand or item properties in gameplay
This is false, see set_tool_capabilities

User avatar
AiTechEye
Member
Posts: 775
Joined: Fri May 29, 2015 21:14
GitHub: AiTechEye
Location: ¯\_(ツ)_/¯

Re: Is there a way to temporarily make the players hand stronger?

by AiTechEye » Post

rubenwardy wrote:
Fri May 22, 2020 21:39

The ItemStack `set_tool_capabilities` method allows you to set the caps of a specific item.
ohh this was something new to me :)

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests