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 keys are converted to text; JavaScript arrays are zero-based. |
obj(...) | Calls the JavaScript function and converts the result. Exceptions print in the console and return nil. |
#obj | String length, or the length property; otherwise 0. |
tostring(obj) | panorama.object<typeof>. |
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 |
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 and must not contain cycles. Functions, userdata and cdata 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.
