dobjFor(search) acting correctly?

I have a hidden door implemented as follows:

hiddenCave:HiddenDoor{ name = 'hidden door' location = eastSideOfHill }

The other side of that door is properly put in, I think:

hiddenCaveInside: HiddenDoor{ name = 'hidden door' location = backDoorEntrance masterObject = hiddenCave }

After this, I have the following brush item implemented as a means of concealing the door:

brush: Immovable vocabWords = 'brush/bushes' name = 'brush' location = eastSideOfHill initDesc = "flavor text" description = "flavor text dobjFor(search){ hiddenCave.discover() hiddenCave.isOpen(true) // just to be sure } }

Everything compiles. When I run, and search the brush, “there is nothing special about the brush.”

Ugh! Help, please. Searching the documentation yielded no examples of modifying dobjFor(search), so I come to you good folks.

Thanks in advance for help. Apologies on advance for any typos. My only access to Internet is through my phone, so I’m retyping of this off of my computer screen.

Lots of little bugs and typos. To name a few:

  • dobjFor(Search) with capital letter.
  • HiddenDoor does not have discover() method, HiddenDoor is visible when open, invisible when closed.
  • Use makeOpen(true) and makeOpen(nil) instead of isOpen() which is onl for checking the status of door.
  • Link compass direction to door or give vocabWords to the door, otherwise you won’t have any chance to go through
  • Say something about the discovery of the door, othervise you won’t notice.

[code]#charset “utf-8”

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

versionInfo: GameID;

gameMain: GameMainDef
initialPlayerChar = me
;

eastSideOfHill: Room ‘room’ ‘room’
"Room. "

vocabWords = 'room'
south = hiddenCave

;

  • me: Actor;

  • hiddenCave: HiddenDoor
    vocabWords = ‘hidden door’
    name = ‘hidden door’
    ;

  • brush: Immovable
    vocabWords = ‘brush/bushes’
    name = ‘brush’
    initDesc = “flavor text”
    description = “flavor text”

    dobjFor(Search)
    {
    action()
    {
    "There is a secret door! ";
    hiddenCave.makeOpen(true);
    }
    }
    ;

backDoorEntrance: Room ‘room’ ‘room’
"Room. "
north = hiddenCaveInside
;

  • hiddenCaveInside: HiddenDoor -> hiddenCave
    name = ‘hidden door’
    vocabWords = ‘hidden door’
    ;[/code]

Got it! Thanks.

EDIT:
It worked in the test file. I copy pasted it into my code, and it’s telling me “error: expected “;”, but you found”{". This ; is supposed to be right after the action() call…

Fair warning, due to style requirements at my job for writing C++ code, I’ve developed a distaste for templates and am not using them. I feel that’s a part of my hugest problem here.

Should I overcome that and rewrite my code using the templates before it gets too large?

Ah, I’ve fixed my example, there should be semicolon after "There is a secret door! "; But error message reporting missing semicolon after action() seems to be a sign of missing includes at the top of your file (dobjFor … action construct is “propertyset” defined in the header file).

When not using property sets instead of writing dobjFor(Search) { action() { your code; }} you need to write actionDobjSearch() { your code; }. Writing dobjFor(Search) { your code; } is wrong in any case.

But yes, you definitely should use templates and macros and property sets and other features. They are part of what makes TADS especially tuned for the domain of text adventures. Eric explains all those features through the manuals and shows both ways of writing code. My understanding of the purpose of explaining both ways is to help understand these features and help start using them than giving you a choice to not using them :slight_smile:

Anyway, property sets, macros and templates make code in real game more structured and more readable while you save lots of typing and about any example you will find on the forum or elsewhere on the net use this coding style.

Ok, you mention that the missing semicolon error indicates a missing include of a header. I’ve split my code into multiple files. Would I need those includes at the top of each file, or just the first file mentioned as source in the .t3m? I’ve seen compilers that catch includes in initial files and extend and I was taking it for granted that TADS did this… I’ll put includes everywhere and see, I guess. :slight_smile: Thanks for the help.

Yup, that was it, works great now!

Just like in C++ you need to include header files in every source file, because just like in C++ every source file is compiled separately. Header files does not contain any actual code which will result in anything in compiled binary. Only definitions of macros and such which enable compiler to understand code in *.t file, therefore you need to include them in any file using them. As a standard I would include both adv3.h and en_us.h in every source file and on a rare occasion include other headers needed (for example date.h or bignum.h).