模块:Terminal:修订间差异

来自Limbo Wiki
→‎ver alpha:​: submit for bugfix
标签(旧)WikiEditor
 
无编辑摘要
标签(旧)WikiEditor
第8行: 第8行:
result = frame.args["result"]
result = frame.args["result"]
for i, cmd in ipairs(args) do
for i, cmd in ipairs(args) do
    if mw.ustring.sub(cmd, 1, 1) == "/" then
if mw.ustring.sub(cmd, 1, 1) == "/" then
    -- 命令输入
-- 命令输入
    out.writeln(prompt .. out.color(mw.ustring.sub(a, 2), color))
out.writeln(prompt .. out.color(mw.ustring.sub(a, 2), color))
    elseif mw.ustring.sub(cmd, 1, 1) == "@" then
elseif mw.ustring.sub(cmd, 1, 1) == "@" then
    -- 控制命令 默认只有一个参数 忽略空格
-- 控制命令 默认只有一个参数 忽略空格
    cut = mw.ustring.find(cmd, " ", 1, true)
cut = mw.ustring.find(cmd, " ", 1, true)
    name = mw.ustring.sub(cmd, 1, cut - 1)
name = mw.ustring.sub(cmd, 1, cut - 1)
    arg = mw.ustring.sub(cmd, cut + 1)
arg = mw.ustring.sub(cmd, cut + 1)
    if name == "color" then
if name == "color" then
    color = arg
color = arg
    elseif name == "result" then
elseif name == "result" then
    result = arg
result = arg
    elseif name == "prompt" then
elseif name == "prompt" then
    prompt = arg
prompt = arg
    end
end
    else
else
    -- 命令回显
-- 命令回显
    out.writeln(prompt .. out.color(cmd, result))
out.writeln(prompt .. out.color(cmd, result))
    end
end
end
end
end
end

2023年3月19日 (日) 09:37的版本

欢迎您参与完善本页面~
欢迎正在阅读这个条目的您协助编辑本页面以做出您的改进。编辑前请先阅读入门指南,并了解像素塔基本设定。
林泊百科祝您在像素塔度过愉快的时光。

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(a, 2), color))
		elseif mw.ustring.sub(cmd, 1, 1) == "@" then
			-- 控制命令 默认只有一个参数 忽略空格
			cut = mw.ustring.find(cmd, " ", 1, true)
			name = mw.ustring.sub(cmd, 1, 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(prompt .. out.color(cmd, result))
		end
	end
end

p.main = out.create_main(p.run)

return p