About Us
Products
Purchase
Downloads
Support
Forums
Contact Us
Site
 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
xekon
Apprentice


Joined: 11 Oct 2007
Posts: 154

PostPosted: Fri Apr 04, 2008 11:11 pm   

Send within #sub variable not expanded when copied, only 1st item copies
 
Send within #sub variable not expanded when copied, only 1st item copies

Code:
#SUB {"You still have to kill * "%1" (~<send '"$replacepath;inzonevnums=@maproomvnums;#walk %item(@maproomvnums,1)"'~>"%2"~</send~>)"}


This does not work either:
Code:
#SUB {"You still have to kill * "%1" (~<send '"$replacepath;inzonevnums=%expandlist(@maproomvnums,"|");#walk %item(@maproomvnums,1)"'~>"%2"~</send~>)"}
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4690
Location: Pensacola, FL, USA

PostPosted: Fri Apr 04, 2008 11:14 pm   
 
just use single quotes, not doubles no need to ~ out the <> anymore either
_________________
Discord: Shalimarwildcat
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Fri Apr 04, 2008 11:55 pm   
 
This is the reason this doesn't work. This is your command with the parts that're strings in green:

#SUB {"You still have to kill * "%1" (~<send '"$replacepath;inzonevnums=@maproomvnums;#walk %item(@maproomvnums,1)"'~>"%2"~</send~>)"}

As shalimar says, there's no need to use ~ to quote <>s that're already inside a string. It's still important that you use speech marks "" to surround things you want to be strings - apostrophes don't mean anything in zScript syntax.

The more pressing problem, though, is the pair of semicolons that're not inside a string, which the parser will then try to interpret. Similarly, the #walk command will probably be run rather than inserted into the string because it's not inside a string. Also, your command is ambiguous - do you mean for @maproomvnums to be evaluated when the #sub command is run, or when your link is clicked? In general, this kind of implicit concatenation (where you just mash a bunch of strings together) isn't recommended. If you concatenate your string explicitly, you shouldn't have a problem.

#SUB {%concat("You still have to kill * ",%1," (<send '",$replacepath,";inzonevnums=@maproomvnums;#walk %item(@maproomvnums,1)'>",%2,"</send>)"}
_________________
Rorso's syntax colouriser.

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


Joined: 04 Aug 2002
Posts: 4690
Location: Pensacola, FL, USA

PostPosted: Sat Apr 05, 2008 12:38 am   
 
i find that within the context of a send massage ' works better then "

<send '$replacePath;inzonevnums=@maproomvnums;#walk %item(@maproomvnums,1)'>%2</send>
_________________
Discord: Shalimarwildcat
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sat Apr 05, 2008 1:21 am   
 
Yes, shamlimar, but he's already doing that and if he hadn't, this problem would've been much more annoying. Change #sub so that it stores the string in a variable (can't show it to the screen or it'll get parsed as MXP) and you'll see what I mean.
_________________
Rorso's syntax colouriser.

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


Joined: 04 Aug 2002
Posts: 4690
Location: Pensacola, FL, USA

PostPosted: Sat Apr 05, 2008 2:16 am   
 
Code:
#SUB {You still have to kill * %1 (<send '$replacepath;inzonevnums=%expandlist(@maproomvnums,"|");#say %item(@maproomvnums,1)'>%2</send>)}


Seems to work just fine. I dont see where all the quotes were needed in the first place.
_________________
Discord: Shalimarwildcat
Reply with quote
xekon
Apprentice


Joined: 11 Oct 2007
Posts: 154

PostPosted: Sat Apr 05, 2008 3:01 am   not quite what i need
 
OK Xianfu I tried the method you posted an I think I have a better understanding of this now. the way you did it would have been perfect except for one problem.
When I receive these lines from the mud, I get about 10 lines back to back. each line needs to sub with their own values.
The way you posted, all lines set inzonevnums to the list of maproomvnums for the last of the patterns back to the mud, so all 10 lines are trying to set to the same maproomvnums.

