intfiction.org

The Interactive Fiction Community Forum
It is currently Fri May 24, 2013 9:05 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Sun Jul 08, 2012 4:14 pm 
Offline

Joined: Fri Jul 06, 2012 8:58 pm
Posts: 5
So I have an poison apple. The player can eat it, but of course they'll die. I'm not exactly sure I'm using dangerous correctly here. It really doesn't seem to do anything but suppress a bare 'eat' command with no direct object.

What I'd really like to do is present the actor with an "Are you sure?" message before they continue.

I looked over the documentation, but the topics covering dangerous are pretty thin.

Thanks in advance!

Code:
++ apple: Food, Thing 'apple' 'apple'
    "The apple is so pretty, it looks as though it was plucked from the Garden of Eden. 
    Actually, it looks a little too perfect.  "
    dobjFor(Eat)
    {
        verify()
        {
            dangerous;
        }
        action()
        {           
            "Not only did it look good, it was full of poison. ";
            finishGameMsg(ftDeath, [finishOptionCredits]);
        }
    }
;


Top
 Profile Send private message  
 
PostPosted: Sun Jul 08, 2012 5:41 pm 
Offline

Joined: Sat Dec 22, 2007 11:52 pm
Posts: 767
Right, dangerous isn't exactly what you want, though it's not a bad idea to have it too.

It's a little hard to find unfortunately, but T3 has a global function yesOrNo (look in the symbols index of the Library Reference Manual).

If you're having trouble finding something in the docs another good resource is the old newsgroup. You can search here too of course but the newsgroup has more T3 topics, since it's been around longer, so I usually try that first.

For example,

https://groups.google.com/forum/?fromgr ... or$20no%22

And the first hit for that,

https://groups.google.com/forum/?fromgr ... 6KY7S0oCIJ

Which would lead you to yesOrNo.

So here's a transcript,

Quote:
The Cottage

>i
You are carrying an apple. 

>eat
What do you want to eat? 

>apple
Are you sure? no
You have second thoughts. 

>eat apple
Are you sure? yes
Not only did it look good, it was full of poison. 

*** YOU HAVE DIED ***

Would you like to RESTORE a saved position, RESTART the story, see the CREDITS, or QUIT?


And code:

Code:
#charset "us-ascii"

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

versionInfo: GameID
    IFID = 'foo'
;

gameMain: GameMainDef
    initialPlayerChar = me
;

startRoom: Room 'The Cottage'
;

+ me: Actor
;

++ apple: Food 'apple' 'apple'
    "The apple is so pretty, it looks as though it was plucked from the Garden of Eden. 
    Actually, it looks a little too perfect.  "
    dobjFor(Eat)
    {
        verify()
        {
            dangerous;
        }
        check()
        {
            "Are you sure? ";
            if(!yesOrNo()) failCheck('You have second thoughts. ');
        }
        action()
        {           
            "Not only did it look good, it was full of poison. ";
            finishGameMsg(ftDeath, [finishOptionCredits]);
        }
    }
;


Top
 Profile Send private message  
 
PostPosted: Sun Jul 08, 2012 5:59 pm 
Offline

Joined: Fri Jul 06, 2012 8:58 pm
Posts: 5
That worked perfectly! I didn't even realize there was a newsgroup about it, since I'm just getting started.

Thanks again for the help and the pointer to the newsgroup.


Top
 Profile Send private message  
 
PostPosted: Sun Jul 08, 2012 9:57 pm 
Offline
User avatar

Joined: Tue Apr 20, 2010 2:48 pm
Posts: 688
Note that the IF newsgroups (rec.arts.int-fiction and rec.games.int-fiction) are quite dead by now. Only a few people follow them these days. They're still good for searching though.


Top
 Profile Send private message  
 
PostPosted: Mon Jul 09, 2012 12:01 am 
Offline

Joined: Sat Dec 22, 2007 11:52 pm
Posts: 767
Nikos, when I was searching the newsgroup I came across an old (2003?) T3 example you posted for this very subject, but the download link was long gone. I was wondering if you still have that source lying around and if it works more or less with the latest T3, maybe you could post it?


Top
 Profile Send private message  
 
PostPosted: Mon Jul 09, 2012 1:17 am 
Offline
User avatar

Joined: Tue Apr 20, 2010 2:48 pm
Posts: 688
George wrote:
Nikos, when I was searching the newsgroup I came across an old (2003?) T3 example you posted for this very subject, but the download link was long gone. I was wondering if you still have that source lying around and if it works more or less with the latest T3, maybe you could post it?

Can you link to the post on Google Groups?


Top
 Profile Send private message  
 
PostPosted: Mon Jul 09, 2012 10:02 am 
Offline

Joined: Sat Dec 22, 2007 11:52 pm
Posts: 767
This one,

https://groups.google.com/forum/?fromgr ... MuN6j4e0gJ


Top
 Profile Send private message  
 
PostPosted: Mon Jul 09, 2012 10:37 am 
Offline
User avatar

Joined: Tue Apr 20, 2010 2:48 pm
Posts: 688
Ah, now I remember. Wow, time really goes by...

I'm attaching the file. It's still from 2003, and it still works as intended (as far as I can tell.) The forum doesn't allow uploading of Tads source code (*.t files), so I've renamed it to *.txt.

There's also a very similar module at the archive. That one also allows "maybe" as an answer. You can find it in the "examples" directory:
http://www.ifarchive.org/if-archive/pro ... /examples/

Simply pick what works for you :)


Attachments:
ncYesNo.txt [5.44 KiB]
Downloaded 19 times
Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group