Scrap Mechanic

Scrap Mechanic

Not enough ratings
brainf_ck language [SComputers addon]
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
1.622 MB
1 Apr @ 3:05am
10 Apr @ 2:26pm
2 Change Notes ( view )

Subscribe to download
brainf_ck language [SComputers addon]

In 1 collection by BananaPen
SComputers addons
15 items
Description
this addon for SComputers adds a computer running on the brainf*ck programming language!

the "." operator outputs values to the bf_output register and to the logPrint.
the "," operator takes values from the bf_input register, if there is none, then from the first input connected to the computer.

a computer can execute up to 100000 brainf*ck instructions in one tick.
to complete the execution in this tick, use the "," operator while reading input, the computer does nothing else and waits for the next tick.

to interact with the rest of the peripheral, use lua-invoke. to do this, output the lua-invoke as a string in "." it should start with byte 1 and end with byte 0.
there is a special python script in the mod files for automatic lua-invoke generation: Scripts/examples/luaInvokeGenerator.py
for luaInvokeGenerator.py to work, when calling lua-invoke, the selected memory location must have a value of 0. after completing lua-invoke, 0 will remain in this cell.
lua-invoke gets the brainf*ck memory table as the first argument, which is indexed from 0.
this allows data exchange between lua and brainf*ck.
please do not write anything there except integers from 0 to 255, as this will lead to UB

if you run a ready-made program on brainf*ck, it will output its result to the computer console and chat.
and accept input from the bf_input register, or if there is none, then from the first connected input.
if you do not need output to the chat,
then you can implement your output function using lua-invoke or disable output to the chat in the mod's Permission Tool
(in this case, output will continue to bf_output and to the computer console)
2 Comments
h20 18 Apr @ 12:02pm 
⣿⣿⣿⣿⣿⡿⠟⠛⠛⢿⠿⠟⠛⠛⠻⢿⣿⣿⡿⠛⠻⢿⣿⣿⣿
⣿⣿⣿⣿⠏⠀⣰⡶⠀⣸⡦⠀⢰⣶⠄⢸⣿⠏⠀⣠⡆⠀⢻⣿⣿
⣿⣿⣿⠏⠀⣼⣿⣿⣿⣿⠃⠀⠛⠁⣀⣾⠏⠀⣼⣿⡇⠀⣼⣿⣿
⣿⣿⡟⠀⢸⣿⣿⣿⣿⡟⠀⣰⣶⠀⢸⡏⠀⣼⣿⡟⠀⢠⣿⣿⣿
⣿⣿⣇⠀⠸⡿⠟⢻⠏⠀⠘⠛⠁⣠⣾⣇⠀⠿⠏⠀⣠⣿⣿⣿⣿
⣿⣿⣿⣷⣤⣤⣶⣾⣷⣴⣦⣤⣶⣿⣿⣿⣦⣤⣴⣾⣿⣿⣿⣿⣿
mistgo 1 Apr @ 5:42am 
useless