Skip to content

Branefuck

skirlez edited this page Feb 21, 2026 · 34 revisions

Branefuck

Branefuck is a modified version of the esoteric programming language Brainfuck. In Endless Void:

  • Add statues can run Branefuck programs to do several things, like destroying themselves, moving, or placing tiles
  • Branefuck nodes can run Branefuck programs to choose which path to take in the pack.

Usage

Add Statues

Each Add statue on the BRANEFUCK mode runs its Branefuck program runs every frame, with a given destroy value. Once the program returns a value that matches the destroy value, the Add statue gets destroyed. If the destroy value is blank, the statue will never destroy unless it errors (See the Errors section)

Branefuck nodes

When you reach a Branefuck node, it will execute the program set by the user. Once the program completes, it will take the path with the same number that was returned by the program. If the path returned is <= 1, it will take path 1. If the path returned is greater than the maximum, it will take the maximum path.

Differences from Brainfuck

  • You have exactly 230 cells
  • Each cell holds a signed 64 bit integer
  • The , input command now takes in an expression, see more below
  • The . output command terminates the program immediately and returns the value in the current cell.
  • You can write a number after commands where it makes sense to, to run them that amount of times. For example, +5 is the same as +++++.
  • New command: ?. This command gets the sign of the current cell's number (1 if positive, 0 if 0, -1 if negative), and puts that value in the cell instead.
  • New command: #. See below.
  • New commands: v and ^. See below.
  • Comments: ;. Everything after this character will be ignored until the next line.

The , command

With this command you can read almost any variable in the game. For the simplest example, you can use the prefix g: or global: to access global variables:

,g:level_time,

This reads the amount of frames since the level has started into the current slot.

Say we have a situation where object "example" holds an array in a variable called "array", and you want to access its third index. You could access it like so:

,example:array:3,

This would read that value into the current slot.

Table of all prefixes:

Prefix Function Example Words
g/global Global variables ,g:level_time, Reads time since level start
s/self/id Add statue instance ,s:x, Reads statue X position
t Temporary add statue memory ,t:0, Reads slot 0 from temporary memory
p Persistent add statue memory ,p:0, Reads slot 0 from persistent memory
(asset name) Asset index ,obj_player, Reads player object index
(object name) Nearest object of that type ,obj_player:y, Reads player Y position

The # command

This command takes in a function like so:

#move#

Parameters are read by taking in the current slot as the first parameter, the previous slot as the second parameter, and so on.

The first return value is in the next slot, the second return value is in the one after that, and so on.

Table of all functions:

Function Description Parameters Returns Can be used by Branefuck node?
show Displays current slot value None None Yes
log Logs current slot value None None Yes
abs Returns the absolute value of the given parameter 1 The Absolute Value Yes
mul Multiplies the first parameter with the second 2 The Product Yes
div Divides the first parameter with the second 2 The Quotient Yes
mod Returns the modulus of the first parameter with the second 2 The Modulus Yes
irandom Generates a random number between 0 and the parameter (inclusive) 1 The Random Number Yes
move Moves the add statue depending on the parameter. 0 - right, 1 - up, 2 - left, 3 - down 1 None No
instance_exists Checks if any instances of an object index exist 1 1 if any exist, 0 if none exist Yes
instance_position See page See page Please see page Yes
ds_grid_get See page See page Please see page Yes
set_tile See page See page Please see page Yes, but why
set_palette See page See Page Please see page Yes

Persistent and temporary memory

Branefuck code is executed every frame. In order to store information between frames, you can use persistent memory. You can switch to and from persistent memory using the ^ and v commands.

You can think of the persistent memory slots as existing "above" the temporary memory slots.

Persistent memory [0][0][0][0]...[0] (230 slots)

Temporary memory [0][0][0][0]...[0] (230 slots)

When ^ is executed, you go up to those slots (maintaining the current slot position, i.e. >>>^ will have you writing at the fourth persistent slot). When v is executed, you go back down to the temporary slots.

An important quirk is that both commands will copy the current slot to the new memory. Meaning +++^ will copy that 3 value to the first persistent memory slot, and likewise ^>+++v will copy the 3 from the second persistent memory slot to the second temporary memory slot.

Persistent memory persists across frames, even through deaths. In level packs, it of course persists through all nodes, and is even written to your save file. It will only be erased after resetting your save.

Finding variable names

In order to use the input command ,, you need to know the names of the variables you want to use. For vanilla variables, you need to use a tool like UndertaleModTool, opening the game up to search for them.

That being said, Endless Void introduces some new global variables that could be useful for this feature, which will be listed here:

leech_count
maggot_count
beaver_count
smile_count
eye_count
mimic_count
octahedron_count
spider_count
orb_count
scaredeer_count

locust_count

player_x 
player_y 

add_current_x
add_current_y

death_x
death_y
death_count (number of times this player has died since they started playing this level)
death_frames (number of frames since death animation started, or -1 if player is still alive)
annoyance_count (number of times player has died in the exact same coordinates)

editor_time (increases by 1 every frame from when you boot the game)
level_time (increases by 1 every frame from when you start the level, resets on death)

turn_frames (number of frames since last turn, you early return if it's not 0 to only execute on turns)

floor_count (regular & black floor counts)
glass_count

add_count
mon_count
tan_count
lev_count
eus_count
bee_count
gor_count
cif_count
jukebox_count
egg_count

has_memory
has_wings
has_sword
	
has_super_rod
has_stack_rod
has_endless_void_rod
has_hungry_rod
(all 4 of these variables are for the same thing)

has_idol


Additionally, here are some very funny global variables you can use as input, from Endless Void and from vanilla.

s_g_pal (palette index)
mouse_right_held
stranger (current player character)

Feel free to open an issue or pull request to add more variables (or even just document some useful variables from the vanilla game)

NOTE: values suffixed with _x are between 0 and 13, values suffixed with _y are between 0 and 8.

Examples of Usage

With destroy value set to 1, this:

,g:leech_count,>+5<
[->-<]
>?.

will cause the Add statue to explode if there are less than 5 leeches.

The first part of the program puts the leech count in the first slot, and the number 5 in the second slot.

Then, the program decrements both cells until the first cell reaches 0 ([->-<]). Once it's done, it moves to the second cell, runs the sign operation on it, and returns that sign. (>?.). If the second cell was smaller than or equal to the first cell, the sign of the second cell will be either -1 or 0, and the statue won't be destroyed. Only if the second cell was initially bigger than the first cell, the sign will be 1, and the statue will be destroyed.

Feel free to open an issue or pull request to add more examples.

Notes

  • If the program reaches the end without a ., it will still return the current cell. So you technically don't need it if it's at the end.
  • If the program reaches a character it doesn't know what to do with, like a [ followed by a number like 3, it will just skip the character.

Errors

The following cases will cause an error:

  • Program runs for too long (100,000 commands executed)
  • Program reaches a loop command ([ or ]) that does not have a counterpart
  • If the program reaches a , or # command that does not have a counterpart

In the case of an error:

  • If the code is running from a Branefuck statue, it will be destroyed.
  • If the code is running from a Branefuck node, the pack will be exited.

Clone this wiki locally