Nested Rules statement Question
Hello GS Community! New guy here with a question about Nested Rules statements.
Basically I spent a couple hours yesterday watching @tshirtbooth tutorials and they've been really helpful.
So today I started to tinker with GS (Windows Beta) and things have gone smoothly, just practicing a simple Main Menu.
However, I'm having trouble using multiple nested Rules in my actor (which acts as the background).
Here's the backstage behavior:
- Rule: When All are happening
-- If game.Clock.Hour >= 14
-- if game.Clock.Hour < 19
--- do
---- set image to: img01
---- then I also display the current game.Clock.Hour for good measure
--- else (this is where things stop working properly)
---- Rule: When All are happening
----- if game.Clock.Hour >= 19
----- if game.Clock.Hour < 6
------ do
------- set image to: img02
------- display current game.Clock.Hour
When the first Rule is satisfied, the Actor's image changes correctly, and the game.Clock.Hour displays perfectly as well.
However, when I purposely dissatisfy it by changing my system time, the Else statement does not execute even though the 2nd Rule is True.
The Actor's background does not change to img02 and the game.Clock.Hour is not printed as well.
I'm not sure if this is just a Windows Beta hiccup, but any help would be greatly appreciated!
Basically I spent a couple hours yesterday watching @tshirtbooth tutorials and they've been really helpful.
So today I started to tinker with GS (Windows Beta) and things have gone smoothly, just practicing a simple Main Menu.
However, I'm having trouble using multiple nested Rules in my actor (which acts as the background).
Here's the backstage behavior:
- Rule: When All are happening
-- If game.Clock.Hour >= 14
-- if game.Clock.Hour < 19
--- do
---- set image to: img01
---- then I also display the current game.Clock.Hour for good measure
--- else (this is where things stop working properly)
---- Rule: When All are happening
----- if game.Clock.Hour >= 19
----- if game.Clock.Hour < 6
------ do
------- set image to: img02
------- display current game.Clock.Hour
When the first Rule is satisfied, the Actor's image changes correctly, and the game.Clock.Hour displays perfectly as well.
However, when I purposely dissatisfy it by changing my system time, the Else statement does not execute even though the 2nd Rule is True.
The Actor's background does not change to img02 and the game.Clock.Hour is not printed as well.
I'm not sure if this is just a Windows Beta hiccup, but any help would be greatly appreciated!
Best Answer
-
gyroscope I am here.Posts: 6,598
Hi @TheGabFather
It should work as expected, although you don't need the two "if's" in the otherwise section. Try the following, and if that's still not working, possibly you've not put the "else" stuff in the topmost Otherwise; if that's not it, maybe there is a bug in the Windows version, perhaps....
Rule: When All conditions are valid:
attribute game.Clock.Hour >= 14
attribute game.Clock.Hour < 19
Change Image to: img01
Display Text
Otherwise
Change Image to: img02
Display Text
Hope that sorts it for you.""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Answers
Actually, I plan on introducing another Rule because i'm dealing with the entire 24hr clock (in my example I've only implemented two so far, where >=6 and <14 are still missing).
However I've already figured out the answer! If the current time is, say 19, it satisfies the first If of the 2nd Rule but NOT the second If!
I guess even if you're dealing with game.Clock.Hour GS still doesn't know that it should reset integer values that are over 24, back to 0.
The solution was to set the 2nd Rule to "Any" to satisfy.
Thanks for your help! I guess Windows Beta is still pretty robust for the most part.