Andy73

scripts.lua (pc)

May 11th, 2014
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.77 KB | None | 0 0
  1. --local path="storage/sdcard0/DWorkspace/ACOS ideas/Andy (Dev)/EA testing"
  2. local path=shell.resolve(".")
  3. dofile(path.."/lib/indv.lua")
  4. world={
  5. {0,0,0,0,0},
  6. {0,0,0,1,0},
  7. {0,0,1,0,0},
  8. {1,0,0,0,0},
  9. {0,0,0,0,1},}
  10.  
  11. function serialize(table)
  12.  local sresult,k1="{\n",nil
  13.  for k,v in pairs(table) do
  14.   if type(v)=="table" then k1=serialize(v) v1="," else k1=k v1="="..v.."," end
  15.   sresult=sresult.."  "..k1..v1.."\n"
  16.  end
  17.  return sresult.."}"
  18. end
  19. function serialize2(table)
  20.  local sresult,k1="{\n",nil
  21.  for k,v in pairs(table) do
  22.   if type(v)=="table" then k1=serialize2(v).."\n" v1="," else k1=k v1="="..v.."," end
  23.   sresult=sresult.."  "..k1..v1
  24.  end
  25.  return sresult.."}"
  26. end
  27. function refuel(x)
  28. --print"refuel called"
  29. if world then
  30. local newW=x:feed(world) else error("newW is nil or false",2) end
  31. if not newW then print("Could not refuel") return false else world=newW end
  32. print"--Refuel Complete!--"
  33. print("Current fuel lvl:"..x.fuel)
  34. end
  35.  
  36. local function arrow()
  37.  if test.rot==1 then
  38.     return "^"
  39.  elseif test.rot==2 then
  40.     return "<"
  41.  elseif test.rot==3 then
  42.     return "v"
  43.  else
  44.     return ">"
  45.  end
  46. end
  47.  
  48. function updateUI()
  49. sleep(0.2)
  50. term.clear()
  51. term.setCursorPos(1,1)
  52. term.setBackgroundColor(colors.white)
  53. term.setTextColor(colors.black)
  54.  for k,v in pairs(world) do
  55.     for _,__ in pairs(v) do
  56.         if __==1 then term.setBackgroundColor(colors.green) end
  57.         if test.pos.x==_ and test.pos.y==k then term.write(arrow()) else term.write(" ") end
  58.         term.setBackgroundColor(colors.white)
  59.     end
  60.     print""
  61.  end
  62. sleep(0.3)
  63. term.setTextColor(colors.white)
  64. term.setBackgroundColor(colors.black)
  65. term.clear()
  66. term.setCursorPos(1,1)
  67. end
  68.  
  69.  
  70. local individuals={}
  71. test=individual:new()
  72. --[[test:go(world)
  73. test:turnLeft()
  74. refuel(test)]]
  75.  
  76.  
  77. dofile(path.."/AIs/testAI.lua")
Advertisement
Add Comment
Please, Sign In to add comment