我正在尝试创建一个可以运行某些条件的程序的程序。基本上,我正在使用带有Minecraft和乌龟的ComputerCraft来检索物品,然后回到它开始的地方。我可以在代码中看到,单独存储表中的所有坐标。但是每次运行它都不起作用,因为goto程序的使用不正确。会发生什么事情是没有正确调用坐标表,我不知道该怎么做。 goto命令的用法如下:goto <x> <y> <z> [f]
。 X,Y和Z是坐标,f是方向。这是代码中的一个pastebin:http://pastebin.com/i73w0S1m
答案 0 :(得分:1)
local tArgs = {...}
if not tArgs[1] then
print("Usage: request <item name> <amount>")
return
end
local currentPOS = {gps.locate()}
local im = peripheral.wrap("left")
local all_items = {
diamond = { -300, 64, -190, 1 },
cobble = { -300, 65, -190, 1 },
...
brass = { -299, 66, -189, 0 },
copper = { -299, 67, -189, 0 },
}
shell.run("goto", unpack(all_items[tArgs[1]]))
im.suck(0, tArgs[2])
shell.run("goto", unpack(currentPOS))
答案 1 :(得分:0)
好的,所以这样做这对我有用=)好吧,我duno关于处理器代码,但我只修复了使用代码=)
local tArgs = {...}
function usage()
print("Usage: request <item name> <amount>")
return
end
if #tArgs < 1 then
usage()
else
if #tArgs > 2 then
usage()
else
local currentPOS = {gps.locate()}
local im = peripheral.wrap("left")
local all_items = {
diamond = { -300, 64, -190, 1 },
cobble = { -300, 65, -190, 1 },
...
brass = { -299, 66, -189, 0 },
copper = { -299, 67, -189, 0 },
}
shell.run("goto", unpack(all_items[tArgs[1]]))
im.suck(0, tArgs[2])
shell.run("goto", unpack(currentPOS))
end
end
你希望它有效吗= D XD Srry我偶然编辑了Egor Skriptunoff代码XD