natiny_script_table_get
C
NatinyScriptValue natiny_script_table_get(NatinyScript script,
NatinyScriptValue table,
const char* key);
Reads a field of a table by name.
Parameters
| Name |
Type |
Description |
script |
NatinyScript |
The state the table lives in |
table |
NatinyScriptValue |
The table to read |
key |
const char* |
Field name; NULL returns NATINY_SCRIPT_NIL |
Returns
| Type |
Description |
NatinyScriptValue |
What is there, or a NATINY_SCRIPT_NIL value when the field is missing or table is not a valid table |
Example
C
NatinyScriptValue title = natiny_script_table_get(script, config, "title");
NatinyScriptValue vsync = natiny_script_table_get(script, config, "vsync");
if (title.type == NATINY_SCRIPT_STRING) {
printf("%.*s, vsync %s\n",
(int)title.string.size, title.string.data,
natiny_script_to_bool(vsync) ? "on" : "off");
}
Notes
- A string points at bytes owned by the state and remains valid until the next
natiny_script_run, natiny_script_call or natiny_script_call_value on
that state.