문제

I am trying to make a program that can run a program with certain conditions. Basically, I am using ComputerCraft with Minecraft and a turtle to retrieve items then go back to where it started. I stored all the coordinates inside tables individually as you can see in the code. But every time I run it, it does not work, since the usage for the goto program is incorrect. What happens is the tables with the coordinates are not getting called correctly, and I am not sure how to do so. The usage for the goto command is as follows: goto <x> <y> <z> [f]. X, Y and Z are the coordinates and f is the direction. Here's a pastebin to the code: http://pastebin.com/i73w0S1m

도움이 되었습니까?

해결책

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))

다른 팁

ok so do it like this this would work for me =) well, i duno about the processer code but i just fixed the usage code =)

 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

There you go hope it works =D XD Srry i accidentally edited Egor Skriptunoff code XD

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top