Problems with 'Bad markup expression preceding end of line' in Verse code.

I’m just starting to learn programming, but I don’t understand where the error is. Can someone help me? The context of what I’m trying to do is an AI that follows nearby players.


(here is all the code)
using { /Fortnite.com/Devices }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Simulation }
using { /Fortnite.com/Characters }

miniboss2 := class(creative_device):

@editable var Enemies : []creative_prop = array{}

var ClosestPlayer : player

# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
    Sleep(30.0)  # Espera 30 segundos
    InitEnemies()

InitEnemies():void=
    loop:
        Sleep(0.1)
        ClosestPlayer := FindClosestPlayer()
        if ClosestPlayer:
            for (X := 0..Enemies.Length - 1):
                if (Enemy := Enemies[X]):
                    spawn:
                        FollowPlayer(Enemy)

FindClosestPlayer(): player =
    ClosestPlayer := None
    ClosestDistance := float.max
    Players := GetPlayspace().GetPlayers()
    for (Player := Players):
        PlayerCharacter := Player.GetFortCharacter()
        if PlayerCharacter:
            PropLocation := PlayerCharacter.GetTransform().Translation
            for (X := 0..Enemies.Length - 1):
                if (Enemy := Enemies[X]):
                    EnemyLocation := Enemy.GetTransform().Translation
                    Distance := (EnemyLocation - PropLocation).Length()
                    if Distance < ClosestDistance:
                        ClosestPlayer := Player
                        ClosestDistance := Distance 
    return ClosestPlayer

FollowPlayer(Enemy : creative_prop)<suspends>:void=
    MoveSpeed := 0.03
    Sleep(0.1)
    if ClosestPlayer:
        PlayerCharacter := ClosestPlayer.GetFortCharacter()
        if PlayerCharacter:
            PropLocation := Enemy.GetTransform().Translation
            PlayerLocation := PlayerCharacter.GetTransform().Translation

            if (LookDirection := (PlayerLocation - PropLocation).MakeUnitVector()):
                Yaw := RadiansToDegrees(ArcTan(LookDirection.Y, LookDirection.X)) - 90.0
                Pitch := 0.0
                Roll := 0.0

                NewRotation := MakeRotationFromYawPitchRollDegrees(Yaw, Pitch, Roll)

                # Movement
                LerpLocation := Lerp(PropLocation, PlayerLocation, MoveSpeed)
                FinalLocation := vector3{X := LerpLocation.X, Y := LerpLocation.Y, Z := 0.0}

                Enemy.TeleportTo(FinalLocation, NewRotation)
    else:
        break

You have errors everywhere my friend, dunno if you copied this from someone or ChatGPT, but maybe learn Verse starting with beginner tutorials :+1:

ooh thank you, I am learning verse but it also helped me with the gpt chat. haha

1 Like

ChatGPT is not really good at doing Verse right now :person_shrugging:

It is true but it can be useful, it helped me with another code and the code works perfectly, you just have to be patient.