 |
xekon Apprentice
Joined: 11 Oct 2007 Posts: 154
|
Posted: Mon Dec 10, 2007 1:16 pm
Need some help understanding a change in cmud from zmud involving space in vars |
I have converted most of my scripts and have them working in cmud, i also fixed all errors shown in the compatibility report, now I need help fixing the stuff that I cant for the life of my understand why its not working. I am really struggling with this and that, but i really like cmud and would like to try and tackle all of my issues if possible.
my inventory is scanned by a script and all items have their string stored into a list var, then each item is handled one at a time, first stripping add characters, that are not likely part of the keyword used to handle the item.... for some reason when I get to the part that strips exclamation point it also strips the empty space between the words on my item. Below the code I have shown the mud output with the echos received so you can see what i mean. the item (!(Light Relief)!) ends up becoming LightRelief
| Code: |
#T- sellmachinego
#loop %numitems( @sellitem) {
itemreplace=%item( @sellitem, %i)
#echo item is %item( @sellitem, %i)
itemreplace=%replace( @itemreplace, "(G)", "")
itemreplace=%replace( @itemreplace, "(H)", "")
itemreplace=%replace( @itemreplace, "(I)", "")
itemreplace=%replace( @itemreplace, "(M)", "")
itemreplace=%replace( @itemreplace, "(B)", "")
itemreplace=%replace( @itemreplace, "(R)", "")
itemreplace=%replace( @itemreplace, "'s", "")
itemreplace=%replace( @itemreplace, "'", "")
itemreplace=%replace( @itemreplace, "-", "")
itemreplace=%replace( @itemreplace, "=", "")
itemreplace=%replace( @itemreplace, ",", "")
itemreplace=%replace( @itemreplace, ".", "")
itemreplace=%replace( @itemreplace, "<", "")
itemreplace=%replace( @itemreplace, ">", "")
#echo item is @itemreplace
itemreplace=%replace( @itemreplace, "!", "")
#echo item is @itemreplace
itemreplace=%replace( @itemreplace, ":", "")
itemreplace=%replace( @itemreplace, "$", "")
itemreplace=%replace( @itemreplace, "%", "")
itemreplace=%replace( @itemreplace, "#", "")
itemreplace=%replace( @itemreplace, "?", "")
itemreplace=%replace( @itemreplace, "+", "")
itemreplace=%replace( @itemreplace, "/", "")
itemreplace=%replace( @itemreplace, "\", "")
itemreplace=%replace( @itemreplace, "|", "")
itemreplace=%replace( @itemreplace, "{", "")
itemreplace=%replace( @itemreplace, "}", "")
itemreplace=%replace( @itemreplace, ")", "")
itemreplace=%replace( @itemreplace, "(", "")
itemreplace=%replace( @itemreplace, "]", "")
itemreplace=%replace( @itemreplace, "[", "")
itemreplace=%replace( @itemreplace, "^", "")
itemreplace=%replace( @itemreplace, "*", "")
#echo item is @itemreplace
sellitem=%replaceitem( @itemreplace, %i, @sellitem)
}
sellsomethin |
sell onwalkend
inv
You are carrying:
(44) (!(Light Relief)!) [4]
(K)(G)(H) Dagger of Aardwolf [40]
(K)(G)(H) Sword of Magic Axe +1 [40]
(K)(G)(H) Swift Galleon [1]
(K)(G)(H) Watchmen's Charitable Chalice [1]
( 2) (K)(G)(H) a Bag of Aardwolf [21]
[ 183/738hp 741/741mp 943/943mv 190tnl 0qt ]
item is !(Light Relief)!
item is !(Light Relief)!
item is LightRelief
item is LightRelief
item is (K)(G)(H) Dagger of Aardwolf
item is (K) Dagger of Aardwolf
item is (K) Dagger of Aardwolf
item is K Dagger of Aardwolf
item is (K)(G)(H) Sword of Magic Axe +1
item is (K) Sword of Magic Axe +1
item is (K) Sword of Magic Axe +1
item is K Sword of Magic Axe 1
item is (K)(G)(H) Swift Galleon
item is (K) Swift Galleon
item is (K) Swift Galleon
item is K Swift Galleon
item is (K)(G)(H) Watchmen's Charitable Chalice
item is (K) Watchmen Charitable Chalice
item is (K) Watchmen Charitable Chalice
item is K Watchmen Charitable Chalice
item is (K)(G)(H) a Bag of Aardwolf
item is (K) a Bag of Aardwolf
item is (K) a Bag of Aardwolf
item is K a Bag of Aardwolf
sell LightRelief |
|
|
|
 |
