intfiction.org

The Interactive Fiction Community Forum
It is currently Sun May 19, 2013 12:45 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Fri Dec 23, 2011 12:26 pm 
Offline

Joined: Sun Nov 06, 2011 12:17 pm
Posts: 156
Location: Toledo, Ohio, USA
My actor has some 'always worn' objects. when I test them by trying to drop them, I get the following message:

"First trying to take off the the khakis"

Then I'm told that I can't take them off.

Is there any way to stop the first line from displaying?

Here's a sample of my code:

[code][/code]

++khakis: Wearable 'pair/kahki/khakis/shorts' 'pair of khaki shorts'
"You are wearing a pair of rugged knee-length khaki shorts with very handy
pockets."
wornBy = me
isPlural=nil
dobjFor(Doff){
check(){
failCheck ('This is not the time nor place to start undressing.');
}}
;

I've tried using the 'AlwaysWorn' approach but then I get compile errors.


Top
 Profile Send private message  
 
PostPosted: Fri Dec 23, 2011 1:04 pm 
Offline

Joined: Tue Apr 27, 2010 1:02 pm
Posts: 797
The easiest way is simply to redirect the drop action to the doff one.

Code:
++ khakis: Wearable 'rugged pair/kahki/khaki*kahkis*khakis*shorts' 'khaki shorts'
   "You are wearing a pair of rugged knee-length khaki shorts with very handy
   pockets."
   wornBy = me
   isPlural = true
   dobjFor(Doff) {
      check() {
         failCheck ('This is not the time nor place to start undressing.');
      }
   }
   dobjFor(Drop) asDobjFor(Doff)
;


The vocabWords property - that part with the slashes and asterisks - took me awhile to understand. It breaks down like this.
  • A list of adjectives, separated by spaces
  • A list of singular nouns, started with a space, separated by slashes
  • A list of plural nouns, started with an asterisk, separated by asterisks

Not sure why you set isPlural to nil. If you set it to true, and leave the plural stuff out of the actual name, then it should show up correctly in listings as "some khaki shorts."


Top
 Profile Send private message  
 
PostPosted: Fri Dec 23, 2011 1:16 pm 
Offline

Joined: Sat Jul 16, 2011 3:48 pm
Posts: 55
Quote:
I've tried using the 'AlwaysWorn' approach but then I get compile errors.


The AlwaysWorn class from RTDD game is not a standard class provided by the Adv3 library, but it's a new class defined in the game source code (in the mods.t file). If you want to use it, you should copy the following code into your game. That's only FYI as it doesn't solve your problem. But you can add dobjFor(Drop) asDobjFor(Doff) into it as bcressey suggests.

Code:
/*
 *   A class for clothing worn by the player character, and which we can't
 *   take off.  We use this for the PC's constant complement of clothes;
 *   there's no reason to remove these.
 */
class AlwaysWorn: Wearable
    wornBy = me
    dobjFor(Doff)
    {
        check()
        {
            cannotDoffMsg;
            exit;
        }
    }
    cannotDoffMsg = "You really don't have any reason to get
        undressed right now. "

    /* exclude these from DROP ALL and DOFF ALL */
    hideFromAll(action)
    {
        return action.ofKind(DropAction)
            || action.ofKind(DoffAction)
            || action.ofKind(PutInAction)
            || inherited(action);
    }
;


Top
 Profile Send private message  
 
PostPosted: Fri Dec 23, 2011 1:41 pm 
Offline
User avatar

Joined: Tue Apr 20, 2010 2:48 pm
Posts: 680
RonG, please always post your code between code tags.


Top
 Profile Send private message  
 
PostPosted: Fri Dec 23, 2011 2:00 pm 
Offline

Joined: Sun Nov 06, 2011 12:17 pm
Posts: 156
Location: Toledo, Ohio, USA
Thanks again for all the quick advice. I downloaded a piece of code named 'custom.t' which looks like it will be helpful.

I used plural because it sounds and looks more natural to use 'the pair of shorts are....' rather than 'the pair of shorts is...'


Top
 Profile Send private message  
 
PostPosted: Tue Dec 27, 2011 5:27 pm 
Offline

Joined: Sun Nov 06, 2011 12:17 pm
Posts: 156
Location: Toledo, Ohio, USA
What's wrong with this picture?

Code:


/*******************************************************************************
* Always worn. A class of objects that the player cannot take off. *
*******************************************************************************/

class AlwaysWorn: Wearable
wornBy=me
dobjFor(Doff)
{
check()
{
cannotDoffMsg;
exit;
}
}
cannotDoffMsg = "You really should be wearing this and have no reason to get rid
of it."

/* Exclude these from Drop All and DOFF All. */

hideFromAll(action)
{
return action.ofKind(DropAction)
||action.ofKind(DoffAction)
||action.ofKind(PutInAction)
||inherited(action);
}
;


/*Next batch of code***************/

replace VerbRule(Doff)
('doff'|'drop')dobjList
:DoffAction
verbPhrase='doff/doffing(what)'
;
Code:


I am using the above two batches of code. The first batch was posted to me by TOMASB. The second, small batch is by me.

I have two AlwaysWorn objects. If I use "Doff" to drop the objects, it works fine and the objects are not dropped. If I use "Drop" to drop the objects then I get a run-time error

Any Ideas :?:

RonG


Top
 Profile Send private message  
 
PostPosted: Tue Dec 27, 2011 5:33 pm 
Offline
User avatar

Joined: Tue Apr 20, 2010 2:48 pm
Posts: 680
Code:
[code]
Your code goes here.
[/code]


That's how you write code tags in the forum :)


Top
 Profile Send private message  
 
PostPosted: Tue Dec 27, 2011 5:41 pm 
Offline

Joined: Tue Apr 27, 2010 1:02 pm
Posts: 797
Don't add drop as a synonym for doff at the verb level. Conceptually you are saying that in your game, "drop X" is always equivalent to "remove X". This will break dropping items in the normal course of inventory management.

You should be using "dobjFor(Drop) asDobjFor(Doff)" in your AlwaysWorn class.


Top
 Profile Send private message  
 
PostPosted: Wed Dec 28, 2011 3:53 pm 
Offline

Joined: Sun Nov 06, 2011 12:17 pm
Posts: 156
Location: Toledo, Ohio, USA
Many thanks. That code works well now.

RonG


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

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: Google [Bot], jford 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