|
chris-74269 Magician
Joined: 23 Nov 2004 Posts: 364
|
Posted: Thu Feb 01, 2007 2:05 am
var changing in loops |
when i see an item such as An item {23}. i want to loop 23 times to pick it up, however my trigger system is such that one trigger will catch the same A item2., Another item {12}. so what happens is it will loop 23 times get @oname, but in the middle after the A item2 goes by the loop changes to get item2 15 times and so on. is there anyway to send it to the loop as a variable but have the loop execute the value in oname 23 times rather than just call the @oname 23 times for its current value:?
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Feb 01, 2007 2:10 am |
You'll need to give examples of the code you're using, the input you're using, and the expected result. I can't understand what you mean from that description.
|
|
|
|
chris-74269 Magician
Joined: 23 Nov 2004 Posts: 364
|
Posted: Thu Feb 01, 2007 2:43 am |
ok so this is the trigger pattern:
\((?:w|o|a)\)([\a\s]+)\{([\d]+)\}\.
it will match something like
(o)An item {23}.
the code is this
#var oname %lower( %word( %1, %numwords( %1)))
#if (@playercheck = 0) {
#loop %2 {
get @oname
#if (@id = 1) {id @oname}
#if (@bags = 1) {put @oname in bag @buse}
}
}
so it should send get item 23 times
however, another trigger i have to deal when there is only one copy is pattern
\((?:w|o|a)\)([\a\s]+)\.
that will match something like
(o)An item.
with the code
#var oname %lower( %word( %1, %numwords( %1)))
#if (@playercheck = 0) {
get @oname
#if (@id = 1) {id @oname}
#if (@bags = 1) {put @oname in bag @buse}
}
so the problem becomes if the room goes like
(o)An item {20}.
(w)A weapon.
(a)Some Armour {3}.
it will send 3 get items, then when the (w) goes by @oname now becomes weapon and will do the next 10 as get weapon, then armours goes by and @oname is changed to armour so get armour is send get armour 7 times, then get weapon, and 3 more get armour. I know you can say just change it so the {23} trigger uses a different var than @oname, but then if the room goes
(o)Item {20}.
(w)Weapn {10}.
it will happen again
so what i want to do is make it so the loop sends get item 20 times, get weapon 10 times and not @oname 30 times. i tried doing things like @{oname} and such but it still didn't work. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Feb 01, 2007 2:50 am |
You need to use the #priority command to prevent other text from being parsed while the loop is being run.
|
|
|
|
chris-74269 Magician
Joined: 23 Nov 2004 Posts: 364
|
Posted: Thu Feb 01, 2007 2:58 am |
bah i was hoping it didnt need to come down to that but there was some force expression. does this mean i can't make an alarm go this same way? as in a trigger makes this alarm:
#var test stored
#tr {test} {#alarm +1 {@test}}
as in the alarm that is made will always have the text @test rather than "stored" |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Feb 01, 2007 3:02 am |
Well, #prio is the easiest way. You could possibly jiggle some workaround like that - it'd be so much easier with CMUD's local variables :( And, of course, the fact that this sort of problem doesn't even exist in CMUD since it doesn't process more text until your scripts are finished.
|
|
|
|
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Thu Feb 01, 2007 10:02 am |
I may be missing something--why are you using a variable at all?
Code: |
#if (@playercheck = 0) {
#loop %2 {get %lower( %word( %1, %numwords( %1)))}
#if (@id = 1) {#loop %2 {id %lower( %word( %1, %numwords( %1)))}}
#if (@bags = 1) {#loop %2 {put %lower( %word( %1, %numwords( %1))) in bag @buse}}
} |
Unless sending things in batches doesn't work for your mud, in which case you could go back to your old way just without variables. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Feb 01, 2007 10:10 am |
I assume it's to cut down on function calls, but that way will work too.
|
|
|
|
chris-74269 Magician
Joined: 23 Nov 2004 Posts: 364
|
Posted: Thu Feb 01, 2007 5:24 pm |
yeah i did it for the exact reason fang mentioned, and if i need to do additional processing all i have to change is the first var line and the rest will still stay the same
|
|
|
|
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Thu Feb 01, 2007 6:44 pm |
Yes, you're cutting down function calls and making it easier to edit--but it's also clearly not working for you.
How about:
Code: |
#for (%lower( %word( %1, %numwords( %1)))) {
#if (@playercheck = 0) {
#loop %2 {get %i}
#if (@id = 1) {#loop %2 {id %i}}
#if (@bags = 1) {#loop %2 {put %i in bag @buse}}
}} |
|
|
|
|
|
|