No Travel Without A Compass - TADS3.1

I would like my actor not to be able to travel in any direction from any room unless he has his compass. Can anyone think of a way to do this without having to use a TravelBarrier with every exit in every room :question:

RonG

The quickest way would be to modify the default TravelAction:

modify TravelAction execAction() { if (the actor performing the action doesn't have a compass) "You can't go anywhere without a compass. "; else inherited(); } ;

Unfortunately this also blocks UP and DOWN. Not sure about ENTER. Test and see. Maybe someone will provide a method to refine it so that only compass directions get blocked.

I recently tested the code included with this post topic. The result of compiling it was a very large number of errors. I tried a number of changes and read through the TADS manuals and had no luck in getting it to compile without errors. I also placed this batch near the top of the game coding but that made no difference.

I hope someone can see what’s wrong with it. :cry: :cry:

RonG

Can you post the errors?

At the risk of asking a really dumb question, did you literally copy the line:

  if (the actor performing the action doesn't have a compass)

If so, that would be the problem. I imagine bcressey meant you to translate into something like:

  if (!compass.isIn(gActor))

Apologies in advance if I’m just pointing out the obvious.

–Eric

Here’s the code as it now stands. Still getting a ton of errors. Will post errors on next post.


 Modify TravelAction
   execAction()
    {
     if(!compass.isIn(gActor))
      "You cannot go anywhere without a compass.";
     else
      inherited();
    }  
;

Here Are The Errors. line 38 is the execAction() line. The last error is where the compass is defined.>t3make -Fy “C:\Documents and Settings\Frenchy\Desktop\The Magic Forest\obj” -Fo “C:\Documents and Settings\Frenchy\Desktop\The Magic Forest\obj” -o “debug\The Magic Forest.t3” -a -D “LANGUAGE=en_us” -D “MESSAGESTYLE=neu” -v -d -statprefix <@> -statpct “system.tl” “adv3\adv3.tl” “The Magic Forest.t” -res “GameInfo.txt”
TADS Compiler 3.1.0 Copyright 1999, 2010 Michael J. Roberts
The Magic Forest.t(38): error:
An equals sign ‘=’ is required to separate the property name and its value; the
parser found “execAction” where the ‘=’ should go. Check the syntax and supply
the missing ‘=’.

The Magic Forest.t(39): error:
A property name was expected in the object definition, but the compiler found
“{” instead. Check for a missing semicolon at the end of the object
definition, and check for unbalanced braces prior to this line.

The Magic Forest.t(40): error:
A property name was expected in the object definition, but the compiler found
“if” instead. Check for a missing semicolon at the end of the object
definition, and check for unbalanced braces prior to this line.

The Magic Forest.t(40): error:
A property name was expected in the object definition, but the compiler found
“(” instead. Check for a missing semicolon at the end of the object
definition, and check for unbalanced braces prior to this line.

The Magic Forest.t(40): error:
A property name was expected in the object definition, but the compiler found
“!” instead. Check for a missing semicolon at the end of the object
definition, and check for unbalanced braces prior to this line.

The Magic Forest.t(40): error:
An equals sign ‘=’ is required to separate the property name and its value; the
parser found “.” where the ‘=’ should go. Check the syntax and supply the
missing ‘=’.

The Magic Forest.t(40): error:
Invalid expression; expected an integer value, a string value (in single or
double quotes), a symbolic name (such as a function, object, or property name),
a list constant enclosed in square brackets ‘[ ]’, or an expression in
parentheses ‘( )’, but found “.”.

The Magic Forest.t(40): error:
A property name was expected in the object definition, but the compiler found
“)” instead. Check for a missing semicolon at the end of the object
definition, and check for unbalanced braces prior to this line.

The Magic Forest.t(41): error:
A property name was expected in the object definition, but the compiler found
“You cannot go anywhere without a compass.” instead. Check for a missing
semicolon at the end of the object definition, and check for unbalanced braces
prior to this line.

The Magic Forest.t(42): error:
The compiler expected a function or object definition, but found “else”. Check
the syntax, and check for unbalanced braces ‘{ }’ and other syntax errors
preceding this line.

The Magic Forest.t(44): error:
The compiler expected a function or object definition, but found “}”. Check
the syntax, and check for unbalanced braces ‘{ }’ and other syntax errors
preceding this line.

The Magic Forest.t(772): error:
The symbol “compass” is already defined, so you cannot use it as the name of an
object here. This symbol is already being used as the name of a function or
property elsewhere in your program. Change the name to a unique symbol.

Errors: 12
Warnings: 0

t3make: error code 1

Build failed.
----- end build: Sat Jan 21 14:47:45 2012 -----

You’ve capitalized the word “modify”. T3 is case-sensitive.

Thanks a lot. That cleared it up. All those hours of suffering just for one little letter!

RonG