Skip to content

Standard Library

LabRicecat edited this page Nov 25, 2022 · 3 revisions

filesystem

using filesystem

read

Returns the content of a given file.

filesystem.read <file>

get_line

Returns a line of the content of a given file.

filesystem.get_line <file> <line>

exists

Returns 1 if the given file/directory exists and 0 if not.

filesystem.exists <file>

is_directory

Returns 1 if it's a directory, 0 if not.

filesystem.exists <file>

extension

Returns the extension of the given file. (Also works for not existing files)

filesystem.extension <file>

filename

Returns the filename of the given file. (Also works for not existing files)

filesystem.filename <file>

write

Clears a file and writes the given string into it.
If the file doesn't exist, a new one gets created.

filesystem.write <file> <content>

append

Appends the given string to the content of the given file.
If the file doesn't exist, a new one gets created.

filesystem.append <file> <content>

size

Returns the size of the given file in bytes.

filesystem.size <file>

os

using os

rand

Returns a random number.

os.rand([max],[min])

date

Returns the current date and time.

os.date()

sleeps

Halts the program for a given period of time.

os.sleep(<time>)

time is in milliseconds.

name

Returns the name of the current operating system.
Names are:

  • Windows
  • Linux
os.name()

exit

Exits the current program with a given exit code.

os.exit(<code>)

version

Returns the current MeowScript version
Format: MAJOR.MINOR.PATH

os.version()

origin_file

Returns the original file that got executed first by the interpreter.

os.origin_file()

main_file

Returns 1 if the current file is the origin-file, 0 if not.

os.main_file()

file

Returns the current filename

os.file()

clear

Clears the console.

os.clear()

args

Returns a list of all arguments provided to the interpreter when the oringinal file got executed.

$ meow-script main.mws <arg1> <arg2> ...
os.args()

utime

Returns the current unix time stamp.

os.utime()

time

Returns based of the argument either the seconds, minutes or hours.

os.time("seconds")
os.time("minutes")
os.time("hours")

math

using math

max

Returns the bigger one of two numbers.

math.max(<num1>,<num2>)

min

Returns the smaller one of two numbers.

math.min(<num1>,<num2>)

sqrt

Returns the square root of a number.

math.sqrt(<num>)

floor

Returns the floor of a number.

math.floor(<num>)

ceil

Returns the ceil of a number.

math.ceil(<num>)

sin

Returns the sin() of a number.

math.sin(<num>)

cos

Returns the cos() of a number.

math.cos(<num>)

tan

Returns the sin() of a number.

math.tan(<num>)

abs

Returns the absolute value of a number.

math.abs(<num>)

log10

Returns the log10() of a number.

math.log10(<num>)

int

Returns the number without any decimals.

math.int(<num>)

round

Returns a rounded version of a number.

os.round(<num>,<digits>)
Clone this wiki locally