panorama.object
Lua wrapper around a JavaScript value from Panorama.
Wraps a JavaScript value from Panorama.
| Operation | Result |
|---|---|
obj.key, obj[k] | Converted property value. Numeric and boolean keys are converted to text; other key types read nil. JavaScript arrays are zero-based. |
obj(...) | Calls the JavaScript function and converts the result. Exceptions print in the console and return nil (nil, err for a function panorama.loadstring returned). Calling a non-function returns nil. |
#obj | String length, or the length property when it is a positive number; otherwise 0. |
tostring(obj) | panorama.object<typeof>, for example panorama.object<function>; panorama.object<invalid> when the value can no longer be read, panorama.object<empty> for an empty wrapper. |
A function read from an object retains that object as JavaScript this. Call it with obj.f(a), not obj:f(a), which supplies an unwanted first argument.
JavaScript-to-Lua conversion:
| JavaScript | Lua |
|---|---|
| null, undefined | nil |
| boolean, number, string | Corresponding Lua value |
| Other values | panorama.object |
Lua-to-JavaScript argument conversion:
| Lua | JavaScript |
|---|---|
nil | null |
| boolean, number, string | Corresponding JavaScript value |
panorama.object | Wrapped value |
Non-empty table with exactly the keys 1..n | Array |
| Other table | Object; string, number and boolean keys are supported |
Tables may nest up to 64 levels. Functions, userdata other than panorama.object, cdata, unsupported keys, cycles and deeper nesting raise panorama.object: unsupported argument.
Property assignment is unsupported and raises. Equality compares wrapper handles, not JavaScript values. Objects from old panels become stale after a map change or HUD reload; reads and calls then return nil. Fetch them again.
