beforeAction hook not running?

I’ll try em!

Advisory: coming from an adv3 background, there’s a good chance connector may be nil if NestedRoom travel is involved. I wouldn’t call a prop of connector without first checking for nil.

 beforeTravel(trav,conn) {
    if(trav==gPlayerChar && conn && conn.destination.ofKind(OutdoorRoom)
   … }

Note that you don’t need if(conn.ofKind(OutdoorRoom)) since it’s covered by the second clause…

JWZ’s pet plug: make a macro for gPlayerChar and gPlayerChar.getOutermostRoom, on the order of gPC/gpc and gOR/gor… I’ve used them each about 600 times in my source…

1 Like

I’m pretty sure you won’t be able to cancel travel from the entering method. Do it on noteTraversal of the connector instead. Another advisory though!

If following mechanics in Lite are anything similar to adv3, you don’t want to cancel travel in noteTraversal either, if you have a sidekick/follower, because they will get sent ahead before your own travel is nixed! So you lose them. BeforeTravel seems the safest…

There are no stupid questions on this forum. This isn’t StackOverflow lol. These are perfectly reasonable questions that might even help a future explorer searching for a solution.

You’re valid!

It sounds like a valid difficulty to be going through, and you are very hard on yourself! :grin:

3 Likes

Hmm. But travelerEntering is so much more elegant! Dammit. I’ll have to think about a way around this.

2 Likes

TADS does give you options!

1 Like

It does indeed. It’s both extremely useful and somewhat overwhelming :grin:

2 Likes

Another caveat in beforeTravel… conn.destination could also be nil, so you’ll get a RTE if you use destination.prop without checking it first…

2 Likes

(today I learned)

2 Likes