Heroes of Might and Magic Community
visiting hero! Register | Today's Posts | Games | Search! | FAQ/Rules | AvatarList | MemberList | Profile


Age of Heroes Headlines:  
5 Oct 2016: Heroes VII development comes to an end.. - read more
6 Aug 2016: Troubled Heroes VII Expansion Release - read more
26 Apr 2016: Heroes VII XPack - Trial by Fire - Coming out in June! - read more
17 Apr 2016: Global Alternative Creatures MOD for H7 after 1.8 Patch! - read more
7 Mar 2016: Romero launches a Piano Sonata Album Kickstarter! - read more
19 Feb 2016: Heroes 5.5 RC6, Heroes VII patch 1.7 are out! - read more
13 Jan 2016: Horn of the Abyss 1.4 Available for Download! - read more
17 Dec 2015: Heroes 5.5 update, 1.6 out for H7 - read more
23 Nov 2015: H7 1.4 & 1.5 patches Released - read more
31 Oct 2015: First H7 patches are out, End of DoC development - read more
5 Oct 2016: Heroes VII development comes to an end.. - read more
[X] Remove Ads
LOGIN:     Username:     Password:         [ Register ]
HOMM1: info forum | HOMM2: info forum | HOMM3: info mods forum | HOMM4: info CTG forum | HOMM5: info mods forum | MMH6: wiki forum | MMH7: wiki forum
Heroes Community > Heroes 3.5 - WoG and Beyond > Thread: How to "continue" in for loops!?
Thread: How to "continue" in for loops!?
piggychu620
piggychu620


Adventuring Hero
posted September 25, 2018 08:53 AM
Edited by piggychu620 at 08:53, 25 Sep 2018.

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!!!

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Salamandre
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

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
piggychu620
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!!!

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Salamandre
Salamandre


Admirable
Omnipresent Hero
Wog refugee
posted September 25, 2018 09:31 AM

I have no crystal ball, post code

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
piggychu620
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!

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
piggychu620
piggychu620


Adventuring Hero
posted September 25, 2018 10:14 AM
Edited by piggychu620 at 10:36, 25 Sep 2018.

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

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Salamandre
Salamandre


Admirable
Omnipresent Hero
Wog refugee
posted September 25, 2018 10:27 AM
Edited by Salamandre at 10:28, 25 Sep 2018.

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

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
piggychu620
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!?

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Salamandre
Salamandre


Admirable
Omnipresent Hero
Wog refugee
posted September 25, 2018 10:46 AM
Edited by Salamandre at 10:49, 25 Sep 2018.

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

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
piggychu620
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!

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Jump To: « Prev Thread . . . Next Thread »
Post New Poll    Post New Topic    Post New Reply

Page compiled in 0.0383 seconds