Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
McGravin
Beginner


Joined: 30 May 2002
Posts: 25
Location: USA

PostPosted: Sun Dec 15, 2002 11:06 pm   

Converting written-out numbers to Arabic numerals.
 
I'm having trouble with a little trigger I'm trying to write. The MOO output is along the lines of:

[General Communication] A Jinu transmits, "Yuuijuminlakiltra et jukl yura oh Human jukte 'Twenty-six.' Erto yuui uu yuuijuminla."

I'm trying to capture the "Twenty-six" (or whatever number it happens to be) and convert it to a number: 26. However, the trigger I wrote, using "#IF %begins(" and "#IF %ends(" just gives me endless syntax errors that I can't seem to correct and doesn't work.

Can anyone help me out? And instead of just the bare-bones script I need to get it to work, can you actually explain what it is that I'm missing about this?

(Yes, that message is in another language, by the way.)

-McGravin
Non plaudite, modo pecuniam jacite.
Reply with quote
Emit
Magician


Joined: 24 Feb 2001
Posts: 342
Location: USA

PostPosted: Mon Dec 16, 2002 5:02 am   
 
help with fixing syntax errors will be more forthcoming with your exact script :)

maybe zmud is complaining about the lack of ()?
#if (%ends(@alpha, "six")) {#add num 6}
no..... thats probably not it
Reply with quote
McGravin
Beginner


Joined: 30 May 2002
Posts: 25
Location: USA

PostPosted: Tue Dec 17, 2002 9:59 pm   
 
Nope, that's not it, but thanks.

So far, the script consists of a trigger with pattern:
~[General Communication~] A Jinu transmits, "Yuuijuminlakiltra et jukl yura oh Human jukte '(*).' Erto yuui uu yuuijuminla."

and script value:
#VARIABLE jinusec 0

#IF %ends(%1,"teen") {#ADD jinusec 10}
#IF %begins(%1,"twenty") {#ADD jinusec 20)
#IF %begins(%1,"thirty") {#ADD jinusec 30}


I haven't gotten any further because I can't get this tiny portion to work. The first #IF works fine, but the next two give me syntax errors and I even get a syntax error on the blank line after the third #IF (even though I didn't hit enter after that #IF and I can't delete the linebreak). Any other ideas?
Reply with quote
Darker
GURU


Joined: 24 Sep 2000
Posts: 1237
Location: USA

PostPosted: Tue Dec 17, 2002 10:27 pm   
 
Try this...


#VARIABLE jinusec 0
#if (%ends(%1,"one")) {#ADD jinusec 1}
#if (%ends(%1,"two")) {#ADD jinusec 2}
#if (%ends(%1,"three")) {#ADD jinusec 3}
#if (%ends(%1,"four")) {#ADD jinusec 4}
#if (%ends(%1,"five")) {#ADD jinusec 5}
#if (%ends(%1,"six")) {#ADD jinusec 6}
#if (%ends(%1,"seven")) {#ADD jinusec 7}
#if (%ends(%1,"eight")) {#ADD jinusec 8}
#if (%ends(%1,"nine")) {#ADD jinusec 9}
#if (%1="ten") {#add jinusec 10}
#if (%1="eleven") {#add jinusec 11}
#if (%1="twelve") {#add jinusec 12}
#if (%1="thirteen") {#add jinusec 13}
#if (%1="fourteen") {#add jinusec 14}
#if (%1="fifteen") {#add jinusec 15}
#if (%1="sixteen") {#add jinusec 16}
#if (%1="seventeen") {#add jinusec 17}
#if (%1="eighteen") {#add jinusec 18}
#if (%1="nineteen") {#add jinusec 19}
#IF (%begins(%1,"twenty")) {#ADD jinusec 20}
#IF (%begins(%1,"thirty")) {#ADD jinusec 30}
#IF (%begins(%1,"forty")) {#ADD jinusec 40}
#IF (%begins(%1,"fifty")) {#ADD jinusec 50}


I didn't check for the definition of %begins and %ends, or even look into more creative ways to do this, so the helpfile might have to be checked if there's a bug. I did find a typo ) instead of } in the original script you posted here and fixed it above.



zMUD 6 Online Help: All the power you'll ever need.
Reply with quote
McGravin
Beginner


Joined: 30 May 2002
Posts: 25
Location: USA

PostPosted: Tue Dec 17, 2002 10:47 pm   
 
Thank you for finding my own stupid typo. I should have realized it was something so simple.

One more problem I found and easily corrected, but I thought I'd better share the solution in case anyone wants to make a similar script later...

In the MOO output, the number I'm looking to change is capitalized, but the #IF (%1="ten") will reject it. So instead, I saved the value of %lower(%1) to a variable and changed all the previous %1's to that variable's name. And it works perfectly, now.

-McGravin
Non plaudite, modo pecuniam jacite.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net