Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("right")
- Farben={"Hellgrau","Braun","Dunkelgrau","Orange","Schwarz","Blau","Pink","Weiss","Rot","Violett","Hellgruen","Magenta","Dunkelgruen","Cyan","Gelb","Hellblau"}
- 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"}
- term.clear()
- term.setCursorPos(1,1)
- os.loadAPI("button")
- ymin=2
- t=button.new("top")
- p2=button.new("top")
- p3=button.new("top")
- t:add("Team 1", function() Team1() end,2,2,14,4,colors.red,colors.lime)
- t:add("Team 2", function() Team2() end,16,2,28,4,colors.red,colors.lime)
- t:add("+++ Team +++", function() newTeam() end,2,6,14,6,colors.red,colors.lime)
- t:add("--- Team ---", function() delTeam() end,16,6,28,6,colors.red,colors.lime)
- p2:add("<",nil,1,1,3,1.5,colors.red,colors.lime)
- p3:add("<",nil,1,1,3,1.5,colors.red,colors.lime)
- function delTeam()
- clear()
- print("Vorhandene Teams: ")
- for _,name in pairs(FileList) do
- if name== "startup" then
- elseif name=="rom" then
- elseif name=="button"then
- else
- print(name..".")
- end
- end
- print(" ")
- write("Welches der Teams soll geloescht werden?")
- print(" ")
- todel=read()
- if todel==" " then
- else
- p2:remove(todel)
- p3:remove(todel)
- if fs.exists(todel) then
- fs.delete(todel)
- end
- os.reboot()
- end
- end
- function load(name)
- local file = fs.open(name,"r")
- local data = file.readAll()
- file.close()
- return textutils.unserialize(data)
- end
- FileList=fs.list("")
- for _, file in pairs (FileList) do
- if file=="button" then
- elseif file=="startup" then
- elseif file=="rom" then
- else
- print(file.." wurde geladen")
- p2:add(file,nil,2,ymin,28,ymin+1,colors.red,colors.lime)
- p3:add(file,nil,2,ymin,28,ymin+1,colors.red,colors.lime)
- ymin=ymin+3
- end
- end
- function save(table,name)
- local file = fs.open(name,"w")
- file.write(textutils.serialize(table))
- file.close()
- end
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function newTeam()
- newTeam={}
- clear()
- write("Teamname: ")
- name=read()
- clear()
- for k,v in pairs(Farben) do
- write(k.." "..v..", ")
- end
- print(" ")
- write("Heimfarbe? ")
- Heimzahl=read()
- Heim=Farben[tonumber(Heimzahl)]
- write("AuswåA4rtsfarbe? ")
- Auswzahl=read()
- Ausw=Farben[tonumber(Auswzahl)]
- print(Ausw)
- write("Anzahl an Pferden: ")
- horse=read()
- for k,v in pairs(Items) do
- write("Anzahl an "..v..": ")
- Anzahl=read()
- table.insert(newTeam,Anzahl)
- end
- newTeam.name=name
- newTeam.Heim=Heim
- newTeam.Ausw=Ausw
- newTeam.horse=horse
- save(newTeam,newTeam.name)
- os.reboot()
- end
- function Team1()
- while true do
- p2:draw()
- local event, p1 = p2:handleEvents(os.pullEvent())
- if event == "button_click" then
- if p1=="<" then
- MainLoop()
- else
- p2:toggleButton(p1)
- ItemsAMTA= load(p1)
- for k,v in pairs(ItemsAMTA) do
- for k=1,24 do
- rednet.send(k+2,tonumber(ItemsAMTA[k]))
- end
- end
- end
- end
- end
- end
- function Team2()
- p3:draw()
- local event, p1 = p3:handleEvents(os.pullEvent())
- if event == "button_click" then
- if p1== "<" then
- MainLoop()
- else
- p3:toggleButton(p1)
- ItemsAMTB= load(p1)
- for k,v in pairs(ItemsAMTB) do
- print(v.." B")
- end
- end
- end
- end
- function MainLoop()
- while true do
- t:draw()
- local event, p1 = t:handleEvents(os.pullEvent())
- if event == "button_click" then
- t.buttonList[p1].func()
- end
- end
- end
- MainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement