这是林泊百科的迁移技术测试站点,所有改动不会同步到林泊百科上,此站点将会在正式迁移后关闭,请勿存放重要数据
模块:Terminal
跳转到导航
跳转到搜索
|
欢迎您参与完善本页面~
林泊百科祝您在像素塔度过愉快的时光。 |
local out = require("Module:Out")
local p = {}
function p.run(frame)
args = frame:getParent().args
prompt = frame.args["prompt"]
color = frame.args["color"]
result = frame.args["result"]
for i, cmd in ipairs(args) do
if mw.ustring.sub(cmd, 1, 1) == "/" then
-- 命令输入
out.writeln(prompt .. out.color(mw.ustring.sub(cmd, 2), color))
elseif mw.ustring.sub(cmd, 1, 1) == "@" then
-- 控制命令 默认只有一个参数 忽略空格
cut = mw.ustring.find(cmd, " ", 1, true)
name = mw.ustring.sub(cmd, 2, cut - 1)
arg = mw.ustring.sub(cmd, cut + 1)
if name == "color" then
color = arg
elseif name == "result" then
result = arg
elseif name == "prompt" then
prompt = arg
end
else
-- 命令回显
out.writeln(out.color(cmd, result))
end
end
end
p.main = out.create_main(p.run)
return p