Module:StorySim/Place:修订间差异
(创建页面,内容为“local p = {} local getArgs = require('Module:Arguments').getArgs local Data = mw.loadData('Module:RotaenoStoryData/PNodeText') -- Start -- local function makeInvokeFunc(funcName) return function(frame) local args = getArgs(frame) return p[funcName](args) end end p.main = makeInvokeFunc('_main') function p._main(args)-- 生成HTML的主函数 部分代码来源:Module:Songtable local id = args['bg'] or args['background'] or a…”) |
小无编辑摘要 |
||
(未显示同一用户的1个中间版本) | |||
第1行: | 第1行: | ||
local p = {} | local p = {} | ||
local getArgs = require('Module:Arguments').getArgs | local getArgs = require('Module:Arguments').getArgs; | ||
local Data = mw.loadData('Module:RotaenoStoryData/PNodeText') | local Data = mw.loadData('Module:RotaenoStoryData/PNodeText'); | ||
local classStorySim = require('Module:StorySim'); | |||
-- Start -- | -- Start -- | ||
第19行: | 第20行: | ||
--- 构建HTML --- | --- 构建HTML --- | ||
local box = mw.html.create("table"):addClass("rotable mw-collapsible mw-collapsed storyTable"); | local box = mw.html.create("table"):addClass("rotable mw-collapsible mw-collapsed storyTable"); | ||
box:tag('tr'):tag('th'):tag('h4'):attr('id',id):wikitext( | local title = '场景 | ' .. d[1]; | ||
local subTitle; | |||
if d[2] == '' then subTitle = ' ' | |||
else title = title .. '(' .. d[2] .. ')';subTitle = d[2]; | |||
end | |||
box:tag('tr'):tag('th'):tag('h4'):attr('id',id):wikitext(title); | |||
local node = box:tag('tr'):tag('td'):addClass('bgSim'); | local node = box:tag('tr'):tag('td'):addClass('bgSim'); | ||
node:tag('div'):addClass('subTitle'):wikitext( | node:tag('div'):addClass('subTitle'):wikitext(subTitle); | ||
node:tag('div'):addClass('Title'):wikitext(d[1]); | node:tag('div'):addClass('Title'):wikitext(d[1]); | ||
node:tag('div'):addClass('Context'):wikitext(d[3]); | node:tag('div'):addClass('Context'):wikitext(d[3]); | ||
local i = 2; | local i = 2; | ||
local storySimList = {}; | |||
while args[i] do | while args[i] do | ||
local name,linkID = string.match(args[i],'(.*) *>> *(.*)'); | local name,linkID = string.match(args[i],'(.*) *>> *(.*)'); | ||
if name and linkID then | if name and linkID then | ||
node:tag('div'):addClass('_link'):wikitext('[[#' .. linkID .. '|' .. name ..']]') | node:tag('div'):addClass('_link'):wikitext('[[#' .. linkID .. '|' .. name ..']]') | ||
storySimList[i] = classStorySim._main({'短剧 | ' .. name,linkID}); | |||
else error('链接格式错误!!') end | else error('链接格式错误!!') end | ||
i = i + 1; | i = i + 1; | ||
end | end | ||
local str = tostring(box); | |||
if i ~= 2 then | |||
storySimList[1] = str; | |||
str = table.concat(storySimList,"\n"); | |||
end | |||
return str | |||
end | end | ||
return p | return p; |
2023年12月31日 (日) 19:34的最新版本
可在Module:StorySim/Place/doc创建此模块的帮助文档
local p = {} local getArgs = require('Module:Arguments').getArgs; local Data = mw.loadData('Module:RotaenoStoryData/PNodeText'); local classStorySim = require('Module:StorySim'); -- Start -- local function makeInvokeFunc(funcName) return function(frame) local args = getArgs(frame) return p[funcName](args) end end p.main = makeInvokeFunc('_main') function p._main(args)-- 生成HTML的主函数 部分代码来源:[[Module:Songtable]] local id = args['bg'] or args['background'] or args['id'] or args[1]; local d = Data[id]; if not d then error('找不到场景文本!!!');end --- 构建HTML --- local box = mw.html.create("table"):addClass("rotable mw-collapsible mw-collapsed storyTable"); local title = '场景 | ' .. d[1]; local subTitle; if d[2] == '' then subTitle = ' ' else title = title .. '(' .. d[2] .. ')';subTitle = d[2]; end box:tag('tr'):tag('th'):tag('h4'):attr('id',id):wikitext(title); local node = box:tag('tr'):tag('td'):addClass('bgSim'); node:tag('div'):addClass('subTitle'):wikitext(subTitle); node:tag('div'):addClass('Title'):wikitext(d[1]); node:tag('div'):addClass('Context'):wikitext(d[3]); local i = 2; local storySimList = {}; while args[i] do local name,linkID = string.match(args[i],'(.*) *>> *(.*)'); if name and linkID then node:tag('div'):addClass('_link'):wikitext('[[#' .. linkID .. '|' .. name ..']]') storySimList[i] = classStorySim._main({'短剧 | ' .. name,linkID}); else error('链接格式错误!!') end i = i + 1; end local str = tostring(box); if i ~= 2 then storySimList[1] = str; str = table.concat(storySimList,"\n"); end return str end return p;