User:Aadenboy/Collapsing Building
Jump to navigation
Jump to search
This is an esolang I devised back in 2022/2023 after making Trampolines. Since I was determined to make the interpreter first before documenting it, I never finished the esolang.
The gimmick is that the script is somewhat like a building
The more lines there is the more "unstable" that building is
There's not an upper limit to how long the building gets, but it definently helps to not have SO many lines
Variables are the problem though, they create weight to the line pointer
The amount of weight the line pointer can carry is determined by this equation
255 - A + (A / 5)
(it only goes down to 50)
A is the amount of lines there is
The weight of a number is it's absolute value plus it's string representation's length
I.E. the weight of 4 is 5, and 135 is 138
The weight of a string is it's length multiplied by 4
I.E. "hello world" is 44, and "Strings are really heavy!!" is 104
The weight of a boolean is always 4
If the weight being held surpasses the capacity the line pointer can hold, any lines below it will start to "break down", as in being permanently deleted from the script.
(Note that this does not modify the file itself)
The lines that are chosen to be broken are determined based on how far away from the line pointer and the floor they are
Closer lines are more suspectible to damage
Every 3-5 lines a weighted random will occur to delete lines from the script
If more than half of the lines end up being destroyed, the script stops running and it says so in the console
The fun part about this is that it will most likely be that some error happens before the building collapses!
Anything declared in parentheses are required, however if it is declared in square brackets it is optional
var (n) (v) Make a new variable n with the value v, v may be a number, a string, or even a boolean
trash (v1) [v2]... Remove variables v1, v2... and so on
dupe (v) (n) Duplicate variable v with the new name n, however this is costly
calculate (op) (v) (a) [b] [c] Do the math operation op on arguments a, b... and so on, the operators are all of lua's built-in math operators (as well as a few custom ones), return the output to v
gate (type) (v) (a) [b] Perform a basic logic gate operation on a and b, return the output to v
print (a) [b]... Print a, b... and so on separated with tabs
write (a) Similar to print but it doesn't add a newline, write a
define (f) [args] Define a new function called whatever f is with the arguments args
end End a dfunction, if statement, etc.
execute (f) [r] [args] Run function f with arguments args returning the returned value to variable r
if (conditions) Check if conditions return true
return (a) Return a
break End the current running loop
while (conditions) Start or continue a while loop only if conditions returns true
for (i) (f) (c) [n] Start or continue a for loop increasing i every extra loop by c until i is equal to f, and optionally add a variable n with the value of i
empty [v1] [v2]... Clear all existing variables except for variables v1, v2... and so on
readnum (i) [min] [max] An unsafe command without min or max, request a number from the user, clamp it to be between min and max, and then return the amount to variable i (if max is not provided, min is treated as max)
readstr (i) [length] An unsafe command without length, request a string from the user, remove any characters after the desired length, and then return the amount to variable i
readbool (i) Request a boolean from the user, and return it to the variable i
string (op) (v) (a) [b] [c] Do the string operation op on arguments a, b, and c, return the output to v and remove a, b, and c
evacuate Ends the program
evacuatedata Ends the program and provides debug data
debug Print debug
collect (n) Put the amount of lines broken into a variable
fancier but longer version
Command: var
The "var" command creates (or replaces) a variable with a value. It has two arguments, the first being the variable name, and the second being the value.
EXAMPLE:
var x 1 -- sets x to 1
var hello "world" -- sets hello to "world"
var boolean true -- sets boolean to true
Command: trash
The "trash" command removes any variables. It allows up to an infinite number of arguments.
EXAMPLE:
var a 1
var b 2
var c 3
-- we want to get rid of c and a, so we use trash
trash a c -- this will get rid of a and c within the same line, so you don't have to use multiple in a row
Command: dupe
The "dupe" command duplicates a variable. It has two arguments, the first being the original variable, and the second being the new variable.
EXAMPLE:
var a 1
dupe a b -- we duplicated a to b, b now has the value of a which is 1
Command: calculate
The "calculate" command calculates anything calculable. It accepts three initial required arguments, then optionally more requirements, up to an infinite amount.
The first argument is the operation. It allows for any function in the Lua math library to be ran.
If you want to do basic arithmetic, you can use the relating symbol.
+ is addition
- is subtraction
* is multiplication
/ is division
^ is exponentation
% is modulo
The second argument is the variable the output goes to. It can be any existing variable, or a new one.
The third (and optionally more) argument(s) are the values the function is given, in order. They can be variables, or numbers.
EXAMPLE:
var a 5
calculate ^ a a 2 -- raise the variable a to the power of 2, and put the result to the variable a
calculate sqrt a a -- run the Lua math library function "sqrt" (square root) on the variable a, and put the result to the variable a
Command: gate
The "gate" command performs simple gate operators on anything. It uses three initial arguments, and optionally a fourth one if needed.
The first argument is the gate type. This can be AND, OR, NOT, NAND, NOR, XOR, XNOR. This should be lowercase.
The second argument is the variable to return to.
The third (and optionally fourth) argument(s) are for the gate to handle. This can be anything. Variable, string, number, and boolean. Booleans are treated as 0 and 1 respectively. Strings are turned into their ASCII characters, and then into their base 2 representations. Numbers are turned into their base 2 representations. If one argument is shorter than another, the shorter argument is repeated until it reaches the other argument's length.
After performing the gate operation, it will turn the output into whatever type the third argument is. If it's a boolean, it will take the most significant bit and turn it into a boolean based on that. If it's a number, it will turn it back to base 10. If it's a string, it will go through each 8 bits and turn it into it's ASCII representation.
EXAMPLE:
var data "encrypt this please!"
var key "apples"
gate xor encrypted data key -- run the xor gate against data and key
Command: print
The "print" command prints to the console after printing a newline first. It allows for an infinite number of arguments, as long as there is one.
Each argument is separated by a tab character. To bypass this, put two periods next to each other inbetween the arguments you want to concatenate
EXAMPLE:
print "This will" "not be concatenated" -- > This will [TAB] not be concatenated
print "This will " .. " be concatenated" -- > This will be concatenated
var a 1
print "It also" a "accepts" 182 "any type of value, including variables" true false -1 -- > It also [TAB] 1 [TAB] accepts [TAB] 182 [TAB] any type of value, including variables [TAB] true [TAB] false [TAB] -1
Command: write
The "write" command appends an argument to the end of whatever is in the console. It only allows for one argument.
EXAMPLE:
print "I forgot to add some text " -- > I forgot to add some text
write "oh hey here it is!" -- > I forgot to add some text oh hey here it is!
Command: define
The "define" command defines a function. It allows for a first initial argument, and then an optional infinitely more arguments, as the function's "inputs".
The first argument is the function's name.
NOTE: The command must end with "end" to denote the end.
BREAKING POINT: The language currently does not support recursion.
EXAMPLE:
define foo a b
calculate + a a b
return a
end
COMMAND: execute
The "execute" command executes any existing functions. The command allows for one initial argument, and then additionally infinitely many more as long as the second argument is a valid variable name.
The first argument is the function to run. The second argument is the variable to write to if it returns a value. The rest of the arguments are the arguments for the function.
EXAMPLE:
define foo a b
calculate + a a b
return a
end
execute foo result 10 5
print result -- > 15
Command: if
The "if" command runs a conditional, and if it is true it will run the code after it, otherwise it will skip to the next "end" command.
The conditional uses the same arguments as Lua's conditional arguments. Every condition must be wrapped in parentheses excluding the first condition, but you may wrap it in parentheses if it appeals to you.
EXAMPLE:
var a 1
var b "a"
if ((a <= 10) and (b ~= "c")) or (a == b)
print true
end
if not (((a <= 10) and (b ~= "c")) or (a == b))
print false
end
Command: while
The "while" command runs a loop until the given conditional is no longer met.
NOTE: This loop must end with an "end" command to signify the end of the loop, and can be ended prematurely with the "break" command.
EXAMPLE:
var x 0
while x < 10
calculate + x x 1
print x
end
-- prints numbers 1-10
Command: for
The "for" command increments upwards until the first argument is equal or greater than the second argument, incrementing up by the third argument. There is an optional fourth argument which assigns the index to a temporary variable.
NOTE: This loop must end with an "end" command to signify the end of the loop, and can be ended prematurely with the "break" command.
EXAMPLE:
for 1 10 1 index
print index
end
-- prints numbers 1-10
Command: empty
The "empty" command removes all variables except for any variables specified in an argument.
EXAMPLE:
var a 1
var b 2
var c 3
empty a -- removes all variables except variable a
var d 10
var e 100 -- very dangerous!
empty a d -- removes all variables except variables a and d, no longer in danger
Command: readnum
The "readnum" command takes a number input from the person running the program. It accepts one initial argument, and then two more optional ones.
The first argument is the variable the input will return to. The second and third argument(s) determine the minimum and maximum. If the third argument is not given, it treats the second argument as the maximum.
NOTE: This command is extremely dangerous without a minimum or maximum provided, since the person running the program can input a very big amount and cause the program to collapse on itself.
EXAMPLE:
readnum back 10 30 -- being safe
if back < 20
print "less than 20"
end
if back >= 20
print "greater than or equal to 20"
end
Command: readstr
The "readstr" command takes a string input from the person running the program. It accepts one initial argument, and then an extra optional argument.
The first argument is the variable the input will return to. The second argument determines the maximum length.
NOTE: This command is extremely dangerous without a maximum length, since the person running the program can input a very long string and cause the program to collapse on itself.
EXAMPLE:
readstr data -- this is unsafe, but the program will assume the user is not mischevious
gate xor encrypted "apples" data
print "Your encrypted data is: " .. encrypted
Command: readbool
The "readbool" command takes a boolean input from the person running the program. It only has one argument, the variable to return to.
NOTE: The inputs "true", "t", and "1" are treated as true, anything else is treated as false.
EXAMPLE:
readbool boolean
if boolean
print "it is true"
end
if not boolean
print "it is false"
end
Command: string
The "string" command performs any of Lua's string library functions on strings. It allows for three initial arguments, and then an optional infitely many more.
The first argument determines which function to run. The second argument determines which variable to return the output to. The third (and the rest) argument(s) are the inputs for the function.
EXAMPLE:
print "You will input a string, and then two numbers to determine the start and end."
readstr string 30
readnum min -30 30
readnum max -30 30
string sub string string min max
empty string
print "Your new string is: " .. string
Command: evacuate
The "evacuate" command ends the program.
EXAMPLE:
readnum number
if (number >= 100) or (number <= -100)
evacuate
end
print number
Command: evacuatedata
The "evacuate" command ends the program and prints debug data.
EXAMPLE:
readnum number
if (number >= 100) or (number <= -100)
evacuatedata -- ends the program and provides debug data
end
print number
Command: debug
The "debug" command prints debug data. The user must press enter to continue the program.
EXAMPLE:
readnum number -100 100
debug
print number
Command: collect
The "collect" command puts the amount of lines broken into a variable, determined by the first argument.
EXAMPLE:
readnum number
print "Collecting..." -- allows it to break a line or two
trash number
collect final
print "Lines broken: " .. final