Checking for existence in rules

180 views
Skip to first unread message

baku...@yahoo.com

unread,
Oct 27, 2017, 11:29:36 AM10/27/17
to PuzzleScript
I know you can use the No keyword very effectively in the WinConditions section, but I am wondering: is it possible to use it in the Rules as well? My scenario is that I want there to be a door object that cannot be passed through, but it becomes an open door object after you catch all the monsters on the level. When you catch a monster, it becomes a "CapturedMonsters" object instead of a Monsters object, so I tried the statement
[Door][No Monsters] -> [OpenDoor][]
to no avail. I am pretty new to Puzzlescript so any help would be much appreciated!

Stephen Lavelle

unread,
Oct 27, 2017, 11:36:23 AM10/27/17
to baku...@yahoo.com, PuzzleScript
[no monsters] matches every tile without a monster.  There's no good syntax for checking if I a monster doesn't exist.  You can do some weird inverting to get the same effect:

[monster] [] -> [monster] [temp] (flood all tiles with temp if there's a monster)
random [door no temp] -> [ opendoor ] (open a door if there's a temp)
[temp] -> [] (remove all temps)

baku...@yahoo.com

unread,
Oct 27, 2017, 11:47:57 AM10/27/17
to PuzzleScript
Ah, that's a shame. Thanks!

Hugo

unread,
Oct 29, 2017, 2:32:17 PM10/29/17
to PuzzleScript
Oh, that explains some similar issues I had with my game. That certainly clarifies things now. Thanks!

Joe Shermetaro

unread,
May 9, 2020, 4:32:22 PM5/9/20
to PuzzleScript
I was searching for an answer to the same question. An alternative solution is to put these two rules at the end:

late [DoorClosed] -> [DoorOpen]
late [Monster] [DoorOpen] -> [Monster] [DoorClosed]

This opens the door every turn, but then instantly closes it again unless there are no monsters remaining.

Pancake Robot

unread,
May 27, 2020, 6:06:20 PM5/27/20
to PuzzleScript
This gives me the visual of a guard peeking out of the door every turn only to slam it shut when he sees a monster.

Builder17

unread,
Jul 24, 2020, 10:23:58 AM7/24/20
to PuzzleScript


torstai 28. toukokuuta 2020 1.06.20 UTC+3 Pancake Robot kirjoitti:
This gives me the visual of a guard peeking out of the door every turn only to slam it shut when he sees a monster.


But would this work?

late [DoorClosed] -> [DoorClosed Temp]
late [Monster] [DoorClosed Temp] -> [Monster] [DoorClosed] 
late [DoorClosed Temp] -> [DoorOpen]

I believe it would.
Reply all
Reply to author
Forward
0 new messages