Vijilante SubAdmin

Joined: 18 Nov 2001 Posts: 5187
|
Posted: Mon Dec 10, 2007 3:19 pm |
I think it is a problem with the parenthesis which seems very odd. I will check it in the latest beta version. I would suggest cleaning up the script some this way.
| Code: |
itemreplace=%replace( @itemreplace, "-", "")
itemreplace=%replace( @itemreplace, "=", "")
itemreplace=%replace( @itemreplace, ",", "")
itemreplace=%replace( @itemreplace, ".", "")
itemreplace=%replace( @itemreplace, "<", "")
itemreplace=%replace( @itemreplace, ">", "")
itemreplace=%replace( @itemreplace, "!", "")
itemreplace=%replace( @itemreplace, ":", "")
itemreplace=%replace( @itemreplace, "$", "")
itemreplace=%replace( @itemreplace, "%", "")
itemreplace=%replace( @itemreplace, "#", "")
itemreplace=%replace( @itemreplace, "?", "")
itemreplace=%replace( @itemreplace, "+", "")
itemreplace=%replace( @itemreplace, "/", "")
itemreplace=%replace( @itemreplace, "\", "")
itemreplace=%replace( @itemreplace, "|", "")
itemreplace=%replace( @itemreplace, "{", "")
itemreplace=%replace( @itemreplace, "}", "")
itemreplace=%replace( @itemreplace, ")", "")
itemreplace=%replace( @itemreplace, "(", "")
itemreplace=%replace( @itemreplace, "]", "")
itemreplace=%replace( @itemreplace, "[", "")
itemreplace=%replace( @itemreplace, "^", "")
itemreplace=%replace( @itemreplace, "*", "") |
Becomes
| Code: |
| ItemReplace=%subchar(@ItemReplace,"-=,.><!:$%#?+/\|{})(][^*", "") |
I would also suggest it actually better to do that replacement before the %additem you are using in your trigger. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
 |
Vijilante SubAdmin

Joined: 18 Nov 2001 Posts: 5187
|
Posted: Mon Dec 10, 2007 3:53 pm |
I checked out the problem you are having in the latest beta, and am actually surprised it doesn't surface sooner. It doesn't look like a bug.
The variable is getting correctly set, but when it is referenced it looks like a function and gets fully evaluated. Local variables are not subject to being tested as a funciton and I suggest using one of them. Also the %nn references in your trigger are not subject to this test, so I again strongly suggest doing the replacement directly there.
If you really wish to use the variable in the same fashion as you have it, then set the variable type to String(literal) and it will not be subject to the function testing. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
 |
xekon Apprentice
Joined: 11 Oct 2007 Posts: 154
|
Posted: Mon Dec 10, 2007 8:05 pm |
AHH Thank you so much for the suggestion of local variables. I never even used them before, I am going to go through all my scripts and look them over.
Thanks again for helping me this time and all the other times that you have helped me as well. |
|
|
|
 |
xekon Apprentice
Joined: 11 Oct 2007 Posts: 154
|
Posted: Mon Dec 10, 2007 8:27 pm |
WOW! I really like local variables, and they claim to be much much faster... going to rewrite a lot of my code.
| Code: |
sellquantity=%additem(%1,@sellquantity)
#echo quantity is %1
$itemreplace=%2
$itemreplace=%replace($itemreplace,"(G)","")
$itemreplace=%replace($itemreplace,"(H)","")
$itemreplace=%replace($itemreplace,"(I)","")
$itemreplace=%replace($itemreplace,"(M)","")
$itemreplace=%replace($itemreplace,"(B)","")
$itemreplace=%replace($itemreplace,"(R)","")
$itemreplace=%replace($itemreplace,"'s","")
$itemreplace=%subchar($itemreplace,"-=,.><!:$%#?+/\|{})(][^'*","")
sellitem=%additem($itemreplace,@sellitem)
#echo item is $itemreplace |
|
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Mon Dec 10, 2007 9:18 pm |
You can do a speed test by putting the line $time=%secs before your code and #say Time: (%secs-$time) after it. That'll give you a way to compare the relative speeds of the two scripts.
|
|
|
|
 |
|
|
|
|
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
|
|