Room description after player change (setPlayer)

I’m switching the player character and forcing a look with .lookAround() [the red part], to reflect the change to the user.

But this is odd: something like a half-switch.

Am I missing something?

[size=85]The code reflecting the problem:[/size]

[spoiler][code]#charset “utf-8”

//
// Tested with frobtads-1.2.3

#include <adv3.h>
#include <en_us.h>

versionInfo: GameID
;

gameMain: GameMainDef
initialPlayerChar = alice
change_player_test(actor) {
"

DEBUG: Changing the player to <<actor.name>>.

";
setPlayer(actor);
"

DEBUG: Player changed to <<gPlayerChar.name>>.

";
"

DEBUG: Let’s look.

";
gPlayerChar.lookAround(gameMain.verboseMode.isOn);
}
;

alice_house: Room
roomName = ‘A house’
desc = "Alice’s house, take the foo to become Bob. "
;

  • foo: Thing
    noun = ‘foo’
    name = ‘foo’
    actionDobjTake(){
    gameMain.change_player_test(bob);
    }
    ;
  • alice: Actor
    noun = ‘alice’
    name = ‘alice’
    isProperName = true
    isHer = true
    ;

bob_house: Room
roomName = ‘B house’
desc = "Bob’s house. "
;

  • bar: Thing
    noun = ‘bar’
    name = ‘bar’
    ;
  • bob: Actor
    noun = ‘bob’
    name = ‘bob’
    isProperName = true
    isHim = true
    ;
    [/code][/spoiler]

When I was messing around with changing characters in my test environments, I got similar results with lookaround. I ending up using replaceActorAction(gPlayerChar,Look). That appeared to fix the half swap that I received.

Your code looks ok to me though.

Thanks, DavidPT.

Your replaceActorAction workaround works fine. As a workaround, I’ve found more semantic newActorAction [run a new action with a specific actor], because I’m not exactly replacing an action.

newActorAction(gPlayerChar, Look);

Reported to the TADS bugs database: #0000210

That will lead to the wrong actor being used for the next turn. It will be correct for ever turn after that though. It is for that oddity that I used replace instead of new.

Maybe your case is more complex but I can’t reproduce the oddity with new.

A slightly modified code follows. It uses the newActorAction workaround and starts with the bar in Bob’s inventory (listed correctly in the next turn):

[spoiler][code]#charset “utf-8”

#include <adv3.h>
#include <en_us.h>

versionInfo: GameID
;

gameMain: GameMainDef
initialPlayerChar = alice
change_player_test(actor) {
"

DEBUG: Changing the player to <<actor.name>>.

";
setPlayer(actor);
"

DEBUG: Player changed to <<gPlayerChar.name>>.

";
"

DEBUG: Let’s look.

";
//
// BAD: gPlayerChar.lookAround(gameMain.verboseMode.isOn);
//
// Workaround:
newActorAction(gPlayerChar, Look);
}
;

alice_house: Room
roomName = ‘A house’
desc = "Alice’s house, take the foo to become Bob. "
;

  • foo: Thing
    noun = ‘foo’
    name = ‘foo’
    actionDobjTake(){
    gameMain.change_player_test(bob);
    }
    ;
  • alice: Actor
    noun = ‘alice’
    name = ‘alice’
    isProperName = true
    isHer = true
    ;

bob_house: Room
roomName = ‘B house’
desc = "Bob’s house. "
;
+bob: Actor
noun = ‘bob’
name = ‘bob’
isProperName = true
isHim = true
;
++ bar: Thing
noun = ‘bar’
name = ‘bar’
;[/code][/spoiler]

I’ll take into account your experience, just in case the oddity bites me.

Again, thanks for your comments.