Search results
Results from the WOW.Com Content Network
See also: the {{}} template. The #if function selects one of two alternatives based on the truth value of a test string. {{#if: test string | value if true | value if false}} As explained above, a string is considered true if it contains at least one non-whitespace character.
Some important things like mw.ustring.gmatch actually return functions, not strings - see Functions below. no such module. You #invoked a module that didn't exist — or wrote #invoke:Module:x instead of #invoke:x. the function specified did not exist. You #invoked a module, but the field after the name of the module is wrong. Often this field ...
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.
While this page doesn't currently have anything to say about semicolons, in Lua code they're generally avoided except when necessary (i.e. a statement ending with a function call is followed by a statement starting with a parenthesized expression) or when multiple statements are on a line.
preprocess_equals_sandbox_many(module, function, cases, options): Performs a series of preprocess_equals_compare() calls on a set of given pairs.The test compares the live version of the module vs the /sandbox version and vs an expected result.
The switch parser function, coded as "#switch", selects the first matching branch in a list of choices, acting as a case statement. Each branch can be a value , an expression ( calculation ), or a template call, [ 1 ] evaluated and compared to match the value of the switch.
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: