Brainfuck CS2D Scripting Interface
11 replies



14.08.17 05:05:20 pm
Didn't you too always want to write CS2D scripts in Brainfuck? No? Whatever you can do it anyway!
I spend weeks(a few hours today) to write an interface that allows loading Brainfuck programs that communicate with lua to give them full control over the scripting environment. Why? For the good of all of humanity of course... and because I was bored.
How does it work? It's a lua script that can be loaded that interprets the Brainfuck programs using an interpreter I wrote yesterday. But that's not all! It keeps track of the output and buffers it. As soon as you write a null character to the output it takes that buffer and executes it using loadstring and thus executes the previous output as lua code. If your output starts with an exclamation point(!) it will read whatever was returned by loadstring into Brainfuck's input.
The input will be modified according to the following rules:
Numbers will stay as they are and will cause errors if they aren't integer numbers within the range 0-255.
Booleans will be turned into 1(true) and 0(false).
Strings will be turned into char codes (as per usual).
All other types will be turned into strings and then handled like a string.
The Brainfuck programs do one operation every tick (using an always hook).
How do you use it? It comes with a few simple commands.
Adds a program to be executed to the system.
program: the Brainfuck code as a string
input: the starting setup for the input as a string
callback: function that will be triggered whenever the program puts out a character (can be nil)
Adds a program to be executed to the system with empty input and no callback.
file: the location of the Brainfuck code file
The files can be downloaded here:
Brainfuck+TISfuck CS2D Scripting Interfaces (6)
In case it wasn't clear enough: This is a joke and should not be taken seriously. The execution of Brainfuck scripts is very slow this way and Brainfuck is not a language that should be used seriously anyway.
I hope you like what I did and maybe even learned a thing or two. Have a nice day!
Necro
I spend weeks(a few hours today) to write an interface that allows loading Brainfuck programs that communicate with lua to give them full control over the scripting environment. Why? For the good of all of humanity of course... and because I was bored.
How does it work? It's a lua script that can be loaded that interprets the Brainfuck programs using an interpreter I wrote yesterday. But that's not all! It keeps track of the output and buffers it. As soon as you write a null character to the output it takes that buffer and executes it using loadstring and thus executes the previous output as lua code. If your output starts with an exclamation point(!) it will read whatever was returned by loadstring into Brainfuck's input.
The input will be modified according to the following rules:




The Brainfuck programs do one operation every tick (using an always hook).
How do you use it? It comes with a few simple commands.

_BF.add_program(program,input,callback)
Adds a program to be executed to the system.
program: the Brainfuck code as a string
input: the starting setup for the input as a string
callback: function that will be triggered whenever the program puts out a character (can be nil)

_BF.dofile(file)
Adds a program to be executed to the system with empty input and no callback.
file: the location of the Brainfuck code file
The files can be downloaded here:


In case it wasn't clear enough: This is a joke and should not be taken seriously. The execution of Brainfuck scripts is very slow this way and Brainfuck is not a language that should be used seriously anyway.
I hope you like what I did and maybe even learned a thing or two. Have a nice day!
Necro
edited 3×, last 22.08.17 02:44:48 pm
-[------->+<]>.-[->++++<]>.++[--->++<]>.---.++.------.--[--->+<]>-.--[->++++<]>-.+[->+++<]>.---.+++++++++++++.-------------.--[--->+<]>-.---[->++++<]>.------------.+.++++++++++.+[---->+<]>+++.-[--->++<]>-.++++++++++.+[---->+<]>+++.++[->+++<]>+.++++++++.------.+++++.-------.
https://ohaz.engineer - Software Engineering
Why dont u use ur knowledge to make good stuffs for the game instead of these useless things.

Site: https://cs2d.com.br | Discord: https://discord.gg/85H6ACE8jp
16.08.17 03:45:49 pm
I'm glad you seem to like it.
I've been working on own more advanced language based on Brainfuck.
And I have modified my Brainfuck interpreter to work on TISfuck instead. PASTEBIN
I might also make a CS2D interface for it and I'll fix the minor bugs my Brainfuck interpreter has.
@
Yates: I get it was meant as a joke but I still looked into LISP but I won't make an interface for that. The reason being that I don't want to write an interpreter for it. There are lua LISP interpreters and even pure lua implementations out there but I think it would be boring just to use one of those.
@
mrc: I make this useless stuff because I think it's a fun way to challenge myself. But because you asked for it I think I can do a custom game mode script. I already have an idea of what it should be like. I won't start creating it right away though.
I've been working on own more advanced language based on Brainfuck.
And I have modified my Brainfuck interpreter to work on TISfuck instead. PASTEBIN
I might also make a CS2D interface for it and I'll fix the minor bugs my Brainfuck interpreter has.
@

@

Code:
.48*61..76.65.20..20.6E.69.63.65.20.64..79.21;
edited 4×, last 17.08.17 11:19:59 pm
I've heard about that scripting language, my senpai made it look really difficult to use and I agree with him.
those symbols are truly made to brainfuck people
those symbols are truly made to brainfuck people
ignore my previous names
@
Qb:
(Lisp (is (a great) programming (language)) and (should be (more (widespread)))
(please (consider) Lisp's (feelings)))

Code:
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
(DEFUN RIP ()
"RIP LISP")
(DEFUN LISPTOLUA ()
nil)
(if (NOT (LISPTOLUA))
(PRINT (RIP)))
"RIP LISP")
(DEFUN LISPTOLUA ()
nil)
(if (NOT (LISPTOLUA))
(PRINT (RIP)))
(Lisp (is (a great) programming (language)) and (should be (more (widespread)))
(please (consider) Lisp's (feelings)))
I just released the TISfuck Scripting Interface:
Brainfuck+TISfuck CS2D Scripting Interfaces (6)
@
Yates: It's not that I don't like LISP. It's just that it's far more complex than Brainfuck and TISfuck will ever be. It would be far too much work for what is essentially a joke.


@

this has nothing on subleq (the 1 instruction by itself can compute anything)
actually, someone made a (limited) C to subleq program which blows my mind (higher subleq)
actually, someone made a (limited) C to subleq program which blows my mind (higher subleq)
will code for food



