Announcement: Be excellent to each other.


Caravel Forum : Caravel Boards : General : I don't get If. (Seriously, how the heck does this work?)
New Topic New Poll Post Reply
Poster Message
FeedtheGentryii
Level: Goblin
Rank Points: 24
Registered: 03-08-2021
IP: Logged
icon I don't get If. (+2)  
It doesn't throw me a question mark if a Wait for command is used, but it doesn't seem to trigger when the Wait for is satisfied, and the in-game documentation won't tell me how it works. I've tried looking online, but there doesn't seem to be much. How do script?

____________________________
They're so cute, though...
03-13-2021 at 06:48 AM
View Profile Send Private Message to User Show all user's posts Quote Reply
kieranmillar
Level: Smitemaster
Rank Points: 2670
Registered: 07-11-2014
IP: Logged
icon Re: I don't get If. (+2)  
A Wait For command will pause the script until the thing it is waiting for happens, but if you put an If in front of it, then the thing is checked only right now, and the code between the If and EndIf is only executed if the thing happened right now.

Basically using If means its no longer a Wait, if that makes any sense.
03-13-2021 at 07:00 AM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Dragon Fogel
Level: Smitemaster
Rank Points: 2434
Registered: 06-21-2014
IP: Logged
icon Re: I don't get If. (+2)  
By default, the game will only check the If condition once, and if the condition isn't satisfied, it will move on with the script.

To get around this, you can either use the "Wait for" condition on its own, which will make the script hold off on activating until it's satisfied; or you can use the Label command to make a loop. To do the latter, just make a label with any name before the If statement, and after the If End command, have a "Go To Label" command to return to the label.
03-13-2021 at 07:03 AM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
FeedtheGentryii
Level: Goblin
Rank Points: 24
Registered: 03-08-2021
IP: Logged
icon Re: I don't get If. (0)  
kieranmillar wrote:
A Wait For command will pause the script until the thing it is waiting for happens, but if you put an If in front of it, then the thing is checked only right now, and the code between the If and EndIf is only executed if the thing happened right now.

Basically using If means its no longer a Wait, if that makes any sense.
I thought I tried this interpretation. Is the player simply no longer touching "me" once the script actually happens? (I used a loop with this, too...)

____________________________
They're so cute, though...
03-13-2021 at 07:13 AM
View Profile Send Private Message to User Show all user's posts Quote Reply
FeedtheGentryii
Level: Goblin
Rank Points: 24
Registered: 03-08-2021
IP: Logged
icon Re: I don't get If. (0)  
Ah. Adding "Wait 1 turn" fixed it. I assume the script interpreter saw an infinite loop and decided to abort.

____________________________
They're so cute, though...
03-13-2021 at 07:16 AM
View Profile Send Private Message to User Show all user's posts Quote Reply
mauvebutterfly
Level: Smitemaster
Avatar
Rank Points: 720
Registered: 05-03-2015
IP: Logged
icon Re: I don't get If. (+1)  
Yes, there is infinite loop detection.

You might want to test your script with both "wait 1 turn" and "wait 0 turns" just to make sure it's doing exactly what you intend. Waiting 1 turn might actually be causing a delay in your script that could lead to issues.

Somehow "wait 0 turns" and [no code at all] aren't the same thing.

DRODScript takes some getting used to.

____________________________
106th Skywatcher
03-13-2021 at 02:03 PM
View Profile Send Private Message to User Show all user's posts This architect's holds Quote Reply
Xindaris
Level: Smitemaster
Avatar
Rank Points: 1531
Registered: 06-13-2015
IP: Logged
icon Re: I don't get If. (+1)  
Functionally, "Wait n turns" means "stop doing things this turn, then wait/don't do anything for the next n turns". So "Wait 0" means "just stop doing things this turn". It would be much clearer to newcomers if there were a separate command called something like "finish turn", but lumping the function into the wait command is efficient in its own weird sort of way, I guess?

____________________________
109th Skywatcher

Here are some links to Things!
Click here to view the secret text


[Last edited by Xindaris at 03-13-2021 05:08 PM]
03-13-2021 at 05:06 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Kaelyn
Level: Delver
Rank Points: 76
Registered: 01-21-2019
IP: Logged
icon Re: I don't get If. (0)  
Xindaris wrote: It would be much clearer to newcomers if there were a separate command called something like "finish turn",
Not just clearer, but possibly more useful, too! Since the Wait command can be injected with _MyScript, this means you can be using _MyScriptX to modify some bit of code elsewhere, then be forced to reset it back to -9999 just before you reach the Wait 0 command. So you're offloading _MyScriptX to some dummy variable for temporary storage, and you have to remember to set it back after Wait 0, and it just adds lots and lots of extra lines and little things to remember if you want to make full use of DROD scripting.

For the sake of simpler code and more powerful programming, I wish there was an option you could check to not inject _MyScript into the command on a given line. Maybe even a flexible interface where the architect can specify which parameters aren't injected and which ones are.
03-13-2021 at 07:04 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
Xindaris
Level: Smitemaster
Avatar
Rank Points: 1531
Registered: 06-13-2015
IP: Logged
icon Re: I don't get If. (0)  
Yeah, the ideal situation would be a way to set any parameter to any variable from within the parameter selection interface, so you wouldn't need to override anything at all, but I'm under the impression that the myscript system is just the best that can be done within the limitations of how scripting basically functions in the first place.

____________________________
109th Skywatcher

Here are some links to Things!
Click here to view the secret text


[Last edited by Xindaris at 03-13-2021 07:37 PM]
03-13-2021 at 07:36 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
FeedtheGentryii
Level: Goblin
Rank Points: 24
Registered: 03-08-2021
IP: Logged
icon Re: I don't get If. (0)  
mauvebutterfly wrote:
Yes, there is infinite loop detection.

You might want to test your script with both "wait 1 turn" and "wait 0 turns" just to make sure it's doing exactly what you intend. Waiting 1 turn might actually be causing a delay in your script that could lead to issues.

Somehow "wait 0 turns" and [no code at all] aren't the same thing.

DRODScript takes some getting used to.
Yeah, I think this actually did happen. Somehow I didn't bother trying wait 0 turns, even though I saw you do it previously (in the speed-architecture contest thing, to switch between Beethro and a Wubba). I wasn't actually using the scripted element for anything, though, lol.

____________________________
They're so cute, though...
03-14-2021 at 10:05 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
New Topic New Poll Post Reply
Caravel Forum : Caravel Boards : General : I don't get If. (Seriously, how the heck does this work?)
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.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.