Skip to content

Instantly share code, notes, and snippets.

@hillexed
Last active June 16, 2019 23:30
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hillexed/c66fec6e54576d1086edd566ba2b55eb to your computer and use it in GitHub Desktop.
Save hillexed/c66fec6e54576d1086edd566ba2b55eb to your computer and use it in GitHub Desktop.
BABA has PORTAL GUN

Here's how my level implementing Portal in Baba is You works! If you haven't seen it, here's a video: https://streamable.com/9pflr

Baba is You is a game played with the arrow keys. How can Baba fire a portal gun and still have the ability to walk around? The answer: there's one more button the game allows, and that's the wait button - which makes baba stand still and allows a turn to pass in the game world. In this level, the wait button does more than wait - it fires the portal gun.

The skull crosses are a gadget to activate an arbitrary rule when the wait button is pressed. The following rules are used to set it up:

FUNGUS MAKE BABA
BABA ON FUNGUS IS MOVE AND MOVE
BABA ON SKULL IS EMPTY

This means that by surrounding a fungus with skulls, pressing a direction will do nothing, but waiting will cause the BABA IS MOVE AND MOVE rule to trigger and baba will be two tiles away from a skull (that's how double-move works in this game).

The Lexian wait detector™ exploits this to activate a rule: the move-and-moving baba lands on a skull (so it's not around to break text) but also pushes a rule into place. The text lands on ice, and ICE NOT NEAR BABA IS SHIFT breaks the rule as soon as a non-wait button is pressed and the stream of dying babas ceases.

BABA MAKE LINE is used to shoot the portal gun. Two Lexian Wait Detectors™ placed on top of one another can be used to toggle a rule back and forth every time wait is pressed. But we want the portal gun to switch between portals each time wait is HELD, not PRESSED. For this, trees are layered on top, and TREE IS STOP is activated via the rightmost Lexian Wait Detector™, preventing the text from being pushed by dying babas any more until wait is released.

This mechanism is also used to toggle between shooting lava and water and to change baba's color. The leftmost wait detectors do that - one wait detector pushing downwards, and one pushing upwards. These use the same TREE IS STOP trick to only swap when wait is pushed for the first time (a rising edge). This leftmost wait detector actually holds two rule activations to save space - both BABA IS RED/BLUE and LAVA/WATER IS EMPTY, which, before you make a portal, destroys the existing portal object. In order to use the same wait detector for both these rules, BELT IS SHIFT is used to position both RED/BLUE and LAVA/WATER on the same tiles. BELT IS SHIFT has a belt underneath the SHIFT, meaning BELT IS SHIFT breaks apart after one turn so the IS doesn't end up on the same tile as well. BABA IS NOT LAVA AND NOT WATER is used to stop these two different uses of the same wait detector from interacting - without it, the text would form BABA IS LAVA/WATER, and BABA IS BABA would stop the wait detector's BABA ON SKULL IS EMPTY from working.

The end result: pressing the wait button, which normally does nothing, swaps between shooting blue portals and orange portals, and changes baba's color to match.

From there, BABA MAKE LINE makes baba shoot a line, which moves thanks to LINE IS MOVE, and when it hits a wall LINE FACING WALL IS BOLT turns it into a bolt. Then BOLT MAKE LAVA/WATER takes hold, the bolt disappears, and LAVA/WATER MAKE LOVE creates the LOVEs under them, and the LOVE is what actually teleports things. The babas that are part of the Lexian Wait Detector™ will also shoot lines, so LINE NEAR SKULL IS EMPTY stops those lines from interfering with the mechanism. To ensure two portals of the same color aren't made, when a bolt appears all existing lines are cleared via LEVEL ON BOLT IS HOT and LINE IS MELT. The lava/water is float so the lava/water tiles don't get teleported themselves. Finally, there are some rules to clean up empty love when the water/lava disappears.

And there you have it: BABA HAS PORTAL GUN. If you want to play the level, you can download it in my custom level pack at https://gamebanana.com/maps/204137! (To play, you'll need to mod the game to enable the hidden level editor to play custom levels, so it's non-console versions only)

@vfig
Copy link

vfig commented Apr 30, 2019

Brilliant work! But you really should have LOVE IS PUSH and have a LOVE somewhere to be baba’s companion cube :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment