|
Thread: How to "continue" in for loops!? | |
|
piggychu620
Adventuring Hero
|
posted September 25, 2018 08:53 AM |
|
|
How to
!!FU:E; is equivalent to break; in C#, then how about continue;!?
Is there any way to let the for loops (!!DO) skip the current irritation or go to the next one without exiting the function completely!?
Much appreciated!!!
|
|
Salamandre
Admirable
Omnipresent Hero
Wog refugee
|
posted September 25, 2018 09:19 AM |
|
|
Examples:
!!DO12345/1/10/1:P; run from 1 to 10
Function skips when x16 is less than 5
!?FU12345;
!!FU&x16<6:E;
[...]
Function terminates when x16 = 7
!?FU12345;
[...]
!!VRx16&x16=7:S99; set x16 to bigger value than specified in loop, loop ends
!!FU&x16=99:E;
____________
Era II mods and utilities
|
|
piggychu620
Adventuring Hero
|
posted September 25, 2018 09:29 AM |
|
|
Salamandre said: Examples:
!!DO12345/1/10/1:P; run from 1 to 10
Function skips when x16 is less than 5
!?FU12345;
!!FU&x16<6:E;
[...]
Function terminates when x16 = 7
!?FU12345;
[...]
!!VRx16&x16=7:S99; set x16 to bigger value than specified in loop, loop ends
!!FU&x16=99:E;
Thanks!
But when I use E, the function will just exit "completely"!
"Anything" after that is never executed!
And the !!DO command will just be terminated!
Can you please tell me where did I do wrong!?
Much appreciated!!!
|
|
Salamandre
Admirable
Omnipresent Hero
Wog refugee
|
posted September 25, 2018 09:31 AM |
|
|
I have no crystal ball, post code
|
|
piggychu620
Adventuring Hero
|
posted September 25, 2018 09:55 AM |
|
|
Salamandre said: I have no crystal ball, post code
My apologies!
I had misunderstood what E does!
When I showed x16 in the for loop, it DID go through ALL the irritations without breaking it!
So it must be the code itself problematic!
I don't know where the problem is and still working on it!
Thank you VERY much for your help!
|
|
piggychu620
Adventuring Hero
|
posted September 25, 2018 10:14 AM |
|
|
I made a script to add additional monsters at the start of each week.
The monsters was added just fine.
But after it finished, the whole game just CRASHED!!!
Could somebody PLEASE tell me where I did wrong!?
Much appreciated!!!
ZVSE
!#UN:X?v11/?v12; Get the size of the map
!#VRv11:-1; Make it 0 based
!#TM1:S1/999/7/2; Timer initialization
!?TM1; Timer trigger
!!DO10001/1/100/1; For loop
!?FU10001;
!!VRy1:S0 Rv11; Randomize x coordinate
!!VRy2:S0 Rv11; Randomize y coordinate
!!UN:Ey1/y2/0; Check if such coordinate is available
!!FU&1:E; Skip if not available
!!VRy3:S0 R192; Randomize creature subtype
!!VRy3&y3>121:+1; Skip all Not Used subtypes
!!VRy3&y3>123:+1;
!!VRy3&y3>125:+1;
!!VRy3&y3>127:+1;
!!UN:Iy1/y2/0/54/y3; Place created creature at (y1,y2)
!!MA:Ly3/?v5; Get creature level
!!VRv5:+1; Make it 1 based
!!VRv5:*10; Multiply by 10
!!VRv6:S1 Rv5; Randomize amount
!!MOy1/y2/0:Gv6; Set amount
|
|
Salamandre
Admirable
Omnipresent Hero
Wog refugee
|
posted September 25, 2018 10:27 AM |
|
|
Please, comments on each script line so we can get what you want it to do.
What is this??
!!UN:Iy1/y2/0/54/y3;
This will add new monster, not add to the existing stack at location. Game will crash when two stacks at same position.
____________
Era II mods and utilities
|
|
piggychu620
Adventuring Hero
|
posted September 25, 2018 10:38 AM |
|
|
Salamandre said: Please, comments on each script line so we can get what you want it to do.
Updated.
Quote:
What is this??
!!UN:Iy1/y2/0/54/y3;
This will add new monster, not add to the existing stack at location. Game will crash when two stacks at same position.
Won't the !!UN:E check that for me!?
|
|
Salamandre
Admirable
Omnipresent Hero
Wog refugee
|
posted September 25, 2018 10:46 AM |
|
|
This:
!!VRy3&y3>121:+1; Skip all Not Used subtypes
!!VRy3&y3>123:+1;
!!VRy3&y3>125:+1;
!!VRy3&y3>127:+1;
Should be
!!VRy3&y3=121:+1; Skip all Not Used subtypes
!!VRy3&y3=123:+1;
!!VRy3&y3=125:+1;
!!VRy3&y3=127:+1;
In original state, will add +4 each time y3>127
faster syntax:
!!VRy3|y3=121/y3=123/y3=125/y3=127:+1; Add +1 if y3 = 121 OR y3=123 etc
____________
Era II mods and utilities
|
|
piggychu620
Adventuring Hero
|
posted September 25, 2018 11:11 AM |
|
|
Salamandre said: This:
!!VRy3&y3>121:+1; Skip all Not Used subtypes
!!VRy3&y3>123:+1;
!!VRy3&y3>125:+1;
!!VRy3&y3>127:+1;
Should be
!!VRy3&y3=121:+1; Skip all Not Used subtypes
!!VRy3&y3=123:+1;
!!VRy3&y3=125:+1;
!!VRy3&y3=127:+1;
In original state, will add +4 each time y3>127
faster syntax:
!!VRy3|y3=121/y3=123/y3=125/y3=127:+1; Add +1 if y3 = 121 OR y3=123 etc
Thanks!
I found out that the problem is my original range includes War Machines and the Commanders!
That's why the game crashed!
|
|
|