TADS 2: I'm just trying to make a cup of tea!

Shorah. First post.
I’m a bit new to TADS 2, and trying to implment a cup of tea. I need a water tap that pours water into a pot, a burner that boils the water, and a tea press that brews it. I’ve tried a simple “object.moveInto(place);” but I get weird errors.Help!

I’m much better versed in TADS 3 than 2, but I did dabble a while back. Have you looked at Mark Engelberg’s Tutorial? It’s linked to on the TADS 2 page, and it goes through things like indirect verbs (put [direct object] in [indirect object]), as well as a lot more besides.

On the whole though, I’m not sure that making a cup of tea is quite as simple to code as you might think. For a start, pouring water into a pot seems like a simple enough command, until you find users wanting to ‘pour water into pot’ as a single action, or ‘put pot under tap’ and ‘turn tap on’, or a million other ways of phrasing it (‘fill pot with water’, for example). I’d be inclined to have a one-button-push tea making machine, or a tea selling npc, but that’s just me…

btw, what kind of errors do you get with moveinto? I seem to remember it being a pretty straightforward command.

I have read that tutorial. I’m basing this on that.
Well, I was trying to put a pot in a sink.

sink: fixeditem, container
sdesc=“sink”
noun=‘sink’
location=startroom
ldesc=
{
if (pot.location=self)
“This is a sad looking sink, with a small tap. A pot rests on the drain.”;
}
else
{
“This is a sad looking sink, with a small tap.”;
}
;

pot: item, container
sdesc=“pot”
ldesc=“This is a pot.”
noun=‘pot’
location=startroom
;

The pot, by being in the sink, when a tap was turned, would check to see if the pot was in the sink, and if so, to place water into it.
i’m not at my own computer, as it does not have internet, so i’m not sure exactly how to define the tap here, so i’ll just tell how I’m trying to work it.

tap:

doturn(actor)=
{
if (pot.location=sink)
{
“Water gushes from the tap and fills the pot.”;
water.moveInto(pot);
}
else
{
“The water gushes on, doing nothing, therefor costing you another 1/8 of a cent wasted.”;
}
}
;

The following code works for me. (Note that this is not ready to go in a released game: synonyms and alternative methods galore would be needed.) You were missing the verDoTurn(actor) bit.

[code]sink: fixeditem, container
sdesc=“sink”
noun=‘sink’
location=startroom
ldesc=
{
if (pot.location=self)
{
“This is a sad looking sink, with a small tap. A pot rests on the drain.”;
}
else
{
“This is a sad looking sink, with a small tap.”;
}
}
;

pot: item, container
sdesc=“pot”
ldesc=“This is a pot.”
noun=‘pot’
location=startroom
;

tap: fixeditem
sdesc=“tap”
noun=‘tap’
location=sink
verDoTurn(actor)={}
doTurn(actor)=
{
if (pot.location=sink)
{
“Water gushes from the tap and fills the pot.”;
water.moveInto(pot);
}
else
{
“The water gushes on, doing nothing, therefor costing you another 1/8 of a cent wasted.”;
}
}
;

water: item
sdesc=“water”
adesc=“some water”
noun=‘water’
location=nil
;
[/code]

Also, here’s that implemented in TADS 3:

somePlace: Room 'Magical Castle in the Clouds'
;

+sink: Container, Fixture
    noun='sink'
    name='sink'
;

++tap: Component
    noun='tap'
    name='tap'
    dobjFor(Turn)
    {
        verify(){}
        check()
        {
            if(pot.location!=sink)
            {
                reportFailure('You see no reason to pour water fruitlessly down the plughole. ');
                exit;
            }
        }
        action()
        {
            "You fill the pot with water. ";
            water.moveInto(pot);
        }
    }
;

++pot: RestrictedContainer
    noun='pot'
    name='pot'
    
    validContents = [water] 
;

water: Thing
    noun='water'
    name='water'
    aName='some water'
;

That bit worked fine, now I’m trying the burner. But this is not working! Sorry to leech off you people, but cann you help? I’m thinking a lightsource object, that would be the simplist to implment, but I’m getting errors like: invalid token, undefined object when the object is defined, that sort of thing. Help! I’ve been working on this project for months, and this is a vital part. The entire code for this project spans over 300 objects and 30,000 letters, and I don’t want to toss it.

I’m afraid we’ve reached the limit of my TADS 2 knowledge, though someone else may be able to help you. In order for that to happen, however, you’ll have to be a lot more specific.

-What is the burner supposed to do from the user’s perspective?
-What are you trying to do from a coder’s perspective (eg. why do you need the burner to be a lightsource)?
-What is your code, and where does the compiler say the errors are? Which token does it say is invalid? Which object does it not think has been defined (and where do you define and use that object)?

Sadly, when it comes to computer code, phrases like ‘that kind of thing’ aren’t very helpful, since code must cohere to a very specific syntax.

Best of luck, anyway. If no-one answers your question here, try the news group. :slight_smile:

This is what the player would get:

put pot in sink
Done.
turn tap
A stream of water fills the pot.
put pot on burner
Done.
turn on burner
The burner lights up, and causes the water to simmer.
z
Time passes…
z
Time passes…
z
Time passes…
z
Time passes…
The water boils.
put water in press
Done.
put tea in press
Done.
close press
Closed.
z
Time passes…
z
Time passes…
The tea looks ready.

that’s all i’m having trouble with. Now that I realize it, I don’t need it to be a lightsource. I’m trying a notify method, like: notify(object,&method, 4); to set the time release. I don’t have the code right here, as i’m on a library computer, but i’ll put it on a floppy and bring it over soon.