natiny_script_get

C
NatinyScriptValue natiny_script_get(NatinyScript script, const char* path);

Reads the value under a dotted name.

Parameters

Name Type Description
script NatinyScript The state to read from
path const char* Dotted name, from the globals down; an empty or overlong segment resolves as missing, and each segment may contain at most 127 bytes

Returns

Type Description
NatinyScriptValue What is there, or a NATINY_SCRIPT_NIL value when the name - or any table on the way to it - is missing

Example

C
NatinyScriptValue config = natiny_script_get(script, "game.config");

if (config.type == NATINY_SCRIPT_TABLE) {
    double width = natiny_script_to_number(
        natiny_script_table_get(script, config, "width"));
}

Notes

  • A table, a function and a string are borrowed: valid until the next natiny_script_run, natiny_script_call or natiny_script_call_value on that state, and nothing to release - see NatinyScriptValue. A number or a boolean is a copy.
  • A borrowed value can go straight into the next call - as an argument, or as the function of natiny_script_call_value. That call ends the loan only after everything is on the stack.