[HELP] AGAIN command not working.

222 views
Skip to first unread message

Blake Regehr

unread,
Mar 29, 2018, 6:30:55 PM3/29/18
to PuzzleScript
Hey! I am making a game inspired by the puzzling scenarios you get yourself into when you play a game like Steamworld Dig or Dig Dug. I need to make rocks fall after you dig under them and I'd like a smooth animation, but the again command seems to fire off instantly and there's no delay. I've used again_interval at the beginning of my code, but it didn't change anything. The second reason I'd like this again command is that it looks like when two rocks fall, they crush each other into one rock. I'd love to share the link to the project, but it seems that GitHub is down. I'll post some code here.

(Rock pushing)
[ >  Player | Rock ] -> [  >  Player | > Rock  ]


(Player falling / gravity)

late down [Player | No Solid] -> [ | Player] again

late down [UnstableRock | No Solid] -> [ | UnstableRock]again
late down [PhysicsObj | No Solid] -> [ | PhysicsObj]again
late down [Rock | No Solid] -> [ UnstableRock | No Solid]
late down [UnstableRock | Solid] -> [Rock | Solid]



(digging)
Left [ > Player | Dirt] -> [ > Player | ]
Right [ > Player | Dirt] -> [ > Player | ]
Down [ > Player | Dirt] -> [ > Player | ]
Up [ > Player | Dirt] -> [ Player | ]

(collecting gem)
[ > Player | Gem] -> [ > Player | ]

Can anyone explain what is happening?

Chris Pickel

unread,
Mar 30, 2018, 3:07:51 AM3/30/18
to Blake Regehr, PuzzleScript
Rules apply repeatedly until they no longer can be applied. With these rules, the rock falls and falls before even getting to the “again” tick (you should see the same behavior even without “again”). You want to have the rule apply only once to each rock in each tick.

One way to do this is to add a new object (Falling) that marks objects that should fall, and remove it after it has applied to a given rock:
late [Rock] -> [Falling Rock]
late down [Falling Rock | no Solid] -> [| Rock] again
late [Falling] -> []

Another way is to move the rocks with motions, which automatically apply only once. But for that, you would have to delay falling to the “again” tick. You can detect that with “[stationary Player]”:
[stationary Player] [Rock] -> [stationary Player] [down Rock]
late down [Rock | no Solid] -> again

In the second approach, the rock will wait until after the player finishes moving to start falling.

--
You received this message because you are subscribed to the Google Groups "PuzzleScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puzzlescript...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Skalmantas Šimėnas

unread,
Mar 30, 2018, 10:06:31 AM3/30/18
to PuzzleScript
Iterating on what Chris said:
You already differentiate Rock and UnstableRock so there's no need for "falling" for that specific purpose. For rocks to fall more slowly, I think all you need to change is this line:
late down [UnstableRock | No Solid] -> [ | Rock]again
But since gravity is quite universal for most objects, I'd choose the new object approach (and I actually do just that in my own game that has gravity). To make something complicated in puzzlescript, you need to make lots of helper objects. A very basic 2x1 sized box in my game is a compound of many "side of a box" objects, a background object and the box "controller" itself that everything else is "attached" to. All this mess gets "tagged" and "untagged" many times during one turn by adding specific invisible objects on top and deleting them.

To understand "again" and puzzlescript rules better, you should check out some documentation pages like this one, then enable `verbose_logging` in the prelude and maybe even try out the universal rule I use for my own game (not applicable in every game but I like this rule):
[] -> again
Reply all
Reply to author
Forward
0 new messages