I've tried many different ways to achieve this and seem to not be able to get anything to work. What I'm trying to do, is replace a broken tool from the players inventory into the active tools slot or main hand item. Where I keep getting stuck is moving the item to the active tool bar slot. What I have so far that works is:
Closest I've got was: (didn't cause errors, but doesn't work)
How do I get this item to swap to the active slot, main hand?
Sorry if this is simple, I've can't seem to get this to work and have most likely searched with the wrong terms for help.
[doublepost=1524463724,1524454097][/doublepost]It seems that the variable {_tool} is being changed from "wooden_pickaxe" (my testing tool) to "0 air". Is there a reason why this is happening, and is there anything I can do to fix this?
Solved:
Finished Code -
Closest I've got was: (didn't cause errors, but doesn't work)
code_language.skript:
on tool breaking:
# message "tool broke"
set {_tool} to event-item
# message "tool is %{_tool}%"
wait 2 ticks
if player's tool is empty:
# message "tool slot empty"
loop items in player's inventory:
# message "%loop-item%"
if loop-item is {_tool}:
message "found tool"
set loop-item to tool
How do I get this item to swap to the active slot, main hand?
Sorry if this is simple, I've can't seem to get this to work and have most likely searched with the wrong terms for help.
[doublepost=1524463724,1524454097][/doublepost]It seems that the variable {_tool} is being changed from "wooden_pickaxe" (my testing tool) to "0 air". Is there a reason why this is happening, and is there anything I can do to fix this?
code_language.skript:
on tool breaking:
message "%event-item% broke"
# message is "wooden_pickaxe broke"
set {_tool} to event-item
message "{_tool} is %{_tool}%"
# message is "{_tool} is wooden_pickaxe"
wait 2 ticks
if player's tool is empty:
message "tool slot empty"
# message is "tool slot empty"
message "%{_tool}% now is {_tool}"
# message is "0 air now is {_tool}"
message "event-item now is %event-item%"
# message is "event_item now is 0 air"
loop items in player's inventory:
message "loop-item : %loop-item%"
# message is "loop-item : wooden_pickaxe"
if loop-item is {_tool}:
message "found tool"
# no message
set loop-item to tool
Finished Code -
code_language.skript:
on tool break:
set {_tool} to id of event-item
wait 1 tick
if player's tool is empty:
loop items in player's inventory:
if loop-item's id is {_tool}:
set tool to the loop-item
clear the loop-item
exit the loop
Last edited: