The first thing I wanted to try to do when I hopped into Verse was make player-specific variables. When I found out those weren’t a thing, I wanted to find a way to make them a thing. I haven’t tested this for multiple players but this should work if you throw in a for loop for each player’s index. I think it could also be modified using MaxHealth instead of Health if players die in the game and you don’t want the variables to reset. There’s a few things I want to clean up to make it a bit more robust but wanted to share!
For this example script the player variable is held in the hundredths digit of health. It should be able to store multiple variables using the different decimals place.
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Verse.org/Native }
using { /EpicGames.com/Temporary/Diagnostics }
using { /Verse.org/Simulation }
log_HealthVariables:=class(log_channel){}
HealthVariables := class<concrete>(creative_device):
Logger:log = log{Channel:=log_HealthVariables}
@editable
IncreaseVariableButton:button_device = button_device{}
@editable
CheckVariableButton:button_device = button_device{}
OnBegin<override>()<suspends>:void=
IncreaseVariableButton.InteractedWithEvent.Subscribe(IncreaseVariable)
CheckVariableButton.InteractedWithEvent.Subscribe(CheckVariable)
IncreaseVariable(Player:player):void=
allPlayers:[]player = GetPlayers()
if (fortCharacter:fort_character = allPlayers[0].GetFortCharacter[]):
fortCharacter.SetHealth(fortCharacter.GetHealth()-0.01)
Logger.Print("Character has {fortCharacter.GetHealth()} health")
CheckVariable(Player:player): void =
allPlayers:[]player = GetPlayers()
if (fortCharacter:fort_character = allPlayers[0].GetFortCharacter[]):
var health : float = fortCharacter.GetHealth()
var highernum : int = 0
if{set highernum = Round[health*100]}
var lowernum : int = 0
if{set lowernum = (Round[health])*100}
Logger.Print("Variable: {(highernum-lowernum)*-1}")