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


Joined: 25 May 2010
Posts: 14

PostPosted: Wed Jun 02, 2010 3:11 am   

assigning a variable to a variable
 
I'm not sure if this is even possible, but I have a variable with a list of targets in it and I have another variable called @temp_target. What I want it to do is check if the target 'priest' is in the list of targets, if it is, replace 'priest' with the value in @temp_target. Here is the code I'm using.

Code:

#IF (@elderly_priest_count=1 AND @temp_target!=0) {
  #IF (%item( @target_list, 1)="priest") {
    %item( @target_list, 1) = @temp_target
  }
}


when I check the syntax it says there is an unmatched bracket at where the equal sign is in the third line of code. Also, I know this code is only checking to see if the first item in the variable is 'priest'. Is there any way to check if it's anywhere in the list at one time? And if it is, find out what position in the list it's at? Thanks in advance.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Wed Jun 02, 2010 3:20 am   
 
1)when I check the syntax it says there is an unmatched bracket at where the equal sign is in the third line of code.

Can't start a line with %, nor can you use a function as the "a" in a=b syntax. If you want to use a function to draw out a string value representing a variable name, you will need to use #VARIABLE.

2)Is there any way to check if it's anywhere in the list at one time? And if it is, find out what position in the list it's at?

Check out %ismember(). It returns the element number, or 0 if it's not a member of the list.
_________________
EDIT: I didn't like my old signature
Reply with quote
Stevestones01
Beginner


Joined: 25 May 2010
Posts: 14

PostPosted: Wed Jun 02, 2010 3:47 am   
 
thanks for the quick answer. It helped alot Very Happy
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