Search results
Results from the WOW.Com Content Network
Function names are often of the form p.myFunctionName, where p is the table from the return p at the bottom of your program. The reason for this is that you can only access functions that are entries in this table from the original #invoke statement. Functions for local use within the program can have any name.
-----local libraryUtil = require ('libraryUtil') local p = {}-- Define often-used variables and functions. local floor = math.floor local infinity = math.huge local checkType = libraryUtil. checkType local checkTypeMulti = libraryUtil. checkTypeMulti----- isPositiveInteger---- This function returns true if the given value is a positive integer ...
function p. q is syntactic sugar for p ["q"] = function. function builds a function. It doesn't declare it. Functions are first-class objects and can be assigned to variables, placed in tables, serialized into strings, and deserialized back out again. Think interpreted, not compiled.
To expand such a script with more (invocable) functions, one adds them between the local statement at the top and the return statement at the bottom. (Non-invocable local functions can be added before the local statement.) The local variable doesn't have to be named p. It could be named any valid Lua variable name that you like.
It is intended for use by other Lua modules, and should not be-- called from #invoke directly. local libraryUtil = require ('libraryUtil') local checkType = libraryUtil. checkType local arguments = {}-- Generate four different tidyVal functions, so that we don't have to check the-- options every time we call it. local function tidyValDefault ...
Help:Lua for beginners; Help:Lua debugging – about debugging Lua modules; Wikipedia:Lua style guide – standards to improve the readability of code through consistency; Module:Sandbox provides a pseudo-namespace for experimenting with Lua modules
Marshalling data between C and Lua functions is also done using the stack. To call a Lua function, arguments are pushed onto the stack, and then the lua_call is used to call the actual function. When writing a C function to be directly called from Lua, the arguments are read from the stack. Here is an example of calling a Lua function from C:
The functions of the Module:SimpleDebug can be used for cases such as those mentioned above or for more complex cases: When variables or the returned value (or values) by a function are local. To see if the flow of the program goes through a point (to which you will label).