|
Deavr Beginner
Joined: 18 Oct 2002 Posts: 11 Location: Australia
|
Posted: 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. |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: 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.
|
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: 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 |
|
|
|
|
|
|
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
|
|