intfiction.org

The Interactive Fiction Community Forum
It is currently Wed May 22, 2013 8:15 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Magic Words - TADS3.1
PostPosted: Thu Apr 12, 2012 12:57 pm 
Offline

Joined: Sun Nov 06, 2011 12:17 pm
Posts: 156
Location: Toledo, Ohio, USA
I have reached a point in my story where I want to start using 'magic words'. They will mostly be intransitive verbs that will be 'magic word' commands that will enable direct travel or other actions. I would also like these verb groups to be able to handle conditional parts that use conditional things such as 'if-if else-else' and so forth. These will be one set
of the heavily used comands of the story. I'm looking for source code examples or other ideas on how I might go about this. Any ideas or help is more than welcome. Thanks, in advance.

RonG


Top
 Profile Send private message  
 
PostPosted: Thu Apr 12, 2012 1:27 pm 
Offline

Joined: Tue Apr 27, 2010 1:02 pm
Posts: 797
The code for any given "magic word" (especially intransitive ones) is going to be more or less the same as the code for the Glow action that we've worked on in the past.

See: viewtopic.php?f=10&t=4596

In generic form, it will look like this:
Code:
DefineIAction(MAGICWORD)
   execAction() {
      // action code goes here
   }
;

VerbRule(MAGICWORD)
   'MAGICWORD'
   : MAGICWORDAction
   VerbPhrase='MAGICWORD/MAGICWORDing'
;


Where you replace all instances of MAGICWORD with some new word.


Top
 Profile Send private message  
 
PostPosted: Sun Apr 15, 2012 2:05 pm 
Offline

Joined: Sun Nov 06, 2011 12:17 pm
Posts: 156
Location: Toledo, Ohio, USA
I've enclosed some VERY rough code which is my first attempt at using a 'magic word' My problem is that I'm not very sure as how to set up the punctuation and structure of this code. I could use some help with this.

RonG

Code:
/*******************************************************************************
*  Magic Words - To create an intransitive verb (no object), you have to write *
*  at leasr two sections of code.                                              *
*******************************************************************************/

/*  Melenkurion - Magic Word - Is Travel Action  ******************************/

VerbRule(Melenkurion)
   'Melenkurian'
   : MelenkurionAction
   verbPhrase = 'Melenkurion'
;

DefineIAction(Melenkurion)
   execAction(){
      //action code goes here
      if me !in Room1
         "That word, although quite powerful, won't work here. Try another
          location. "
         break
      else
         goto Room3
   }
;


Top
 Profile Send private message  
 
PostPosted: Sun Apr 15, 2012 2:20 pm 
Offline

Joined: Tue Apr 27, 2010 1:02 pm
Posts: 797
Your verb is "Melenkurion" but the triggering word in the VerbRule is "Melenkurian" - that seems to be a mistake.

You aren't following the language syntax rules in your execAction method. You can try this:

Code:
DefineIAction(Melenkurion)
   execAction(){
      //action code goes here
      if (gPlayerChar.getOutermostRoom != Room1) {
          "That word, although quite powerful, won't work here. Try another
           location. "
      }
      else {
          gPlayerChar.moveIntoForTravel(Room3);
          gPlayerChar.lookAround(true);
      }
   }
;


Top
 Profile Send private message  
 
PostPosted: Sun Apr 15, 2012 3:20 pm 
Offline

Joined: Sun Nov 06, 2011 12:17 pm
Posts: 156
Location: Toledo, Ohio, USA
Your code works perfectly. I'll be able to alter it for many uses. Thanks for all the quick responses that you give.

RonG


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users 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