Base Lua differences:
● Replaced the not so random default standard lib 16bit random number generator with a fast 53bit precision one.
Effects the Lua math.randomseed() and math.random() functions.
● The format() method was extended to display up to 64bit hex numbers.
Example:
print(string.format (“Large hex: %016I64X\n”, 0x0123456789ABCDEF))
Output: “Large hex: 0123456789ABCDEF”
● To compliment the library function os.execute(), a wrapper for the more useful Windows API function ShellExecute() was added.
All parameters can be nil as NULL for some parameters.
boolean,result = os.ShellExecute([szOperation], [szFile], [szParameters], [szDirectory])
Returns true on success, and a result code on error.
Examples:
-- Open default email program with an email address.
os.ShellExecute(nil, "mailto:bugreport@email.com")
-- Open a web page
os.ShellExecute("open", "http://www. macromonkey.com")
-- Open a file in Notepad
os.ShellExecute("open", "notepad.exe", "MyScript.mms", nil)
-- Open Windows Explorer in the current directory
os.ShellExecute("explore" , nil, nil, nil)
See MSDN document ShellExecute() for more information.
http://msdn.microsoft.com/en-us/library/bb762153%28VS.85%29.aspx
● string.pack, and string.unpack to the string library (see below).
● LuaJIT “Just-In-Time compiler” to give MM (MacroMonkey) scripts a speed up to seven times and more!
And adds the Coco extension that fixes some internal Lua coroutine issues.
See: http://luajit.org/
● Support added to the C API for some “missing” boolean, and 64bit integer functions.
Plus many more internal tweaks, optimization, and enhancements; such as a custom memory al locator, support for Lua number to 64 bit integer conversion, larger internal buffers, etc.
Note about 64 integer usage. MM Lua uses double floats (64bit) internally. It gives a very large range of precision for number representations. An entire 32bit integer (unsigned or signed) will fit in it’s range easily. However a 64bit integer will not. If a number is larger then 53 bits, some lower bits will be truncated! This may or not be a problem for you depending on the use. It is certainly a problem in the typical case where a lot of games and what not use a 64bit ID number for “world items”, etc. In this case, the simple solution is to split the number into a high and low part.
See for more info: http://en.wikipedia.org/wiki/Double_precision
MacroMonkey Extensions
MacroMonkey extends Lua with a large collection of internal libraries that provide OS wrappers and extra functionality.
Extensive use of tables and meta methods to organize things into packages (like namespaces in C++ et al).
Smart handles:
MM (MacroMonkey) uses a custom “smart” handle type internally for object handles (like process handles) and Registry handles so that they can be automatically closed in garbage collection.
Keep this in mind when dealing with handle variable scopes. If a handle is only local it will eventually be closed automatically if/when it looses scope. You can also close most handles manually by calling the meta method close() for the given handle type.
Example:
-- Terminate a process by PID
function KillProcTest(uPID)
local hHandle = process.Open(uPID)
if (hHandle ~= nil) then
process.Terminate(hHandle)
end
-- We could explicitly close the handle this way (if it were not commented out)
---process.Close(hHandle)
--
Since “hHandle” is local to this function it will loose scope when we exit/end it, and thus be automatically closed on
---
the next garbage collection cycle.
end