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
Nibbles
Beginner


Joined: 01 Aug 2004
Posts: 15

PostPosted: Sat May 21, 2005 3:32 pm   

Problem with special characters and %read?
 
All right, I'm attempting to right a Wizard/eScape script emulator for simutronics users in zMUD. To load the files, I'm using the #FILE and %read command and function, the relevant portion follows:

Code:

\clearscript
#FILE 1 %1
#VAR __iter {1}
#VAR __filesize {%filesize( 1)}
#WHILE (@__iter <= @__filesize) {
  #VAR __nextline {%read( 1)}


Now, one of the files might look like this.

Code:

put say Hello %1!


However, the line #VAR __nextline {%read( 1)} is setting @__nextline equal to "put say Hello 1!". The % sign is disappearing.

I've tried encompassing the %read with a %quote, but that doesn't do anything. Does %read itself strip special characters, and if so, why?

Any assistance on how to make this work would be appreciated.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sun May 22, 2005 1:26 am   
 
Were you after the specific emulation of the wizard language, or just the reading-from-a-file format?

Assuming the former, you'll probably have to convert your filereader from %read() to #READ. #READ has a _noexpand option that will keep %1 and other variables intact but to do any processing on each line you'll have to create aliases of all the wizard script commands.

Assuming the latter, you could build an interactive interface to make things easier on the user. I kind of like this idea, so maybe I'll take a crack at it as well (I've got a few other uses in mind, so it won't totally be reinventing the wheel).
_________________
EDIT: I didn't like my old signature
Reply with quote
Nibbles
Beginner


Joined: 01 Aug 2004
Posts: 15

PostPosted: Sun May 22, 2005 4:25 am   
 
Thank you, that solution worked. I created a (*) command trigger and just turned it on to read the line, then turned it right back off:

Code:

#WHILE (@__iter <= @__filesize) {
  #T+ _WizardScripts_CatchLine
  #READ 1 _noexpand
  #T- _WizardScripts_CatchLine
  #MATH __iter {@__iter + 1}
  }


All the parsing goes on in there. I've got it working now with put and echo, I just need to write all the other commands.
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