travelVia crashes, moveTo doesn't work, and neither does setting the location property -- what the hell?

I have two simple Actors:

cop1: Actor 'tall cop; imposing muscular; police; him them'
    "..."
    isHim = true
;

+ copStanding: ActorState
    isInitState = true
;

cop2: Actor 'short cop; brutal thin sleek lithe; police; him them'
    "..."
    isHim = true
;

+ copStanding2: ActorState
    isInitState = true
;

They don’t start anywhere at all, just in the ether ready to be spawned in when the player inevitably does some property crime. So I have some code like this to spawn them in:

cop1.moveTo(megablockEntrance);
cop2.moveTo(megablockEntrance);

// or, another alternative I've tried:

cop1.travelVia(megablockEntrance, nil);
cop2.travelVia(megablockEntrance, nil);

// or, yet another alternative I've tried:

cop1.location = megablockEntrance;
cop2.location = megablockEntrance;

However, none of these options seem to work. The first and third ones just fail silently, leaving the cops’ location property unchanged and the cops themselves nowhere in sight, while the second one outright crashes with a “nil reference to object” error.

What am I missing? Thanks!

1 Like

The cops might need to be in a temporary secret room to use travelVia, because that method usually needs to refer to a previous room that is being traveled from.

I think actionMoveTo has a few more “do this like it would work in normal gameplay” details, compared to moveTo, but both of these might not necessarily report anything changing during gameplay, like travelVia would,

Unless I am completely misunderstanding something, because these should be changing the location property.

1 Like

Also, fun fact: Changing the location property only does one half of a location change. Locations know what is within themselves with the contents property, and moveTo is meant to change both the location property of the object and the contents property of the origin and destination.

Felt like this was worth bringing up, because I actually had a very similar bug a few months back, and discovered this is what was happening.

Stuck on mobile right now, so this is all from memory.

I have no idea why this isn’t working, though:

This won’t cause any text to appear in game, so it could happen silently, but if you checked the location properties afterward and they didn’t change to megablockEntrance, then I am royally stumped as well.

2 Likes

This won’t cause any text to appear in game, so it could happen silently, but if you checked the location properties afterward and they didn’t change to megablockEntrance, then I am royally stumped as well.

Yeah, not only did I check their location properties in-game, their special descriptions and stuff didn’t show up in the room description when I looked, and I couldn’t refer to them either, so I think that pretty conclusively shows that moveTo didn’t work.

Thanks for the other info though! It was enlightening.

1 Like

Is this adv3lite?

1 Like

Yeah

1 Like

How are you calling whatever’s doing the moveInto? Because it should work. Simple but complete example:

#charset "us-ascii"
#include <adv3.h>
#include <en_us.h>

DefineSystemAction(Foozle)
        execSystemAction() {
                alice.moveInto(startRoom);
                defaultReport('Bingo bango, Alice appears. ');
        }
;
VerbRule(Foozle) 'foozle': FoozleAction
        verbPhrase = 'foozle/foozling';

startRoom: Room 'Void' "This is a featureless void. ";
+me: Person;

alice: Person 'Alice' 'Alice'
        "She looks like the first person you'd turn to in a problem. "
        isProperName = true
        isHer = true
;

versionInfo: GameID;
gameMain: GameMainDef initialPlayerChar = me;

This starts the long-suffering Alice in a nil location and gives you a >FOOZLE action to move her into the starting (and only) room:

Void
This is a featureless void.

>foozle
Bingo bango, Alice appears.

>l
Void
This is a featureless void.

Alice is standing here.
2 Likes

I’m calling it from a callback to a Fuse, where the callback is a method of a Scene, if that helps

1 Like

If you’re using moveTo, that’s the problem because you need moveInto…

4 Likes

I think @johnnywz00 may have identified the problem, but using a Fuse shouldn’t matter:

#charset "us-ascii"
#include <adv3.h>
#include <en_us.h>

DefineSystemAction(Foozle)
        execSystemAction() {
                new Fuse(self, &bamf, 1);
                defaultReport('Bingo bango, Alice will appear. ');
        }
        bamf() {
                alice.moveInto(startRoom);
                defaultReport('Bango bingo, Alice has appeared. ');
        }
;
VerbRule(Foozle) 'foozle': FoozleAction
        verbPhrase = 'foozle/foozling';

startRoom: Room 'Void' "This is a featureless void. ";
+me: Person;

alice: Person 'Alice' 'Alice'
        "She looks like the first person you'd turn to in a problem. "
        isProperName = true
        isHer = true
;

versionInfo: GameID;
gameMain: GameMainDef initialPlayerChar = me;

Gives:

Void
This is a featureless void.

>foozle
Bingo bango, Alice will appear.

>z
Time passes...

>z
Time passes...

Bango bingo, Alice has appeared.

>l
Void
This is a featureless void.

Alice is standing here.

>
2 Likes

Mmmm that sounds like the solution! What’s the difference? Does moveTo move the thing to the same container as the object specified, so they’re siblings in the hierarchy then?

2 Likes

Well, I don’t see moveTo as being defined anywhere in Lite…

1 Like

Omg the name difference between moveTo and moveInto completely went past me. Excellent eye!

2 Likes

Huh, must’ve been misreading it this whole time. Wild.

3 Likes

Omg me too.

I just realized it affected how I wrote this reply.

2 Likes

This sort of thing is surprisingly insidious and I think it happens to everyone at some point. Usually multiple times.

For example I once asked a question here where the answer was “that’s not how you spell vocabLikelihood”.

4 Likes

there’s another, more subtle, issue with TADS’s notExactlyCamelcase: a ßtester pointed to me that I often fail to capitalise after a period; I was amazed in tracing this bug, whose is in my brain’s “TADS mode”, whose included watching for the uncommon capitalisation of methods &c, a watching whose evidently spilled into the text strings (I’m still figuring why also the syntax colouring fail its mission…)

Best regards from Italy,
dott. Piergiorgio.

2 Likes