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.
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”…)
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?
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. ";
;
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.
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…
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:
(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.
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).