intfiction.org

The Interactive Fiction Community Forum
It is currently Sat May 25, 2013 12:52 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Wed Feb 29, 2012 8:56 am 
Offline
User avatar

Joined: Fri Jan 27, 2012 2:34 pm
Posts: 271
Location: Boston
It seems I need to convert a string to an integer, or to read it in originally as an integer. Can't figure how to do it...

Code:
DefineLiteralAction(Zip)
     execAction()
     {
        mainReport('Okay, Zipping. ');
        Z_ing.n = getLiteral();                 //<----  the offending line; I get a runtime error
        Z_ing.dinky2;
     }
;


VerbRule(Zip)
     'zip' singleLiteral
     : ZipAction
     verbPhrase = 'zip/zipping (what)'
;



Conrad.

_________________
http://tiltedcandle.wordpress.com


Top
 Profile Send private message  
 
PostPosted: Wed Feb 29, 2012 1:38 pm 
Offline
User avatar

Joined: Fri Jan 27, 2012 2:34 pm
Posts: 271
Location: Boston
Hey, I got this one!

toInteger() is my new friend...


C.

_________________
http://tiltedcandle.wordpress.com


Top
 Profile Send private message  
 
PostPosted: Wed Feb 29, 2012 7:10 pm 
Offline
User avatar

Joined: Fri Jan 27, 2012 2:34 pm
Posts: 271
Location: Boston
However, I'll trade that one off for this one--

(I know, I'm always asking questions. BUT, I'm making progress!)


Code:
VerbRule(Zip)
     'zip' singleLiteral
     : ZipAction
     verbPhrase = 'zip/zipping (HowManyTurns)'
;

How do I do this to get proper spaces in between words WITHOUT having them scrambled in some peculiar fashion?

Quote:
>zip
HowManyTurns do you want to zip?


--isn't terrible. The alternatives are...

Quote:
>zip
How do you want to zip many turns?

...with...

Code:
     verbPhrase = 'zip/zipping (many turns how)'


Or

Quote:
>zip
How do you want to zip?


..with..

Code:
     verbPhrase = 'zip/zipping (how) (many turns)'


Or

Quote:
>zip
Many do you want to zip turns how?


..with..

Code:
     verbPhrase = 'zip/zipping (turns how many)'


Or

Quote:
>zip
How do you want to zip turns many?


..with..

Code:
     verbPhrase = 'zip/zipping turns (many how)'


Or other even less likely things.

In general the problem is that TADS wants to say

THREE do you want to verb ONE TWO?

...you can tinker with the order, some, but you can't, that I've seen, get to a

WORD WORD WORD do you want to verb?

--whether it's ONE TWO THREE, THREE TWO ONE, or any other sequence.

Is there some other format I might use? Is it possible to start fresh with a string, 'How many turns do you want to zip?' that I can have TADS ask?


Conrad.

_________________
http://tiltedcandle.wordpress.com


Top
 Profile Send private message  
 
PostPosted: Wed Feb 29, 2012 7:34 pm 
Offline

Joined: Tue Apr 27, 2010 1:02 pm
Posts: 797
I don't know the best way, but this seems to work.

Code:
DefineLiteralAction(Zip)
   whatObj(which) {
      return 'how many turns';
   }
   execAction() {
      // ...
   }
   actionTime = 0
;

VerbRule(Zip)
   'zip' singleLiteral
   :ZipAction
   verbPhrase = 'zip/zipping (what)'
;


Top
 Profile Send private message  
 
PostPosted: Wed Feb 29, 2012 7:51 pm 
Offline
User avatar

Joined: Fri Jan 27, 2012 2:34 pm
Posts: 271
Location: Boston
Yes, that works!

Thanks again, Ben!


Conrad.

_________________
http://tiltedcandle.wordpress.com


Top
 Profile Send private message  
 
PostPosted: Wed Feb 29, 2012 8:12 pm 
Offline
User avatar

Joined: Tue Apr 20, 2010 2:48 pm
Posts: 688
You should probably use singleNumber instead of singleLiteral. You can then get the value as an integer with numMatch.getval(). As a bonus, this allows stuff like:

Code:
>zap seven turns


Which is quite l33t :mrgreen:

Anyway, I didn't look at your whole attempt (scripted waiting and all that), but I think what you want here is to extend WaitAction with a new form that also takes a number. So that in addition to the default form:

Code:
>Z [or WAIT]
Time passes...


You will also have:

Code:
>Z 10 [or WAIT 10]
10 turns worth of time pass...


Something like:

Code:
DefineIAction(WaitTurns)
     execAction()
     {
        "<<numMatch.getval()>> turns worth of time pass... ";
        // ...
     }
;

VerbRule(WaitTurns)
     ('wait' | 'z') singleNumber ( | 'turn' | 'turns')
     : WaitTurnsAction
     verbPhrase = 'wait/waiting (a number of turns)'
;


Top
 Profile Send private message  
 
PostPosted: Wed Feb 29, 2012 10:16 pm 
Offline
User avatar

Joined: Fri Jan 27, 2012 2:34 pm
Posts: 271
Location: Boston
Yeah... I was considering something like that, as being better in every way, but dreaded tinkering with basic TADS verbs at that level.

However, I will be brave and face it (especially since you seem to've done all the work). But I'll look to it later.

I want to get some momentum going along other lines right now, rather than nicening this up beyond functionality.


Conrad.

_________________
http://tiltedcandle.wordpress.com


Top
 Profile Send private message  
 
PostPosted: Wed Feb 29, 2012 11:26 pm 
Offline

Joined: Sun Mar 01, 2009 8:02 pm
Posts: 902
conradcook wrote:
Yeah... I was considering something like that, as being better in every way, but dreaded tinkering with basic TADS verbs at that level.

Whenever you define new grammar, you're not tinkering with an existing action, you're creating an entirely new action. For instance:
Code:
DefineTAction(WaitFor);
VerbRule(WaitFor)
    ('wait' | 'z') 'for' singleDobj
    : WaitForAction
    verbPhrase = 'wait/waiting (for what)'
;

This doesn't affect the library's existing Wait action in any way. At least, I hope it doesn't, because I do this sort of thing a fair amount, and I've never noticed any untoward side effects.


Top
 Profile Send private message  
 
PostPosted: Wed Feb 29, 2012 11:32 pm 
Offline
User avatar

Joined: Tue Apr 20, 2010 2:48 pm
Posts: 688
Jim Aikin wrote:
This doesn't affect the library's existing Wait action in any way. At least, I hope it doesn't, because I do this sort of thing a fair amount, and I've never noticed any untoward side effects.

That's correct. It's a totally new Action object. The worst thing that can happen is a conflicting verb rule, but that's rather easy to spot.


Top
 Profile Send private message  
 
PostPosted: Thu Mar 01, 2012 12:30 pm 
Offline
User avatar

Joined: Fri Jan 27, 2012 2:34 pm
Posts: 271
Location: Boston
Oh God.... I just got this code stable.... I need a week of not looking at it before I screw with it any more...


C.

_________________
http://tiltedcandle.wordpress.com


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

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


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