Sample Output of "campaign check":
Code:
You still have to kill * a sprite (A Den of Snakes in the Labyrinth).
You still have to kill * The Wood Elemental (Elemental Grove).
You still have to kill * a regular customer (House of Pleasure).
You still have to kill * a musician (A Small Loft).
You still have to kill * Ereshkigal (The Torturer's Bedroom).
You still have to kill * personal guard of the White Lotus Chief (Rooms of the White Lotus Chief).
You still have to kill * Minax (In the Warp).
You still have to kill * Lamias (A Crystal Hallway).
You still have to kill * Belinda the judge (Inside Judge Belinda's house).
You still have to kill * the mortal manifestation of Overlord Hatchet (The Living Room of Icaza and Hatchet).
You still have to kill * the Hombre del Saco (A Stairway).


Below is a way I have managed to successfully get all the @maproomvnums into @inzonevnums variable, the only problem with this is that I have to do string manipulation on inzonevnums or run a loop that parses out the strings into a list, this just seems like a cheesy workaround and there must be a better way to do it, but maybe not.

Code:
#SUB {"You still have to kill * "%1" ("<send '$replacePath;inzonevnums=%expandlist(@maproomvnums,"_");#walk @maproomvnums'>%2</send>")"}
Reply with quote
xekon
Apprentice


Joined: 11 Oct 2007
Posts: 154

PostPosted: Sat Apr 05, 2008 5:02 am   
 
shalimar wrote:
Code:
#SUB {You still have to kill * %1 (<send '$replacepath;inzonevnums=%expandlist(@maproomvnums,"|");#say %item(@maproomvnums,1)'>%2</send>)}


Seems to work just fine. I dont see where all the quotes were needed in the first place.


Shalimar, you are correct that this works just as good as what I originally had. no quotes or anything.

However, inzonevnums=%expandlist(@maproomvnums,"|") is only copying the first value of maproomvnums into inzonevnums....
I did a copy and paste of exactely what you had... now if im wrong and that code is somehow working for you, could you tell me what version of cmud you are using.
Reply with quote
Anaristos
Sorcerer


Joined: 17 Jul 2007
Posts: 821
Location: California

PostPosted: Sat Apr 05, 2008 5:23 am   
 
It would seem to me, Xekon, that if it is only copying one value, then there is only one value in the list.
As a test I did the following:
Code:

#VAR var1 100|200|300|400
#VAR var2 %expandlist(@var1,"|")
#ECHO var2 = @var2


The echo was: var2 = 100|200|300|400, as it should have been.
_________________
Sic itur ad astra.
Reply with quote
xekon
Apprentice


Joined: 11 Oct 2007
Posts: 154

PostPosted: Sat Apr 05, 2008 5:30 am   
 
well yes that will work but when your doing sub with send it does something to it... I sill setup a test package with the triggers and variables. then this will be easier to figure out. i will upload it a little later.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4690
Location: Pensacola, FL, USA

PostPosted: Sat Apr 05, 2008 12:34 pm   
 
you could always just have the send perform an alias that handles the other things for you
_________________
Discord: Shalimarwildcat
Reply with quote
xekon
Apprentice


Joined: 11 Oct 2007
Posts: 154

PostPosted: Sat Apr 05, 2008 2:52 pm   
 
Test Package for this.

http://jakegaisser.googlepages.com/testcp.xml

and if you would rather paste into a xml file of your own, heres the contents of the file above:
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <class name="testcp">
    <trigger priority="9020">
      <pattern>^You still have to kill ~* (*) ~((*)~).$</pattern>
      <value>roomvnums=""
currentvnums=""
$replacepath="running someplace"
$replacepath=%concat($replacepath,";#show "currentvnums "@currentvnums;#show "roomvnums "@roomvnums")
#loop %random(2,8) {#additem roomvnums %random(1,28226)}
#SUB {You still have to kill * %1 (%2)}
</value>
    </trigger>
    <var name="roomvnums" type="StringList">7832|15371|11306</var>
    <var name="currentvnums">7832</var>
    <alias name="test">
      <value>#show "You still have to kill * a sprite (A Den of Snakes in the Labyrinth)."
#show "You still have to kill * The Wood Elemental (Elemental Grove)."
#show "You still have to kill * a regular customer (House of Pleasure)."
#show "You still have to kill * a musician (A Small Loft)."
#show "You still have to kill * Ereshkigal (The Torturer's Bedroom)."
#show "You still have to kill * personal guard of the White Lotus Chief (Rooms of the White Lotus Chief)."
#show "You still have to kill * Minax (In the Warp)."
#show "You still have to kill * Lamias (A Crystal Hallway)."
#show "You still have to kill * Belinda the judge (Inside Judge Belinda's house)."
#show "You still have to kill * the mortal manifestation of Overlord Hatchet (The Living Room of Icaza and Hatchet)."
#show "You still have to kill * the Hombre del Saco (A Stairway)."</value>
    </alias>
  </class>
</cmud>
Reply with quote
xekon
Apprentice


Joined: 11 Oct 2007
Posts: 154

PostPosted: Mon Apr 07, 2008 6:02 am   
 
Ive been reading over the forums looking through scripts trying to come up with a solution to this but i cannot seem to find one. Any takers? The test package above should get you started and show you in detail the problem that I am having. All you have to do is run the variable test. Then take a look at the contents of currentvnums... you will see that it only has one of the room vnums, instead of all of them.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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