ROBOT IS CHILL

From Esolang
(Redirected from Robot Is Chill)
Jump to navigation Jump to search

ROBOT IS CHILL (or RIC) is a discord bot that is mostly used for making Baba Is You renders, but also can run its own code, macros.

Macros

Macros in RIC replace itself with what it returns (internally). so, something like [add/5/10] would output 15.0. This means that you can also do [[echo/add]/5/10], which would also output 15.0.

In the bot, you can create macros that would be stored in the database. They basically are public functions. The most important ones are builtin macros, which'll be listed here:

Add

[add/int/int] Adds two numbers together.

Example 1: [add/5/10] returns 15.0.

Example 2: [add/2/2.5] returns 4.5.

And

[and/bool/bool] Takes two arguments, both either being true or false, and returns true if both are true, and false otherwise.

Example 1: [and/true/true] returns true.

Example 2: [and/true/false] returns false.

Example 3: [and/false/false] returns false.

Assert

[assert/bool/string] Throws an error with a message of the second argument if the first argument is false.

Example 1: [assert/false/Oops!] makes an error with the message "Oops!".

Example 2: [assert/true/Nope!] does nothing.

Bin

[bin/int] Converts a number to binary.

Example 1: [bin/5] returns 0b101.

Example 2: [bin/2.5] returns 0b10

Chr

[chr/int] Gets a character from a unicode codepoint.

Example: [chr/65] returns A.

Concat

[concat/string/...] Concatenates all arguments into one string.

Example 1: [concat/he/llo] returns hello.

Example 2: [concat/h/e/l/l/o] returns hello.

Count

[count/string/string] Returns the number of occurrences of the second argument in the first.

Example 1: [count/apple banana apple orange/apple] returns 2.

Example 2: [count/apple banana apple orange/an] returns 3.

Divide

[divide/int/int] Divides a number by another number.

Example 1: [divide/10/5] returns 2.0.

Example 2: [divide/5/2] returns 2.5.

Example 3: [divide/10/3] returns 3.3333333333333335.

Drop

[drop/variable] Deletes a variable.

Example 1: If there is a variable called var, [drop/var] deletes it.

Example 2: If there is not a variable called var, [drop/var] errors.

Equal

[equal/string/string] Checks if two strings are equal.

Example 1: [equal/hi/hi] returns true.

Example 2: [equal/ab/cd] returns false.

Error

[error/string] Raises an error with a specified message.

Example: [error/Uh oh!] errors with the message "Uh oh!"

Find

[find/string/string/string(optional)/string(optional)] Returns the index of the second argument in the first, optionally between the third and fourth.

Get

[get/variable/string] Loads the value of a stored variable of the name in the first argument, or if it does not exist, initializes it to the second.

Hash

[hash/string] Takes the hash of a given string.

Hex

[hex/int] Converts a number to hexadecimal.

If

[if/bool/any/any] Takes three arguments, in the form of [if/a/b/c], and is replaced by b if a is true, and c if a is false.

Imag

[imag/int] Gets the imaginary component of a complex value.

Int

[int/int] Turns a number into an integer.

Is_number

[is_number/any] Checks if a value is a number.

Is_stored

[is_stored/variable] Checks if a variable is stored.

Join

[join/string/string/...] Joins all arguments after the first with the first argument.

Json.append

[json.append/json/string] Appends a value to a JSON array. The first argument is the JSON array, and the second argument is the data to append.

Json.get

[json.get/json/int] Gets a value from a JSON array or object. The first argument is the JSON, and the second argument is the key or index.

Json.insert

[json.insert/json/int/string] Inserts a value into a JSON array. The first argument is the JSON array, the second argument is the index, and the third argument is the data to insert.

Json.keys

[json.keys/json] Gets the keys of a JSON object as a JSON array.

Json.len

[json.len/json] Gets the length of a JSON object or array.

Json.remove

[json.len/json/int] Removes a value from a JSON object or array. The first argument is the JSON array and the second argument is the index to remove.

Json.set

[json.len/json/int/string] Sets a value in a JSON object or array. The first argument is the JSON array, the second argument is the index, and the third argument is the data to set.

Len

[len/string] Gets the length of a string.

Less

[less/int/int] Takes two arguments, in the form of [less/a/b], and is replaced with true if a as a number is less than b as a number, and false if they're not.

Load

[load/string] Gets the value of a variable, erroring if it doesn't exist.

Log

[load/int/int(optional)] Takes the logarithm of the first argument, with the base being the second argument. If the second argument is not given, then the natural logarithm is taken.

Mod

[mod/int/int] Returns the modulus of the first value with the second.

Popular custom macros

Forsep

[replace/$4/$1/[int/$2]][if/[less/$2/$3]/$5/][?/[less/$2/$3]]forsep/$1/[add/1/$2]/$3/$4/$5]

"forseq+(i,a,b,expr,sep): Replace i in expr with integers in [a,b], splitted by sep"

by l4.m2

Examples

99 bottles of beer

[unescape/[forsep/@/0/98/\[int\/\[subtract\/99\/@\]\] bottle\[if\/\[equal\/1\/\[int\/\[subtract\/99\/@\]\]\]\/\/s\] of beer on the wall, \[int\/\[subtract\/99\/@\]\] bottle\[if\/\[equal\/1\/\[int\/\[subtract\/99\/@\]\]\]\/\/s\] of beer. Take one down, pass it around, \[replace\/\[int\/\[subtract\/98\/@\]\]\/0\/No\] bottle\[if\/\[equal\/1\/\[int\/\[subtract\/99\/@\]\]\]\/\/S\] of beer./

]]

by blokos

FizzBuzz

[unescape/[forsep/@/1/100/\[if\/\[and\/\[equals\/\[mod\/@\/3\]\/0.0\]\/\[equals\/\[mod\/@\/5\]\/0.0\]\]\/fizzbuzz\/\[if\/\[equals\/\[mod\/@\/3\]\/0.0\]\/fizz\/\[if\/\[equals\/\[mod\/@\/5\]\/0.0\]\/buzz\/@\]\]\]/ ]]

by blokos

Fixed Repeating Output

[repeat/$1/1]0

by another_user