chatgpt写的按原路返回的代码
新模式做完任务手动往回走很麻烦,用chatgpt弄了个按原路返回的代码。function reverse_path(opath)
local directions = {
n = "s",
s = "n",
e = "w",
w = "e",
u = "d",
d = "u",
nw = "se",
se = "nw",
ne = "sw",
sw = "ne",
nu = "sd",
sd = "nu",
wu = "ed",
ed = "wu",
eu = "wd",
wd = "eu",
su = "nd",
nd = "su",
et = "ot",
ot = "et"
}
local path_array = {}
for direction in string.gmatch(opath, "%a+") do
table.insert(path_array, 1, directions)
end
return table.concat(path_array, ";")
end
function clear_variables()
SetVariable("opath", "")
SetVariable("newpath", "")
Note("opath: " .. GetVariable("opath"))
Note("newpath: " .. GetVariable("newpath"))
end
local opath = GetVariable("opath")
local reversed_path = reverse_path(opath)
local path_array = {}
for direction in string.gmatch(reversed_path, "%a+") do
table.insert(path_array, direction)
end
-- 显示开始反向行走提示
Note("---开始反转行走---")
local delay = 0.5
for _, direction in ipairs(path_array) do
DoAfterSpecial(delay, direction .. ";", 10) -- 使用DoAfterSpecial发送方向
delay = delay + 0.5 -- 增加延迟
end
-- 在反向行走结束后,调用clear_variables函数
DoAfterSpecial(delay, "clear_vars", 10)
</alias>
</aliases>
好奇et 和 ot是什么方向 xfox 发表于 2023-5-8 01:13 PM
好奇et 和 ot是什么方向
应该是enter和out
页:
[1]