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
shaun.murray
Magician


Joined: 23 Jul 2005
Posts: 334
Location: Chicago

PostPosted: Wed May 14, 2008 2:04 am   

%line help....
 
Well... I've been posting alot on here, so I thought that I would break it down a lil more and get some help with just what I need. So here goes. Am I using %line{num} correctly? TIA!

Code:
#var {sob_list} {Galloping by, a horse nearly runs you over.=Stallion|There is a cow grazing in the field.=Bull|Rolling in the mud, a pig makes a mess.=Sow|One chicken got seperated from the flock.=Rooster}
#var {gob_list} {A stallion leads a herd of ~[ (%d) ~] horses around.=Stallion|There are ~[ (%d) ~] cows here eating away at the grass.=Bull|In the distance you see ~[ (%d) ~] pigs rolling in the mud.=Sow|There are ~[ (%d) ~] chickens in a flock, clucking, making alot of noise.=Rooster}

#trig {({@sob_list})} {#var mob_list %line(1)}
#trig {({@gob_list})} {#var mob_list %line(%1)}
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed May 14, 2008 3:06 am   
 
No. %line isn't a function, it's a variable. It contains the most recent line of text. If used in a trigger, that's the line that fired the trigger.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
shaun.murray
Magician


Joined: 23 Jul 2005
Posts: 334
Location: Chicago

PostPosted: Wed May 14, 2008 11:44 am   
 
Ah... So you would use %line(1) to point to the line that fired the trigger? So it would be used something like this instead? (In continuing with the code from the first post.)

Code:
#var {mob_list} {Stallion=0|Bull=0|Sow=0|Rooster=0}

#trig {({@sob_list})} {#var mob_list %line(1) 1}
#trig {({@mob_list})} {#var mob_list %line(1) %1}
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed May 14, 2008 12:30 pm   
 
No. Like I said, %line isn't a function, it doesn't take any arguments. It's a variable, like %1 is a variable. You use %line in your scripts, not %line(number). Remove the (1) part.

Though you need to be sure that that'll do what you want, because word wrapping might mean that %line has stuff in it that's nothing to do with the trigger match.

And now I think about it, your #var syntax is potentially wrong. You're setting the default there when I think you mean to be using #addkey to set up a dbvar.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
shaun.murray
Magician


Joined: 23 Jul 2005
Posts: 334
Location: Chicago

PostPosted: Wed May 14, 2008 12:47 pm   
 
Mmmm.... Ok, that makes a lil more sense. LoL! So... I'm thinking this is looking better?

Code:
#var {sob_list} {Galloping by, a horse nearly runs you over.=Stallion|There is a cow grazing in the field.=Bull|Rolling in the mud, a pig makes a mess.=Sow|One chicken got seperated from the flock.=Rooster}

#var {gob_list} {A stallion leads a herd of ~[ (%d) ~] horses around.=Stallion|There are ~[ (%d) ~] cows here eating away at the grass.=Bull|In the distance you see ~[ (%d) ~] pigs rolling in the mud.=Sow|There are ~[ (%d) ~] chickens in a flock, clucking, making alot of noise.=Rooster}

#var {mob_list} {Stallion=0|Bull=0|Sow=0|Rooster=0}

#trig {({@sob_list})} {#addkey mob_list %line 1}

#trig {({@gob_list})} {#addkey mob_list %line %1}
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed May 14, 2008 4:29 pm   
 
You need to be very careful setting up a dbvar manually with the #var command. The spaces and non-alphanumeric characters you have in it might cause problems. Were it me, I'd use #addkey to set up the initial variables as well, because then you know for sure you're getting what you want. So:

#addkey sob_list "Galloping by, a horse nearly runs you over." "Stallion"

etc.

And okay, I understand where you're going with this script now. I suspect you'll need to use %2 rather than %1 in your gob_list trigger, because the brackets () around the {@gob_list} will cause the entire match to be captured into %1. Which, I suppose, would be pretty handy - you can replace your use of %line with %1.

The fundamental problem here, though, is that you're adding a key based on %line to the mob list when what you want is the key in mob_list to be the value of gob or sob that matches that line. So change %line to %db(@gob_list,%line) or %db(sob_list,%line) (or %1 if you decide to go that route). Hopefully you understand what that'll do - it's the reason, I think, that you changed your *ob_list variables to dbvars in the first place.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Anaristos
Sorcerer


Joined: 17 Jul 2007
Posts: 821
Location: California

PostPosted: Wed May 14, 2008 11:05 pm   
 
He could create a db variable as follows:
Code:

dbvar = ""
#CALL %vartype(dbvar,5)
dbvar.key1 = value1
dbvar.key2 = value2
....
_________________
Sic itur ad astra.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed May 14, 2008 11:08 pm   
 
He could do it that way (even without explicitly setting the type as you do there), but the trouble is that his keys are very long and contain spaces. So he can't do that in this case.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
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