Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:LuaCall/doc
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Module rating|alpha}} This module allows you to call any one single preinstalled Lua function, so that you don't need to write a module for one desired feature. ==Usage== ===Main=== {{tlc|#invoke:LuaCall|main|{{var|arbitrary variables}}|{{var|parameters}}|{{var|functioncall}}}} The {{var|arbitrary variables}} are any key of your choice <code>=</code> any value of your choice. Values are interpreted as strings unless {{code|tonumber(value)|lua}} isn't {{code|nil|lua}}, i.e. numbers should be converted to the numeric type. No effort is made to interpret tables. The {{var|parameters}} all begin with <code>reserved_</code>, which arbitrary variable should use. * <code>reserved_return</code> sets which output from the function you want, and defaults to 1. For example, setting it to 2 for mw.ustring.gsub will return the number of replacements made. * <code>reserved_debug</code> - nonzero value forces display of a not particularly useful debug text The {{var|functioncall}} is written as <code>{{var|some.function.name}}({{var|a,b,c}})</code> where {{var|some.function.name}} means something in the [[mw:Extension:Scribunto/Lua reference manual|Extension:Scribunto/Lua reference manual]] and {{var|a,b,c}} are the arbitrary variable names you've chosen. ==Examples== ===Main=== *{{demo inline|<nowiki>{{#invoke:LuaCall|main|a=test |b=7|string.rep(a,b)}}</nowiki>}} *{{demo inline|<nowiki>{{#invoke:LuaCall|main|pattern=(%a)|replace=%1.|string=I can't get no satisfaction|mw.ustring.gsub(string,pattern,replace)|reserved_return=1}}</nowiki>}} *{{demo inline|<nowiki>{{#invoke:LuaCall|main|pattern=(%a)|replace=%1.|string=I can't get no satisfaction|mw.ustring.gsub(string,pattern,replace)|reserved_return=2}}</nowiki>}} *{{demo inline|<nowiki>{{#invoke:LuaCall|main|value=1.4512|math.ceil(value)}}</nowiki>}} *{{demo inline|<nowiki>{{#invoke:LuaCall|main|value=1.4512|math.modf(value)}}</nowiki>}} *{{demo inline|<nowiki>{{#invoke:LuaCall|main|value=1.4512|math.modf(value)|reserved_return=2}}</nowiki>}} *{{demo inline|<nowiki>{{#invoke:LuaCall|main|mw.text.nowiki(s)|s={{URL|1=https://www.Amazon.com/}}}}</nowiki>}} ===Call=== *{{demo inline|<nowiki>{{#invoke:LuaCall|call|string.format|%04x|127}}</nowiki>}} *{{demo inline|<nowiki>{{#invoke:LuaCall|call|math.modf|1.4512}}</nowiki>}} *{{demo inline|<nowiki>{{#invoke:LuaCall|call|math.modf|1.4512|return=2}}</nowiki>}} ==Errors== The module '''may''' generate script errors β whenever your call is not valid Lua code, you see the error you would normally have. For example, {{demo inline|<nowiki> {{#invoke:LuaCall|main|value=1.4512|math.fmod(value)}}</nowiki>}} because the second value is lacking. No effort is made to trap these. <includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | | <!-- Template categories below this line, please --> }}</includeonly>
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Code
(
edit
)
Template:Demo inline
(
edit
)
Template:Module rating
(
edit
)
Template:Tlc
(
edit
)
Template:Var
(
edit
)