Announcement: Why not try our official idea generator for inspiration when making puzzles?


Caravel Forum : DROD Boards : Architecture : Question concerning infinite loops in scripts
New Topic New Poll Post Reply
Poster Message
vinheim
Level: Smiter
Rank Points: 300
Registered: 05-31-2007
IP: Logged
icon Question concerning infinite loops in scripts (0)  
If I've read correctly somewhere, scripts that have executed more commands in one turn than there are script commands in that character will be considered being "in an infinite loop" and the script will stop.

What if a script is running a loop, say.. 10 times with each loop increasing a variable by 1 and a special thing happening once the variable is equal to 10? Because there are more commands being run in one turn than there are script commands, this special thing won't happen.

Now what if the infinite loop thing only happens if no variable is changing? If there is no check for the changing variable (nothing special will happen no matter how large this variable is), then it will run in an infinite loop that might crash DRoD.

So how exactly is this whole infinite loop thing being handled anyway?
10-31-2010 at 03:21 AM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
TFMurphy
Level: Smitemaster
Rank Points: 3118
Registered: 06-11-2007
IP: Logged
icon Re: Question concerning infinite loops in scripts (+1)  
A script is considered to be in an infinite loop once it has run more commands than there are in the script since the last time the script changed a variable, *OR* the script has run more than 1000 change/set variable commands.

So long as a single script loop changes a variable before it enters the next loop, then there's usually no danger.

I will note, however, that a DROD room contains 1216 squares, so if you're relying on a single script to change variables according to what's in every square, you may run into trouble that way.

EDIT: Oh, and no infinite loop script will crash DROD. As soon as DROD detects one of the above conditions, it will automatically stop the script and it won't run again until the room is reset.

[Last edited by TFMurphy at 10-31-2010 03:31 AM]
10-31-2010 at 03:29 AM
View Profile Send Private Message to User Show all user's posts This architect's holds Quote Reply
vinheim
Level: Smiter
Rank Points: 300
Registered: 05-31-2007
IP: Logged
icon Re: Question concerning infinite loops in scripts (0)  
It was more of a curiousity thing, so thanks for clarifying!
10-31-2010 at 03:31 AM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
New Topic New Poll Post Reply
Caravel Forum : DROD Boards : Architecture : Question concerning infinite loops in scripts
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.9
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.