BefungeBot - A Befunge interpreter which uses the EE World!
BefungeBot requires LuaBot
To use, download BefungeBot, place it in the /scripts/ directory inside of LuaBot's unzip directory.
Run luabot (or do command 'reloadlua') and then type in 'lua befunge'!
Befunge is an esoteric programming language which pioneers something known as a 2d programming language.
Commands are made up of a single letter, or in the case of everybody edits, a certain type of block.
Read more about it here
Bot download link: https://github.com/uniquegamer522/LuaBo … efunge.lua
Chat commands:
!cachetime [time]: adjusts the amount of time the bot waits for each output command before flushing the buffer to chat.
!string [a string]: Passes a string into standard input
!number [numbers seperated by commas]: passes numbers into standard input
!hyperspeed: 100x speed, disables drawing of the current program position
!fast: 10x speed
!medium: 5x speed
!slow: x1 speed (once per second)
!reset: resets the script completely
!pause: Pauses/unpauses the script
▼The command blocks
(Push 0-9 are represented by the Basic block set, where white = 0, gray = 1, ... and purple = 9)
+ Addition: Pop two values a and b, then push the result of a+b
- Subtraction: Pop two values a and b, then push the result of b-a
* Multiplication: Pop two values a and b, then push the result of a*b
/ Integer division: Pop two values a and b, then push the result of b/a, rounded down. According to the specifications, if a is zero, ask the user what result they want.
% Modulo: Pop two values a and b, then push the remainder of the integer division of b/a.
! Logical NOT: Pop a value. If the value is zero, push 1; otherwise, push zero.
` Greater than: Pop two values a and b, then push 1 if b>a, otherwise zero.
> PC direction right
< PC direction left
^ PC direction up
v PC direction down
? Random PC direction
_ Horizontal IF: pop a value; set direction to right if value=0, set to left otherwise
| Vertical IF: pop a value; set direction to down if value=0, set to up otherwise
" Toggle stringmode (push each character's ASCII value all the way up to the next ")
: Duplicate top stack value
\ Swap top stack values
$ Pop (remove) top stack value and discard
. Pop top of stack and output as integer
, Pop top of stack and output as ASCII character
# Bridge: jump over next command in the current direction of the current PC
g A "get" call (a way to retrieve data in storage). Pop two values y and x, then push the ASCII value of the character at that position in the program. If (x,y) is out of bounds, push 0
p A "put" call (a way to store a value for later use). Pop three values y, x and v, then change the character at the position (x,y) in the program to the character with ASCII value v
& Get integer from user and push it
~ Get character from user and push it
@ End program
0 – 9 Push corresponding number onto the stack
Implementation differences:
Lua supports arbitrary precision, so you can have any number in your cells
Division by 0 stops the program
Output is buffered to reduce chat spam
Block codes and ascii codes differ, so befunge programs which use g/p will probably break here.
▼Hello, world!
Note that this example prints "Hello, world!" one character at a time, and loops endlessly.
Detailed breakdown of execution, [textInBrackets] shows the current stack
(Note: indented code after [textInBrackets] means that [textInBrackets] is still on the stack, its just not shown)
@top
string read [!dlrow ,olleH]
[!dlrow ,olleH]
push 9 [9]
push 3 [9, 3]
add [12]
push 3 [12, 3]
swap [3, 12]
push 3 [3, 12, 3]
swap [3, 3, 12]
write <12 to 3,3> []
@print
cout "H" [!dlrow ,olle]
[!dlrow ,olle]
push 3 [3]
push 3 [3,3]
read <3,3> [x]
push 1 [x,1]
swap [1,x]
subtract [x-1]
duplicate [x-1, x-1]
conditional ([x-1] == 0) [x-1, result]
Branch TRUE (down): [x-1]
discard []
goto @top
Branch FALSE (up): [x-1]
push 3 [x-1, 3]
swap [3,x-1]
push 3 [3,x-1,3]
swap [3,3,x-1]
write <x-1 to 3,3> []
goto @print
Feedback? Bug reports (Actually these should go on github, but post them here too!)? Post it here!
After approximately a long time of being idle...
I've finally found the time, energy, and inspiration to begin...
Announcing...
the long-awaited sequal..
with an actual GUI...
event-based system instead of threads...
..nope never mind out of inspiration. I'll be back in another month or two.
It's here: LuaBot 2.0! (Hopefully we fixed that missing DLL problem)