Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shell.run("clear")
- buttons = {}
- buttons["LV"] = {X = 3, Y = 3,BCol = colors.white,TCol = colors.green, BtnName = "LV Solar Panel"}
- buttons["MV"] = {X = 3, Y = 4,BCol = colors.white,TCol = colors.red, BtnName = "MV Solar Panel"}
- buttons["HV"] = {X = 3, Y = 5,BCol = colors.white,TCol = colors.blue, BtnName = "HV Solar Panel"}
- btnNone = colors.orange
- i = 0
- function cBut(cx,cy,tcol, bcol, bName)
- term.setCursorPos(cx,cy)
- term.setBackgroundColor(bcol)
- term.setTextColor(tcol)
- term.write(bName)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- end
- p = peripheral.wrap("bottom")
- lv = p.getItemIdentifierIDFor(183,0)
- mv = p.getItemIdentifierIDFor(183,1)
- hv = p.getItemIdentifierIDFor(183,2)
- print(lv)
- print(mv)
- print(hv)
- function setButs()
- cBut(buttons.LV.X,buttons.LV.Y,buttons.LV.TCol, buttons.LV.BCol,buttons.LV.BtnName)
- cBut(buttons.MV.X,buttons.MV.Y,buttons.MV.TCol, buttons.MV.BCol,buttons.MV.BtnName)
- cBut(buttons.HV.X,buttons.HV.Y,buttons.HV.TCol, buttons.HV.BCol,buttons.HV.BtnName)
- cBut(20,7,colors.white,colors.black,"Anzahl Request")
- cBut(26,8,colors.white,colors.black,tostring(i))
- cBut(25,8,colors.white,colors.black,"<")
- cBut(25 + string.len(i) + 1,8,colors.white,colors.black,">")
- cBut(20,9,colors.green,colors.black,"Start Request")
- cBut(3,10,colors.black,btnNone,"Nichts")
- end
- while true do
- req = 0
- shell.run("clear")
- setButs()
- evt,btn, x, y = os.pullEvent("mouse_click")
- if x == 25 and y == 8 then
- if i == 0 then
- i = 0
- else
- i = i - 1
- end
- elseif x == (25 + string.len(i) + 1) and y == 8 then
- i = i + 1
- elseif y == 9 then
- if x < string.len("Start Request") + 1 or x > 19 then
- if i == 0 then
- else
- if req == 0 then
- elseif req == 1 then
- l = p.makeRequest(lv,i)
- elseif req == 2 then
- l = p.makeRequest(mv,i)
- elseif req == 3 then
- l = p.makeRequest(hv,i)
- end
- term.setCursorPos(16,10)
- term.write("Request gestartet")
- term.setCursorPos(16,11)
- term.write(l)
- sleep(1)
- end
- end
- elseif y == buttons.LV.Y then
- if x > (buttons.LV.X -1) or x < (string.len(buttons.LV.BtnName) + 1) then
- buttons.LV.BCol = colors.orange
- buttons.MV.BCol = colors.white
- buttons.HV.BCol = colors.white
- btnNone = colors.white
- req = 1
- end
- elseif y == buttons.MV.Y then
- if x > (buttons.MV.X -1) or x < (string.len(buttons.MV.BtnName) + 1) then
- buttons.LV.BCol = colors.white
- buttons.MV.BCol = colors.orange
- buttons.HV.BCol = colors.white
- btnNone = colors.white
- req = 2
- end
- elseif y == buttons.HV.Y then
- if x > (buttons.HV.X - 1) or x < (string.len(buttons.HV.BtnName) + 1) then
- buttons.LV.BCol = colors.white
- buttons.MV.BCol = colors.white
- buttons.HV.BCol = colors.orange
- btnNone = colors.white
- req = 3
- end
- elseif y == 10 then
- if x > 2 or x < string.len("nichts") + 1 then
- buttons.LV.BCol = colors.white
- buttons.MV.BCol = colors.white
- buttons.HV.BCol = colors.white
- btnNone = colors.orange
- req = 0
- end
- end
- sleep(0.5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement