I want to make a pickaxe that gets progressively weaker as you use it. I learned I needed to create several versions of the pickaxes, but I don't know how to make the pickaxe swap out for an identical pickaxe with the same wear.
If someone could help, that would be nice.
Thank you!
How do you make items swap?
- Desour
- Member
- Posts: 1581
- 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: How do you make items swap?
There's set_tool_capabilities nowadays, so you don't need to register several picks.
For wear there's set_wear.
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)
- Linuxdirk
- Member
- Posts: 3416
- Joined: Wed Sep 17, 2014 11:21
- In-game: Linuxdirk
- Location: Germany
- Contact:
Re: How do you make items swap?
As I understand it, AndPherb wants a pickaxe that can crack very hard materials but after some time when it was worn, it cannot do that anymore.
Can we set tool capabilities via ItemStack metadata? Then this could be possible by writing a function in after_dig_node that checks wear value and adjusts the tool capacities accordingly.
Edit: Just checked. Yes, is possible.
Code: Select all
`ItemStackMetaRef`
------------------
ItemStack metadata: reference extra data and functionality stored in a stack.
Can be obtained via `item:get_meta()`.
### Methods
* All methods in MetaDataRef
* `set_tool_capabilities([tool_capabilities])`
* Overrides the item's tool capabilities
* A nil value will clear the override data and restore the original
behavior.
[...](And btw. that’s actually a cool idea!)
Who is online
Users browsing this forum: No registered users and 0 guests