actorState with Player object v2.0

I recently updated to the latest version of adv3lite and am getting an error when adding a state to the player object. The error is “nil object reference” and it links to the actor.t file → if(getActor.allStates == nil).

When I switch the me object back to actor, the code compiles fine.

I read in the change log that new games should use the Player object for the PC from this point forward. I’ve been kicking around with this game for a while but I would still consider it new.

Also, the game compiles fine on a Mac using VSCode and Parchment. When I’m at another location sometimes referred to as “work”, I have access to a PC running Workbench. :slight_smile:

Thank you in advance.
Deborah

2 Likes

The second problem is simple: macOS, uses < LF> (line feed) as end-of-line terminator, and windoze uses the < CR>< LF> pair (wasting a byte for every line, as usual for the corporation behind that “os”…)

Best regards from Italy,
dott. Piergiorgio.

Can you be more specific about the circumstances of this error? When I tried it just now, simply adding an ActorState to the player character object defined with the Player class didn’t generate an error.

It’s also puzzling that you’d get the error with Player but not Actor, since the Player class is defined as:

class Player: Actor
    isFixed = true
    person = 2
    isInitialPlayerChar = true    
    isProper = true
;

So there’s nothing in there that would obviously make ActorStates work any differently from how they do on the Actor class; this admittedly doesn’t totally rule out the possibility of some obscure bug, but again make me wonder about the circumstances under which it can be occurring.

Finally, does the player character change in the course of your game so that the initial player character later becomes an NPC? If so, then there may well be a need to add one or more ActorStates to the initial player character, but if not then I’m not sure what you’d be trying to achieve with them.

That all said, the error you’re getting suggests that getActor is nil during the ActorState initialization, which suggests to me that the ActorState may not have been properly located within the player character object. I get precisely the error you get if I do this:

drive: Room 'Drive'
    "A house with a plain front door lies to the north. Next to the door is a prominent brass
    doorbell. A path leads off to the west, or you could continue southwards down the drive to the
    street. "
    
    west = gardenPath
    south = driveCon
;

+ fred:Actor 'Fred'
;

+ fredState: ActorState
;

This is because here fredState is incorrectly located in the drive location instead of the fred Actor. Is it possible you made a similar error when trying placing an ActorState in your player character?

1 Like

I have the player in its own file and all the states are added beneath it like so:

me: Player 'you; young pretty;girl;her' @tinyShack 
"You\'re by far the loveliest of the bunch, with cornsilk blonde hair and crystal blue eyes. "
    isHer = true
    ContType = Carrier
;
+ amalieSittingState: ActorState
    isInitState = true
    specialDesc = ""
    stateDesc = "You're sitting near a hearth with an empty soup bowl and wooden spoon in your lap, waiting for supper. "
;

+ amalieGirlsRoomState: ActorState
    specialDesc = ""
    stateDesc = "Sleepily, you head towards you bed. ";
;

It could be when I change states maybe?

girlsRoomScene: Scene
    startsWhen = (gRevealed('amalieAgrees') == true)
    whenStarting() {
        me.moveInto(girlsRoom);
        me.setState(amalieGirlsRoomState);
    }
    endsWhen(){
        me.isIn(bed);
    }
;
1 Like

I just tried changing ActorState between two states defined on the player character, and that didn’t give me an error.

But it occurs to me that one other thing that could cause the error you report would be if you were compiling your game with a version of adv3Lite prior to 2.0. In earlier versions of adv3Lite the Player class descended directly from Thing rather than Actor, as it does in 2.0. Locating an ActorState in a Thing (that’s not an Actor) would cause the error you reported.

2 Likes

or, is possible that dsherwood has compiled against 2.0 library without rebuilding ?

Dsherwood, you can try t3make -a -f (that is, rebuilding the .obj files) ?

my 0,02 € and
Best regards from Italy,
dott. Piergiorgio.

1 Like

Hi,

It happens when I chose to create a new game using the Adv3lite - WebUI in the workbench.
I just tested it.

Also, one thing I have noticed between using the workbench vs using vscode on Mac, when a player types a SAY command and I don’t have anything implemented for it, the output is “Character name does.” on the Mac but in work bench the output is “Character name does not respond.”

That’s been bothering me for a while and I figured I would get to it soon but since I have your attention… :slight_smile:

Deborah

I just tried that, and I still didn’t get this error. (There is a Workbench instability with the WebUI interface, but that appears to be a Workbench issue - it occurs with adv3 as well - so I don’t think it’s anything to do with the error you’re getting).

I suggest the next thing for you to look at is the definition of the Player class in your copy of the library, It should be defined in thing.t and begin with:

class Player: Actor

If that’s not the case for you then somehow your library files have got out of sync, or you’re using a pre version 2.0 version of the library.

I don’t have a Mac so I can’t test this (I get what you get on Workbench). I’ve no idea why you’re getting what you get using vscode on a Mac, unless it’s again picking up a different version of the library files. The message in question comes from the following line in actor.t:

noResponseMsg = BMsg(no response, '{The subj cobj} {doesnot respond[ed]}. ')

But you’d get what you’re seeing on the Mac if it instead said:

noResponseMsg = BMsg(no response, '{The subj cobj} {does not respond[ed]}. ')

(There is incidentally an error in the library manual here which I need to fix, since it suggests the latter form, whereas the former is correct).

Again, perhaps you could check what library files your Mac setup is picking up. The handling of a SAY command when nothing was defined for it was changed in v 1.6.

ok thank you - I am going to try your suggestions and possibly uninstall then reinstall in the morning on all platforms.

I appreciate your help.
Deborah

This is from the actor.t file. This is what it should be, correct?

    noResponseMsg = BMsg(no response, '{The subj cobj} {doesnot respond[ed]}. ')

Then I found another adv3lite directory in my TADS folder. DOH!

    noResponseMsg = BMsg(no response, '{The subj cobj} {does not respond[ed]}. ')

The adv3lite folder should be in a folder called “extensions” in the TADS folder, right?
Is there a place to check what version this copy is?

The first noResponseMsg is the correct one.

That’s what I’d recommend. You’d need to tell both Workbench and VSCode where to find it, so it looks like they’re using different library versions, which indeed probably explains the errors you’ve been getting (from referencing an older version of the library).

1 Like