??????
Scribunto
, ??????? ????? ??????? ????
Lua
?????? ??? ?
??????
, ?????? ?????????? ??????.
????? ???????
???? ????? ???
.
?????? ???????, ??? ???? ???? "??????" ??????? ?????? ????? ?? ?????, ??????? ?????? ????? ????? ?? ??? ????? "?????" (??????? module). ?? ????? ????? ?????? ???? ?????? ?????? ??? ?? ???????? ??????? ??????? ????? ?????? ?????? ???.
?? ????? ????? ??????, ????, "????? ???????" (?????, ????? ???
?????:????? ???????
) ??????? ??? ????????: "??? ???? ?? ??" ?"????? ?? ?? ??":
-- each module returns a table, whose keys are the invocation names, which can be any string, including spaces, numbers, hebrew letters etc.
-- the values are functions to be invoked using those names.
-- there are several ways to achieve this. the "best practice" in hewiki described below.
-- modules imported from other wikis often use different way to create and return this table.
-- best practice:
-- all variables and functions are local.
-- at the bottom of the module, we return a literal table, constructed by assigning functions to invocation names:
local
function
f1
(
frame
)
-- documentation linked above explains how to extract parameters from frame
return
'??? ???????!'
end
local
function
f2
(
frame
)
return
'????? ????'
end
-- here we return the invocations:
return
{
[
'??? ???? ?? ??'
]
=
f1
,
[
'????? ?? ?? ??'
]
=
f2
,
}
??? ?????? ??????, ?? "???? ???" ???? ??? invoke. ????? ??? ?? ??? ??? ???????: ?? ?????? ??? ????????. ?????, ???? ?????? ??????? ?????? ??? ?????. ??????? ?????? ??? ?????? ????????. ???? ????? ?????? ???????? ??? ???????:
{{#invoke:????? ???????|??? ???? ?? ??}}
????? ??????? ???????? ?-Lua
[
????? ??? ????
]
???????? ?????? ?-invoke ????? ???? ????? ???? ????? (?? ?? ?? ????) ????? ?? frame. ????? ?? ???? ????? ???? ????????? ?-lua ????? ????? ??????? ??. ??????, ???? ?? ?????? ?????? ?? ?????? ?-invoke ???? ?-
frame:getParent()
. ?????, ???????? ???????? ??????? ?????? ?-frame.args. ????? ???????? ???????, ??????? ???????? ?????? ????? ?????? ??? ?? ?????. ???? ?????? ????? ?????? ???????? king_wives ????? ???????: ????? ??? ??? "???", ???? ??????? ?????? ???:
{{#invoke:m|king_wives|???=????|40|25}}
???????? ????? ???????? ????? args:
function
m
.
king_wives
(
frame
)
local
king
=
frame
.
args
[
"???"
]
local
param1
=
frame
.
args
[
1
]
local
param2
=
frame
.
args
[
2
]
-- do something with the parameters, e.g.:
return
string.format
(
"?%s ???? ??? %d ????"
,
king
,
param1
*
param2
)
end
?? ???? ???????? ??? ?????? ?????, ???? ??? "????? ???? ??? 1000 ????".
????? ???, ??????:
{{#invoke:m|king_wives|???=???|3|6}}
???? "???? ???? ??? 18 ????".
????????? ???????? ?????? ?????? ?????? ??? ???? ????? - ??? ???, ????, ??????, ????, ??? ???????, ?? ????? ???????. ??????? "?????", ????? ??? ?????? ???? ????, ????? ?????? ??????. ???? ?????? ????????, ??????? ??????? ?????? ????? (parser) ????? ??????. ??????? ??? ??? ???????? ????, ????, ????? ?????, ??? ?? ????? ?????? ?????? html ?? ?? img, ??? ?????? ???? ????, ??? ?????? ???? ??? - [[????:?? ?????]].
????? ??????, ?????? ????? ??? ?????, ???? ????? ??????, ????? "????? ?????? ?? ??? ?? ?????? ????". ?????? ?? ?? ?????? ??????, ??????? "????". ??? ????? ????? ???? ????? ????? ?????. ?????? ????? ????, ??? ?? ????? ?????? ???? ?????? ??????, ?????? ????. ???? ????? ??????? ?????? ?????, ?????? ?????? ????? ??????, ???? ??? ?????? ???????? ???, ??? ????? ?? ?????? ???? ???? ?? ?????? ??????.
??? ????? ??????, ???? ????? ????? "??????", ?????
mw.log()
, ?-
mw.logObject()
. ??????? ?????? ?"????? ????". ????? ????????? ???? ?
mw:Extension:Scribunto/Lua reference manual
????? ???? ??????? ?????? ??????? ?????? ???. ?? ?????? ?? "?????? ??????", ???????? ?????? ???????, ????? ??????.
???? ????? ??? ???? ???? ??????????, ????? ????? ?????. ???? ?? ????? ???? ?????????? ??? ???? 5.1, ????? ?????? ????? ?? ???? ??????, ???? ??????? ????? ???? ?? ???? ?? ?????? ????? ????? ?????, ??????? ??????? ???? ?????????. ????? ????? ????? ????? ?????? ?????? ??????? ?????, ??????? debugging ??? ?????? ?????? ?????????? ????.
??????
???? ??? ???????
????? ?? ??????????. ????? ?????, ???? ???? ?????? ??????? ????? ??????, ???? ?????? ????? ?????.
???? ??? ??? ???? ?????? ????? ???, ???? ????? ?????? ?????, ????? "????? ?????? ?? ??", ??????, ??"??????????" ?????? ?????? ????? ???? ??????.
???? ????? ???? ????? ????, ????? ??????? ?????? ????? ??????, ?? ?????? ?????? ??????, "???? ????" ????? ????? ????? ?????? "???? ????????", ???? ??????? ?? ??????? ???????? ???? ????? ?????. ???? ???? "?????" ???? ??? ???? ????? ?????? ??????? ??????? ?????, ???? ??????? ????? ????.
?"???? ?????????" ??? ??? ?? ????? ??????, ???? ??????? ???????? ???????? ?? ??? ???? ?? ??? ???, ???????? ??????? ?
?????:
??
?????:
.
???????
??????:???????
???? ???? ????? ??? ??? "????", ?? ????? ??????? ???? ???? ????? ?????? ???? ??? ??. ??? ?? ??? ?????? ?? ??? ???
"??????:???????/???? ???/?????:????"
. ???? ?? ???? ?????? ??????:
- ????????? ??? ???, ?"??????" ????????? ??????? ???????? ??? ???? ?? ??? ??, ??? ????? ??? ?? ????? ??? ????? ?????, ??? ??? ????? ??????, ???? ???? ????????.
- ????????? ??? ????? ??????? ???????, ???
????
?????? ???? ?????, ?????? ???? ??? ??? ???? ??????. ?????? ?????? (????? ????????? ?? ???? ???? invoke#), ?????? ????? ?? ???? ??????? ??? ?????? ?????? ?????? ????? ??? ????? ???? ?????. ?????? ????, ???? ????? ?????? ??? ??? ????. ?????? ?"???? ??? ???????", ???? ??????? ?"?? ??????" ??? ???? ??? ?????? ????? ??? (?????, ????? ?? ?? "????" ????? "?????", ?? ??? ??? ???? ?????:????, ????? ??????) ???? ?????? ?? ?????? ???? ???????? ???? ?????. ???? ??????? ?????? ?????? ????? ??????, ??????? ??????? ????? ?? ??? ??? ????? ???? ?????. ?? ?? ?????? ??? ??????, ???? ?? ?? ?????.
????????? ????? ????? ?? ????? ?????????? ?? ??? ???? ????? ?????? ??????? ?"???? ??? ???????", ??? ????? ?? ???? ??????? ?????? ?? ????, ??? ????? ????, ?????? ?? ????? ?????? ??????? ??????, ?????? ????? ??? ?? ??? ?????? ???? ??? "?????? ????? ???". ?? ????? ?? ????? ???? ??????, ?????? ????? ???. ?? ??, ??? ????? ?????? ?? ?????? ????? ????? ??????? ?? ???????? ??? ??. ?????? ????, "?????? ????? ???" ??? "??????:???????/???? ???", ???? ???????? ????? ?
{{#invoke:????|....}}
, ?????? ???? ?? ???? ????? ??? "??????:???????/???? ???/?????:????".