Advertisement
Guest User

startup

a guest
Mar 27th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.68 KB | None | 0 0
  1. rednet.open("right")
  2. Farben={"Hellgrau","Braun","Dunkelgrau","Orange","Schwarz","Blau","Pink","Weiss","Rot","Violett","Hellgruen","Magenta","Dunkelgruen","Cyan","Gelb","Hellblau"}
  3. Items={"Sticks","Blaze Rod", "Shear Blade","Glistering Melon","Bowl","Gravel","Snowball","Netherquarz","Iron Ingot","Brick","String","Cactus","Wheat","Leather","Gold Nugget","Gunpowder", "Flint","Glas","Clay","Egg","Sugar","Red Mushroom","Brown Mushroom", "Wooden Button"}
  4. term.clear()
  5. term.setCursorPos(1,1)
  6. os.loadAPI("button")
  7. ymin=2
  8. t=button.new("top")
  9. p2=button.new("top")
  10. p3=button.new("top")
  11. t:add("Team 1", function() Team1() end,2,2,14,4,colors.red,colors.lime)
  12. t:add("Team 2", function() Team2() end,16,2,28,4,colors.red,colors.lime)
  13. t:add("+++ Team +++", function() newTeam() end,2,6,14,6,colors.red,colors.lime)
  14. t:add("--- Team ---", function() delTeam() end,16,6,28,6,colors.red,colors.lime)
  15. p2:add("<",nil,1,1,3,1.5,colors.red,colors.lime)
  16. p3:add("<",nil,1,1,3,1.5,colors.red,colors.lime)
  17. function delTeam()
  18. clear()
  19. print("Vorhandene Teams: ")
  20. for _,name in pairs(FileList) do
  21. if name== "startup" then
  22.  elseif name=="rom" then
  23.   elseif name=="button"then
  24.   else
  25. print(name..".")
  26. end
  27. end
  28. print(" ")
  29. write("Welches der Teams soll geloescht werden?")
  30. print(" ")
  31. todel=read()
  32. if todel==" " then
  33. else
  34. p2:remove(todel)
  35. p3:remove(todel)
  36. if fs.exists(todel) then
  37. fs.delete(todel)
  38. end
  39. os.reboot()
  40. end
  41. end
  42.  
  43. function load(name)
  44. local file = fs.open(name,"r")
  45. local data = file.readAll()
  46. file.close()
  47. return textutils.unserialize(data)
  48. end
  49.  
  50.  FileList=fs.list("")
  51. for _, file in pairs (FileList) do
  52.   if file=="button" then
  53.   elseif file=="startup" then
  54.   elseif file=="rom" then
  55.   else
  56.   print(file.." wurde geladen")
  57.  p2:add(file,nil,2,ymin,28,ymin+1,colors.red,colors.lime)
  58.  p3:add(file,nil,2,ymin,28,ymin+1,colors.red,colors.lime)
  59.  ymin=ymin+3
  60.   end
  61.  
  62.  
  63. end
  64. function save(table,name)
  65. local file = fs.open(name,"w")
  66. file.write(textutils.serialize(table))
  67. file.close()
  68. end
  69.  function clear()
  70.  term.clear()
  71.  term.setCursorPos(1,1)
  72.  end
  73.  function newTeam()
  74.  newTeam={}
  75.  clear()
  76.  write("Teamname: ")
  77.  name=read()
  78.  clear()
  79.  for k,v in pairs(Farben) do
  80.  write(k.."    "..v..",  ")
  81.  end
  82.  print(" ")
  83.  write("Heimfarbe? ")
  84.  Heimzahl=read()
  85.  Heim=Farben[tonumber(Heimzahl)]
  86.   write("AuswåA4rtsfarbe? ")
  87.  Auswzahl=read()
  88.  Ausw=Farben[tonumber(Auswzahl)]
  89.  print(Ausw)
  90. write("Anzahl an Pferden: ")
  91.  horse=read()
  92.  
  93. for k,v in pairs(Items) do
  94.  write("Anzahl an "..v..": ")
  95.  Anzahl=read()
  96.  table.insert(newTeam,Anzahl)
  97.  end
  98.  newTeam.name=name
  99.  newTeam.Heim=Heim
  100.  newTeam.Ausw=Ausw
  101.  newTeam.horse=horse
  102. save(newTeam,newTeam.name)
  103.  os.reboot()
  104.  end
  105.  function Team1()
  106.  while true do
  107. p2:draw()
  108.        
  109.         local event, p1 = p2:handleEvents(os.pullEvent())
  110.         if event == "button_click" then
  111.            if p1=="<" then
  112.              MainLoop()
  113.              else
  114.                 p2:toggleButton(p1)
  115.                 ItemsAMTA= load(p1)
  116.  for k,v in pairs(ItemsAMTA) do
  117.  for k=1,24 do
  118.  rednet.send(k+2,tonumber(ItemsAMTA[k]))
  119.  end
  120.  
  121. end
  122. end
  123.         end
  124. end
  125.  end
  126.  function Team2()
  127.  p3:draw()
  128.  local event, p1 = p3:handleEvents(os.pullEvent())
  129.         if event == "button_click" then
  130.          if p1== "<" then
  131.          MainLoop()
  132.          else  
  133.                 p3:toggleButton(p1)
  134.                 ItemsAMTB= load(p1)
  135. for k,v in pairs(ItemsAMTB) do
  136.  print(v.." B")
  137. end
  138. end
  139.         end
  140.         end
  141.  function MainLoop()
  142. while true do
  143. t:draw()
  144.        
  145.         local event, p1 = t:handleEvents(os.pullEvent())
  146.         if event == "button_click" then
  147.            
  148.                
  149.                 t.buttonList[p1].func()
  150.         end
  151. end
  152. end
  153. MainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement