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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion Goto page 1, 2  Next
cuprohastes
Wanderer


Joined: 22 Oct 2006
Posts: 92

PostPosted: Thu Jul 10, 2008 6:46 am   

How do I.... specify "Do not parse" from command line in script?
 
I have a script in my custom globals file like this:
Code:
$aname=%1
$atarget=%2
#echo "Alias created"
#alias $aname "page" $atarget "~=%params"

So if I use
Code:
pmake al Alex
it creates an alias that will use this:
Code:
page alex~=%params
to send a page to Alex -
Code:
al Hi!
on the command line results in
Code:
page alex=Hi!
being sent to the Muck.
But then I have to go into the settings, find the new alias and un-tick the "Parse parameters" box.
How do I edit my script to set that property to off?
Reply with quote
Caled
Sorcerer


Joined: 21 Oct 2000
Posts: 821
Location: Australia

PostPosted: Thu Jul 10, 2008 7:26 am   
 
Give this a shot. Its a guess only, but..

#AL $aname {"page" $atarget "~=%params"} {parsearg}


Thats the format it needs to take to specify options. The guess part is 'parsearg' as the name of the option.
_________________
Athlon 64 3200+
Win XP Pro x64
Reply with quote
cuprohastes
Wanderer


Joined: 22 Oct 2006
Posts: 92

PostPosted: Thu Jul 10, 2008 7:31 am   
 
That actually creates a class called "parsearg" and makes an alias inside it, which has the "Parse arguments" option set to on, which is the default. The parse Arguments option needs to be set to off when the alias is created.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Jul 10, 2008 9:18 am   
 
That's just a syntax mistake:

#AL $aname {"page" $atarget "~=%params"} "" {parsearg}

I have no idea if parsearg is the right keyword for this option, though.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
cuprohastes
Wanderer


Joined: 22 Oct 2006
Posts: 92

PostPosted: Thu Jul 10, 2008 9:28 am   
 
No that is wrong. For a start, instead of
Code:
page Alex ~=%params
You get
Code:
 "page" Alex "~=%params"
and since {parseargs} isn't the right argument, nothing happens.
Reply with quote
Caled
Sorcerer


Joined: 21 Oct 2000
Posts: 821
Location: Australia

PostPosted: Thu Jul 10, 2008 11:46 am   
 
Problem is I can't think of a way to work out what the right argument is. The older ones we tend to just remember from zmud. 'Parsearg' I got from the xml.
_________________
Athlon 64 3200+
Win XP Pro x64
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Thu Jul 10, 2008 4:34 pm   
 
As far as I'm aware after the class name is specified there are no further arguments expected for the #alias command so I guess that the parser is just discarding them.

You'll have to request that Zugg make a change to allow such a thing to be done.

At which point there is no reason the following wouldn't work as your base alias:

#ALIAS pmake($aname,$atarget) {#ALIAS $aname {page %concat($atarget,~=%params)} "someclassifyouwantit" {noparse};#ECHO "Alias created"}
_________________
Taz :)
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23377
Location: Colorado, USA

PostPosted: Thu Jul 10, 2008 5:05 pm   
 
There isn't any command line option for this argument at this time (same for the Auto Append option). The #ALIAS command doesn't have an "options" field like the #TRIGGER command does.
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Thu Jul 10, 2008 5:16 pm   
 
Beyond adding options at creation time it might be nice, and useful, to be able to modify them at a later time programmatically.
...same for macros, triggers and anything else that has options.
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23377
Location: Colorado, USA

PostPosted: Thu Jul 10, 2008 7:15 pm   
 
You can already do much of that via the CMUD API and Lua. For example:
Code:
LUA Code:
zs.makealias{"myalias", "#SHOW %params", parsearg="false"}

would create an alias called "myalias" with the ParseArg option turned off. Or, to modify an existing alias:
Code:
LUA Code:
a = zs.getalias("myalias")
a.parsearg = "false"

would change an existing alias. Lots of power in the LUA API. This API will eventually be exposed as a new COM API, but that's lower on the priority list right now.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Jul 10, 2008 7:53 pm   
 
Is it actually "false", the string false, you need to set the option to, or is the boolean false without the quotes? It's an important distinction.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Thu Jul 10, 2008 11:31 pm   
 
What is the key name for language?
Code:
LUA Code:
a = zs.getalias("myalias")
a.language = "Lua"
doesn't seem to work.
_________________
Taz :)
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Jul 10, 2008 11:44 pm   
 
You have a good point, actually - the documentation doesn't mention an option like this. I'm just about to add parsearg here, btw.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23377
Location: Colorado, USA

PostPosted: Fri Jul 11, 2008 12:48 am   
 
Actually, either the string value or a boolean value will both work. When CMUD tries to convert the value into a boolean, if it sees a string, it checks for true/false string values.

The key name for the language is whatever you see in the pull-down Language box in the settings editor. CMUD takes this from the list of supportable scripting languages that it finds installed on your system.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri Jul 11, 2008 1:09 am   
 
I'd imagine that that'd be the string value you need to select a particular language... but Taz is after the key in the alias zs object that you use to set the script language. It's not language, so what is it?
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23377
Location: Colorado, USA

PostPosted: Fri Jul 11, 2008 2:43 am   
 
Hmm, I just looked at this and unfortunately I don't have a property for that! There is an internal property for the language "id" value, which is a numeric value. But I'll add this to the list for the next version and see what I can do.
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Fri Jul 11, 2008 1:39 pm   
 
This doesn't work on the command line it throws a parsing error but works fine from within an alias. Am I being thick or something?
#lua {a = zs.getalias("myalias");a.parsearg = false}
_________________
Taz :)
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23377
Location: Colorado, USA

PostPosted: Fri Jul 11, 2008 5:19 pm   
 
I'll add this to the bug list. The parser is kludged to handle the #LUA command (since the stuff in {} is not a normal zScript syntax) and it looks like the = in it is messing up the parser. I'll see what I can do.
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Wed Jul 16, 2008 10:57 pm   
 
cuprohastes:

Now that v2.32 is out find below the answer to your problem.

Code:
#ALIAS pmake($aname,$atarget) {#ALIAS $aname {page %concat($atarget,~=%params)} "pages";noparse $aname;#ECHO "Alias created"}
#ALIAS noparse($aname) {a = zs.getalias(zs.param(aname));a.parsearg = "false"}
#LUA {a = zs.getalias("noparse");a.language = "Lua"}

Then test with

pmake al Alex <- return
al this is a nice command; testing all sorts of cr@p <- return
_________________
Taz :)
Reply with quote
cuprohastes
Wanderer


Joined: 22 Oct 2006
Posts: 92

PostPosted: Thu Jul 17, 2008 4:57 pm   
 
Thanks for the scrip!
Unfortunately this is the result:
Code:
<alias name="al" id="491">
  <value>page %concat(alex,~=%params)</value>
</alias>

Code:
page %concat(alex,~=%params)

Which works fine. The problem is it's in a class folder called "pages;noparse" and "Parse arguments" is set to On., same as with a regular alias.
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Thu Jul 17, 2008 5:08 pm   
 
What version are you using?

If you are using v2.32 then copy just the part in the code section into an untitled session and see if it works since it does for me.

If you have a pmake and noparse already then delete them from your session before copying the code and executing it on the command line.
_________________
Taz :)
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Thu Jul 17, 2008 5:14 pm   
 
Try copy and pasting the following on the command line instead
Code:
#ALIAS pmake($aname,$atarget) {
  #ALIAS $aname {page %concat($atarget,~=%params)} "pages"
  noparse $aname
  #ECHO "Alias created"
}
#ALIAS noparse($aname) {
  a = zs.getalias(zs.param(aname))
  a.parsearg = "false"
}
#LUA {
  a = zs.getalias("noparse")
  a.language = "Lua"
}
_________________
Taz :)
Reply with quote
cuprohastes
Wanderer


Joined: 22 Oct 2006
Posts: 92

PostPosted: Fri Jul 18, 2008 5:43 pm   
 
[edit] Actually it looks like I just flubbed on an edit. [edit]
Quote:
OK, that worked - except when I moved it to the "MyGlobals" global package I use, it stopped running Noparse
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Fri Jul 18, 2008 7:58 pm   
 
I just tested that here and it worked fine. The only thing that I did do was to remove the extra spaces that the layout above causes inside the scripts, so check for them and get back to me.
_________________
Taz :)
Reply with quote
cuprohastes
Wanderer


Joined: 22 Oct 2006
Posts: 92

PostPosted: Fri Jul 18, 2008 9:39 pm   
 
OK. So I have
Code:
<alias name="pmake" id="31">
  <value>#ALIAS $aname {page %concat($atarget,~=%params)} "MyPages" noparse $aname
#ECHO "Alias created"</value>
  <arglist>$aname,$atarget</arglist>
</alias>


and

Code:
<alias name="noparse" language="Lua" id="30">
  <value>a = zs.getalias(zs.param(aname))
a.parsearg = "false"</value>
  <arglist>$aname</arglist>
</alias>


in my "My Globals" global. When I open a session and type "pmake al alex" I get
Code:
<alias name="al" id="495">
  <value>page %concat(alex,~=%params)</value>
</alias>


In a class called "MyPages", which is fine. But "Parse arguments" is still set to on.
Now when I ran this originally it actually did turn the parsing off. Now... it doth not.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
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