If you plan to write plugins that extend Hollywood's script language by installing new commands and constants, you will have to deal with the Lua VM which is at the heart of Hollywood. Hollywood uses Lua 5.0.2 as its virtual machine but with major modifications. Here is a non-exhaustive list of the differences between Lua 5.0.2 and Hollywood:
Nilis different between Hollywood and Lua. Comparing 0 against
Truein Hollywood, but
Falsein Lua. This change has been made to allow you to work with uninitialiazed variables. If you pass an uninitialized, i.e. a
Nilvariable to a function or you use an uninitialized variable in an equation, Hollywood will just treat this uninitialized variable as if its value was 0. Lua, on the other hand, will fail if you try do arithmetics with
Nilvariables or pass a
Nilvariable to a function which expects a numerical value. Hollywood will just assume a numerical value of 0 for all uninitialized variables. The only exception from this rule is with table elements. Hollywood will fail if you try to index table elements that are
Nil. It will not automatically assume 0 for them. That is why you have to explicitly initialize all table elements you want to use. Variables, on the other hand, don't have to be initialized explicitly. You can just use them and if they are still
Nil, Hollywood will assume they are 0.
Falseare simply special constants that will be mapped to the numerical values 1 and 0 respectively. There is no special object type for boolean values. This means that comparing 0 against
Truein Hollywood, whereas in Lua it would be
Falsebecause you would be comparing two different object types. Internally, Lua's boolean API is still supported by the VM and your plugin could use the respective functions from LuaBase but this is not recommended since Hollywood itself will never use Lua's boolean object type. It will always just use numbers. Not to mention that it is impossible to pass a real Lua boolean value to one of your plugin's functions because the parser will map all the
Falsekeywords to plain numbers.
endkeyword to close all kinds of different scopes, Hollywood has scope-dependent closing keywords like
EndIfand so on to make script files better readable.
not equaloperator whereas Hollywood uses
<>. Hollywood also supports much more operators than Lua does. For example, Hollywood comes with a variety of bitwise operators that Lua is missing entirely.
@INCLUDE. Preprocessor commands are prefixed by the at character (@).
Gosub(), although this is considered obsolete and is only included for compatibility with Hollywood 1.x.
lua_IDand the functions luaL_checkid() and luaL_checknewid() to deal with its object identifiers. See Object identifiers for details.
luaL_error()function which will directly jump to Lua's error handler. In Hollywood, however, you have to return an error code from your C function to indicate that an error has occurred. If that is not possible for some reason, you may also call lua_throwerror() to jump directly into Hollywood's error handler but the recommended way is returning an error code. The reason for this design is that working with error codes is preferable to doing a
longjmp()because it gives your code a chance to free resources before it error-exits. Note that Lua functions like
luaL_checknumber()will still jump into the error handler directly, so be prepared to deal with this.
See Library plugins for details.
See LuaBase for details.