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
Latent
Apprentice


Joined: 19 Aug 2002
Posts: 120
Location: USA

PostPosted: Fri Jan 31, 2003 4:36 am   

storing more than one word in a variable
 
How?
Reply with quote
Davos
Adept


Joined: 30 Jan 2003
Posts: 228
Location: USA

PostPosted: Fri Jan 31, 2003 4:39 am   
 
Depends on what your trying to store...
storing off a trigger pattern?
easy way I believe is
@var = "String of text"
Im sure someone will correct me if im wrong

The Seaworthy
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Fri Jan 31, 2003 4:41 am   
 
My guess is that you are storing matched text from a trigger. If so, then you need something like:
#VAR myvar "%1"

Kjata
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Fri Jan 31, 2003 4:42 am   
 
The issue is that the script parser is looking at spaces as different parameters.

Easiest way is to put {} around it.

#VAR many_words {many words here}

#TRIGGER {^(*) is here.} {#VAR Who_is_here {%1}}
#SH A big dude is here.
#SH @Who_is_here
A big dude

Ton Diening
Reply with quote
Davos
Adept


Joined: 30 Jan 2003
Posts: 228
Location: USA

PostPosted: Fri Jan 31, 2003 4:43 am   
 
While we are on the topic whats different from
@var = "%1"
and
#VAR var "%1"

The Seaworthy
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Fri Jan 31, 2003 4:47 am   
 
Same thing different syntax:
var="%1"
#VAR var "%1"

@var = "%1"
Sets what @var is to "%1"

#VAR var somethingelse
@var="%1" ; sets the value of @var which is somethingelse to "%1"
Edited above line does indeed not work; I never use that syntax and should know
better to claim before testing ^_^ However the following line works as I use the concept often.

#VAR @var "%1" ; sets the value of @var which is somethingelse to "%1"
#SH @somethingelse will show "%1"

Ton Diening
Reply with quote
Latent
Apprentice


Joined: 19 Aug 2002
Posts: 120
Location: USA

PostPosted: Fri Jan 31, 2003 4:48 am   
 
actually its for a blacksmithing script i am making, and whenever i start to craft an item type, say, rusty dagger, i want it store "rusty dagger" in a variable to keep my position should i log off. it isnt capturing the test from output, its part of the trigger, just changing the value of a variable
Reply with quote
Latent
Apprentice


Joined: 19 Aug 2002
Posts: 120
Location: USA

PostPosted: Fri Jan 31, 2003 4:50 am   
 
heres what one part of my trigger looks like...

#IF (@blacksmith == 41) {
smith celestial axe
#VAR currentsmith "celestial axe"
}

is the part where i assign currentsmith the value "celestial axe" correct?
Reply with quote
Davos
Adept


Joined: 30 Jan 2003
Posts: 228
Location: USA

PostPosted: Fri Jan 31, 2003 4:58 am   
 
quote:
#VAR var somethingelse
@var="%1" ; sets the value of @var which is somethingelse to "%1"
#SH @somethingelse will show "%1"



#SH @somethingelse will show "" not "%1" in your example because var @somethingelse isn't defined.

when I use it if I use
My Name Is Davos.
#TR {My Name Is (%w).} {@var = %1}
#SH @var
Davos

So why wouldn't:
My Name Is Davos.
#TR {My Name (%*).} {@var = "%1"}
#SH @var
Is Davos

Work? Or should it be:

My Name Is Davos.
#TR {My Name (%*).} {@var = %1}
#SH @var
Is Davos

The Seaworthy
Reply with quote
Davos
Adept


Joined: 30 Jan 2003
Posts: 228
Location: USA

PostPosted: Fri Jan 31, 2003 5:00 am   
 
quote:
#VAR currentsmith "celestial axe"
}

is the part where i assign currentsmith the value "celestial axe" correct?




Yes this should work for you.

The Seaworthy
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Jan 31, 2003 5:04 am   
 
Latent:
Yes, that should work fine, as long as the variable doesn't already have a default value and doesn't have the "use default" option set. If it does, you can clear the option and remove the default value in the editor.

LightBulb
Senior Member
(by the way, the correct syntax is #IF (@blacksmith = 41), but the way you have it will still work)
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Fri Jan 31, 2003 5:29 am   
 
Davos see my correction above!

quote:

My Name Is Davos.
#TR {My Name Is (%w).} {@var = %1}
#SH @var
Davos


You must remove the @ sign up there. Equivalent statement:
#TR {My Name Is (%w).} {#VAR var %1}
#TR {My Name Is (%w).} {var=%1}

quote:

My Name Is Davos.
#TR {My Name (%*).} {@var = "%1"}
#SH @var
Is Davos


Avoid %* patterns unless absolutely necessary as they can be unsafe.
Use * patterns instead. Equivalent statements:
#TR {My Name (*).} {#VAR var "%1"}
#TR {My Name (*).} {var="%1"}

You only need the @ when you want the value of the variable.
To set a variable to something you omit it.


See help files at
http://www.zuggsoft.com/library/varadv.htm

Ton Diening
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