Advertisement
theinsekt

poz2test

Sep 3rd, 2014
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.24 KB | None | 0 0
  1. --poz2test
  2. --program to test theinsektAPIs/poz2
  3.  
  4. os.loadAPI("theinsektAPIs/poz2")
  5. local pos=poz2.getNewPosT()
  6. local args={...}
  7.  
  8.  
  9. local comnr=1
  10. local nrargs=0
  11. local com=nil
  12. local dir=nil
  13. local opt=nil
  14. for index,value in pairs(args) do
  15.     nrargs=nrargs+1
  16.     if nrargs==1 then
  17.             com=args[index]
  18.     end
  19.     if nrargs==2 then
  20.             dir=args[index]
  21.         end
  22.     if nrargs==3 then
  23.         opt=args[index]
  24.         print(comnr,": (",com,", ",dir,", ",opt,") running...")
  25.         local res=poz2.doCommand(com,dir,pos,opt)
  26.         print("returned: ",res)
  27.  
  28.         nrargs=0
  29.         comnr=comnr+1
  30.     end
  31.        
  32. end
  33.  
  34. if nrargs==0 and comnr==1 then
  35.  print("usage: poz2test <command1> <direction1> <extra1> <command2> <direction2> <extra2> ...")
  36.  print("example: poz2test go f - go f - ddgloop b 2 turn n -")
  37.  print("commands: turn, go, attack, dig, place, detect, compare, drop, suck, ddgloop")
  38.  return
  39. end
  40.  
  41. if comnr>1 then
  42. print("final position values: ")
  43. for key,value in pairs(pos) do
  44.     print(key," ",value)
  45. end
  46. end
  47.  
  48. if nrargs==1 then
  49.  print(poz2.commandUsageT[com])
  50.  print("directions: n,e,s,w,u,d,f,b,r,l")
  51. end
  52. if nrargs==2 then
  53.  print("the previous command requires 2 arguments not 1")
  54.  print(poz2.commandUsageT[com])
  55.  print("directions: n,e,s,w,u,d,f,b,r,l")
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement