Update README.md

This commit is contained in:
fed 2022-06-11 21:03:37 +02:00 committed by GitHub
parent 2937edd21a
commit a1b8d80bf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -72,20 +72,77 @@ If you wish for any feature to be added please create an [issue](https://github.
# Functions & Methods # Functions & Methods
A list of all the functions and methods that are added to the GSC VM by this plugin. A list of all the functions and methods that are added by this plugin.
## IO ## IO
* `fileExists(path)`: Returns true if the file exists. * `fileExists(path)`: Returns true if the file exists.
* `writeFile(path, data[, append])`: Creates a file if it doesn't exist and writes/appends text to it. * `writeFile(path, data[, append])`: Creates a file if it doesn't exist and writes/appends text to it.
* `appendFile(path, data)`: Creates a file if it doesn't exist and appends text to it.
* `readFile(path)`: Reads a file. * `readFile(path)`: Reads a file.
* `fileSize(path)`: Returns file size in bytes. * `fileSize(path)`: Returns file size in bytes.
* `createDirectory(path)`: Creates a directory. * `createDirectory(path)`: Creates a directory.
* `directoryExists(path)`: Returns true if the directory exists. * `directoryExists(path)`: Returns true if the directory exists.
* `directoryIsEmpty(path)`: Returns true if the directory is empty. * `directoryIsEmpty(path)`: Returns true if the directory is empty.
* `listFiles(path)`: Returns the list of files in the directory as an array. * `listFiles(path)`: Returns the list of files in the directory as an array.
* `copyFolder(source, target)`: Copies a folder. * `copyFolder(source, target)`, `copyDirectory(source, target)`: Copies a folder.
* `copyDirectory(source, target)`: Same as `copyFolder`. * `removeDirectory(path[, recursive])`: Removes a directory and optionally all its contents.
* `removeDirectory(path[, recursive)`: Removes a directory and optionally all its contents. ## Command
* `executeCommand(command)`: Executes a console command.
```gsc
fast_restart()
{
executeCommand("fast_restart");
}
```
* `addCommand(name, callback)`: Adds a console command.
```gsc
init()
{
addCommand("test_cmd", ::test_cmd);
}
test_cmd(args)
{
assert(args[0] == "test_cmd");
print("Hello world", args.size);
}
```
## String
* `va(fmt, ...)`, `formatString(fmt, ...)`, `sprintf(fmt, ...)`: Formats a string:
```gsc
init()
{
print(va("hello %i %f %s", 1, 1.2, "world"));
}
```
* `printf(fmt, ...)`: Formats and prints a string:
```gsc
init()
{
printf("hello %i %f %s", 1, 1.2, "world");
}
```
## Misc
* `array(...)`: Creates an array from a list of arguments:
```gsc
init()
{
arr = array(1, 2, 3, 4);
}
```
* `type(value)`, `typeof(value)`:
```gsc
init()
{
assert(type("hello") == "string");
assert(type(array()) == "array");
}
```
## SOON ## SOON
* ... * ...