Solution for Verse Persistence Issue: unique specifier on classes that lack the allocates effect

using @CHENSHUO.L solution, here is the corrected commands.verse from the Verse Commander tutorial:

command := class<computes><abstract>:
    DebugString()<transacts>:string

# The Commands module contains definitions of commands that the NPC can perform.
# This example uses instances of command subclasses instead of the enum type
# so you can add more commands after the initial published version of the project.
Commands := module:
    # The following are subclasses of the command class
    # that implement the abstract command class and define what commands are valid.
    # Each has their own implementation of DebugString(), for example,
    # so when you print a command value it has the correct string associated with it.
    # Since the command class is abstract, it means these subclasses are the only valid commands,
    # otherwise there will be a compiler error.
    forward_command<public> := class<computes>(command):
        DebugString<override>()<transacts>:string = "Forward"

    turnright_command<public> := class<computes>(command):
        DebugString<override>()<transacts>:string = "TurnRight"

    turnleft_command<public> := class<computes>(command):
        DebugString<override>()<transacts>:string = "TurnLeft"
        
    # Instances of each command type that can be used in the minigame.
    Forward<public>:forward_command = forward_command{}
    TurnRight<public>:turnright_command = turnright_command{}
    TurnLeft<public>:turnleft_command = turnleft_command{} 

# Convert the command data to a string to be able to print it when debugging issues.
# For example, Print("Player selected {Command} command.")
ToString(Command:command):string=
    Command.DebugString()

Also, in the verse_commander_character.verse file:

            # If the command is forward, create a new navigation target from the target tile.
            if:
                Command.DebugString() = Commands.Forward.DebugString()
            then:
                NavTarget := MakeNavigationTarget(TargetTile.Translation)
                # Navigate the character to the navigation target. The ReachRadius is set to a small float
                # here rather than zero to allow the character a small leniency in how close it needs to get to the 
                # exact position of the target.
                NavResult := Navigatable.NavigateTo(NavTarget, ?ReachRadius := ReachRadius)
            # If the command is right or left, force the character to maintain focus on the taget for
            # a short period of time to turn the character to face that target.
            else if:
                Command.DebugString() = Commands.TurnLeft.DebugString() or Command.DebugString() = Commands.TurnRight.DebugString()

You should then be able to do the same with the ui_manager.verse file!

1 Like