The light userdata type is used by Hollywood to store handles to objects allocated by Hollywood functions. Typically, Hollywood functions that allocate objects can be used in two ways. You can either specify a hard-coded numeric identifier for the object or you can ask Hollywood to return a light userdata identifier handle back to your script. Here we use the hard-coded numeric identifier 1 to refer to the file we've just opened:
OpenFile(1, "test.txt") s$ = ReadLine(1) CloseFile(1) |
Alternatively, we could also ask Hollywood to return an identifier handle to us by passing the special value Nil to OpenFile() like this:
handle = OpenFile(Nil, "test.txt") s$ = ReadLine(handle) CloseFile(handle) |
In that case, the variable handle will receive a value of type light userdata
to store a reference to the file we've just opened. This is pretty much the
only use case for variables of type light userdata. They are only used to
store handles allocated by Hollywood functions that deal with objects. It's
not possible to use variables of type light userdata in any other way, e.g. you
cannot write their value to a file or construct them in any other way besides
asking a Hollywood object function like OpenFile() or CreateBrush()
to create a new variable of type light userdata for you.
See Auto ID selection for details.