I have imported custom pickaxes and as I am relatively new to Verse I’m having some trouble with this code. I want to hide the custom pickaxe when a player swaps to a weapon in their inventory and show the custom pickaxe when they swap back to their melee. Though I can’t seem to figure out why its not working as intended. Code below:
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
WeaponChecker := class():
@editable Conditional : conditional_button_device = conditional_button_device{}
@editable VFX : visual_effect_powerup_device = visual_effect_powerup_device{}
Equip(Agent:agent) : void=
VFX.Pickup(Agent)
CustomAxePlayer := class():
Player : player
var CustomAxeDevice : WeaponCheckerManager = WeaponCheckerManager{}
var AllWeapons : WeaponChecker = array {}
var ClearTrigger : trigger_device = trigger_device{}
Initiate() : void=
spawn:
CheckWeapons()
CheckWeapons()<suspends> : void=
race:
block:
loop:
Sleep(0.0)
LeavingPlayer := CustomAxeDevice.GetPlayspace().PlayerRemovedEvent().Await()
if(LeavingPlayer = Player):
break
loop:
Sleep(0.0)
var IsWeaponFound : logic = false
for(Wep : AllWeapons):
if(Wep.Conditional.IsHoldingItem[Player]):
set IsWeaponFound = true
ClearTrigger.Trigger(Player)
if(IsWeaponFound = false):
Wep.Equip(Player)
WeaponCheckerManager := class(creative_device):
var PlayersMap : [player]CustomAxePlayer = map {}
@editable AllWeapons : []WeaponChecker = array {}
@editable ClearTrigger : trigger_device = trigger_device{}
OnBegin<override>()<suspends>:void=
for(Player : GetPlayspace().GetPlayers()):
Initialize(Player)
GetPlayspace().PlayerAddedEvent().Subscribe(Initialize)
Initialize(Player : player) : void=
if(PlayerExists := PlayersMap[Player]):
else:
if:
set PlayersMap[Player] = CustomAxePlayer{
Player := Player
CustomAxeDevice := Self
AllWeapons := AllWeapons
ClearTrigger := ClearTrigger
}
CP := PlayersMap[Player]