|
Dasyr Newbie
Joined: 29 Jan 2016 Posts: 8
|
Posted: Tue Sep 12, 2017 8:47 am
Timing Issue with #LOOP? |
Code:
Code: |
#DELCLASS {CORE|RADIATION}
#CLASS {CORE|RADIATION}
#VARIABLE radTemp {}
#VARIABLE radActual {}
#VARIABLE radProjected {}
#VARIABLE radDifference {}
#VARIABLE radCostArray {brawn|40|grace|40|mettle|40|wits|40|tenacity|40|discipline|40|attack|5|defense|5|damage|10|ascendancy|4|protection|4|power|8|resistance|8|speed|12|health|1|mana|2|landing|1|enchantment|1|crush_soak|1000|cut_soak|1000|stab_soak|1000|movement_speed|1000}
#ALIAS radAdd {#SAY OK ~[~%1: %1~]~[~@radTemp~[~%2~]: %-2~];#VARIABLE radTemp {%lower(%2)};#LOOP 1,%numitems(@radCostArray) {#IF @radCostArray.%i=@radTemp {#SAY INDEXED AT %i}}}
#ALIAS radDiffer {}
#TRIGGER {Magic type : {A|An} (*) (%w) with (%d) points of radiation.} {#SAY COLLECT NOW: RAD %3 - TYPE %1 %2;#VARIABLE radActual {%3};#T+ {CORE|RADIATION|CAPTURE}}
#CLASS {CORE|RADIATION|CAPTURE}
#TRIGGER {-------------------------------------------------------------------------------} {#say GOODNIGHT COLLECTOR;#T- {CORE|RADIATION|CAPTURE}}
#TRIGGER {^Bonus : Contains (%d) points of (%w).} {radAdd %1 %2}
#TRIGGER {^Bonus : +(%d) to (%w).} {radAdd %1 %2}
#TRIGGER {^Bonus : +(%d) (%w).} {radAdd %1 %2}
#TRIGGER {^Bonus : +(%d)~% soak vs (%w) damage.} {radAdd %1 %2_soak}
#TRIGGER {^Bonus : Auto-absorbs (%d) points of (%w) damage ~(see 'help armour'~).} {radAdd %1 %2_absorb}
#T- {CORE|RADIATION|CAPTURE}
#CLASS 0
|
In the alias radAdd I am having some type of issue, it is spitting out the entire array @radCostArray instead of checking the specific data designated with .%i, this only happens while the alias is triggered but typing in a value with the alias for example "radAdd 100 wits" will return 7 |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4689 Location: Pensacola, FL, USA
|
Posted: Tue Sep 12, 2017 10:35 am |
Your #IF expressions need to be inside (parenthesis)
Also, making use of #LOCAL $vars might speed up runtime a hair.
There is also no need to specify a range if you are going to test all values.
#LOOP %numitems(@radCostArray) {
$this=%db(@radCostArray,%i)
#IF ($this=@radTemp) {#SAY INDEXED AT %i}
}
You could also start it with:
#FORALL %dbkeys(@radCostArray) { |
|
_________________ Discord: Shalimarwildcat |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4689 Location: Pensacola, FL, USA
|
Posted: Wed Sep 13, 2017 8:48 am |
oh, right zMUD doesn't have #LOCAL $vars, that's a CMUD thing.
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
|
|