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


Joined: 18 Oct 2002
Posts: 11
Location: Australia

PostPosted: Tue May 20, 2003 7:37 am   

Loose the last char of previous string in a list
 
I'm using the below script to set a stringlist of targets:
#ONINPUT {^t(%d) (%w)$} {#gag;#var targetlist %replaceitem( %2, %1, @targetlist);#Echo Target %1 = %item( @targetlist, %1)}

My intent is to be able to maintain a list of targets by entering them in the format 't1 Zugg', 't2 Bob', 'tn Targetn'.

It works fine if the item(n) already exists, but if it does not exist Zmud deletes the last caracter off what was the last record in the string, so the result in the above example if t3 was Targetn is:
"Zugg|Bo|Targetn"
Note: the missing 'b' from Bob

Now, being a target list I dont want to simply additem, as I want the item to go onto the record I specify.

Surly I don't have to check if the record exists before replacing it?

Anyone see a proper way to do this?

ZMub 6.16 btw.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Tue May 20, 2003 11:15 am   
 
The loss of the last character when using %replaceitem to add items is a bug that was fixed around version 6.25. I would reccommend you upgrade to the current public version.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Tue May 20, 2003 3:21 pm   
 
No, of course you don't have to check whether an item exists before using %replaceitem. If the item doesn't exist (the list isn't that long) zMUD will just ignore the function, since it's meaningless. For instance, replace the 79th word in this paragraph with "Oops".

You might also note that using %replaceitem means you'll drop the item being replaced. It won't insert an item. Thus, if you replace item 2 in {Zugg|Bob} you'll still have a two-item list and Bob won't be on it.

LightBulb
Advanced Member
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