FILE I/O
WriteFile
Writes data to a file, creating it when missing.
Syntax
local ok = ONYX.WriteFile(name, data)Parameters
name(string) — Plain file name ending in .json - no directories, no path separators.data(string) — Bytes to write; binary-safe, embedded NUL bytes are preserved.
Return(s)
ok (boolean) — true when the file was opened and written, false when it could not be created or written.
Behavior
- Validates the name first; traversal attempts raise a Lua error.
- Opens the file for binary output and truncates previous contents before writing.
- On failure it returns false instead of raising.
Example(s)
local ok = ONYX.WriteFile("settings.json", "{\"aimbot\":true}")
if not ok then print("failed to save settings") end