Basics of Writing Code 9 Practice Time in Verse | Fortnite Documentation |...

This is code that is copied directly from the Basics of Writing Code 9 Practice Time in Verse at the bottom of the page. Everything was going fine with the documentation up to this point. When you copy and paste it to Visual Studio Code, it’s lines and lines of errors that I can not figure out how to get rid of. I tried the correct indentation of if and then and all the other scopes, nothing. PLEASE tell me how to fix these errors. I’ve been trying to figure this out for hours!

using { /Fortnite.com/Devices }

using { /Verse.org/Simulation }

using { /UnrealEngine.com/Temporary/Diagnostics }

using { /Fortnite.com/Characters }

using { /Fortnite.com/Playspaces }

using { /UnrealEngine.com/Temporary/SpatialMath }

hello_world_device := class(creative_device):

# Runs when the device is started in a running game

OnBegin():void=

Playspace:fort_playspace = GetPlayspace()

AllPlayers:\[\]player = Playspace.GetPlayers()



var FirstPosition:transform = transform{}

var SecondPosition:transform = transform{}



if:

    Player:player = AllPlayers\[0\]

    FortniteCharacter:fort_character = Player.GetFortCharacter\[\]

    set FirstPosition = FortniteCharacter.GetTransform()

then:

    Print("Move or prepare to take damage!")

    Sleep(10.0)



if:

    Player : player = AllPlayers\[0\]

    FortniteCharacter : fort_character = Player.GetFortCharacter\[\]

    set SecondPosition = FortniteCharacter.GetTransform()

    DistanceBetweenPositions: float = DistanceXY(FirstPosition.Translation, SecondPosition.Translation)

    DistanceBetweenPositions < 10000.0

then:

    Print("Distance Moved: {DistanceBetweenPositions}")

    Print("Applying Damage")

    HurtPlayer(50.0)

# Functions From Previous Lessons

#################################

HurtPlayer(DamageAmount : float):void=

Playspace: fort_playspace = GetPlayspace()

AllPlayers: \[\]player = Playspace.GetPlayers()

if (Player : player = AllPlayers\[0\]):

    if (FortniteCharacter : fort_character = Player.GetFortCharacter\[\]):

        MyCharacterHealth : float = FortniteCharacter.GetHealth()

        DamageToDo : float = CalculateDamage(MyCharacterHealth, DamageAmount, 1.0)

        Print("Damage To Do: {DamageToDo}")

        FortniteCharacter.Damage(DamageToDo)

CalculateDamage(PlayerHealth:float, DesiredDamageAmount:float, MinHealth:float):float =

\# If the damage amount would not eliminate the player, do that amount of damage

if (PlayerHealth > DesiredDamageAmount):

    return DesiredDamageAmount

else if (PlayerHealth > MinHealth):

    \# Give player one more chance if their health is low

    return PlayerHealth - MinHealth

else:

    \# Eliminate player

    return PlayerHealth

@Astonghini With the right indentation I was able to get the code without errors, could you specify what errors you are getting possibly? A screenshot might help.

Also how did you do that?!

Move all these to the right, they should be under hello_world_device also If you are reffering how I made them go to the right, I did that by pressing the TAB button on my keyboard

You are a life saver! Thank you!

1 Like