Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

nicy_eval

Evaluate inline Luau code and print the result.

C Signature

void nicy_eval(const char* code);

Parameters

ParameterTypeDescription
codeconst char*Luau source code to evaluate

Description

nicy_eval creates an isolated Luau state, loads the code, and executes it. Results are printed to stdout. Errors are printed to stderr.

Unlike nicy_start, it:

  • Does not run the task scheduler
  • Creates a fresh state each time (no shared globals)
  • Is intended for quick one-liners and tests

Example (C)

#include "NicyRuntime.h"

int main() {
    nicy_eval("print(2 + 2)");
    nicy_eval("print('Hello from Luau!')");
    return 0;
}

Notes

  • The code is loaded as a chunk — no file-based module resolution
  • Each call is independent (no state sharing)
  • Errors terminate the program (no recovery)