Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- com = {"front","back","left","right","top","bottom"}
- m = peripheral.wrap("back")
- if fs.exists("GUI") then
- print("loading 1Ridav's GUI lib")
- os.loadAPI("GUI")
- else
- shell.run("pastebin","get","XcbJj1n4","GUI")
- print("loading 1Ridav's GUI lib")
- os.loadAPI("GUI")
- end
- write("enter channel(number, from 1 to 65000)")
- inp = read()
- act ={}
- if type(tonumber(inp)) == "number" then
- channel = tonumber(inp)
- m.open(channel)
- else
- error("not value")
- end
- function fw()
- side = com[1]
- SIDET:setText(side.." ")
- end
- function bc()
- side = com[2]
- SIDET:setText(side.." ")
- end
- function rh()
- side = com[4]
- SIDET:setText(side.." ")
- end
- function lt()
- side = com[3]
- SIDET:setText(side.." ")
- end
- function up()
- side = com[5]
- SIDET:setText(side.." ")
- end
- function down()
- side = com[6]
- SIDET:setText(side)
- end
- function send()
- if recc then
- table.insert(act,"set"..side)
- else
- m.transmit(channel,channel,"set"..side)
- end
- end
- function rm()
- if recc then
- table.insert(act,"rm"..side)
- else
- m.transmit(channel,channel,"rm"..side)
- end
- end
- function record(s)
- if s.check then
- recc = true
- else
- recc = false
- end
- end
- function execute()
- if type(act) == "table" then
- for i=1,#act do
- if type(act[i]) == "string" then
- if string.sub(act[i],1,5) == "sleep" then
- sleep(tonumber(string.sub(act[i],7,9)))
- else
- m.transmit(200,200,act[i])
- end
- elseif type(act[i]) == "table" then
- tab = act[i]
- for o=1,tab[#tab] do
- for j=1,#tab-1 do
- m.transmit(200,200,tab[j])
- end
- end
- end
- sleep(0.5)
- end
- end
- end
- function clear()
- act = {}
- end
- function sleep()
- nsl = 1
- if last == "sleep" then
- nsl = sl + 1
- end
- if recc then
- table.insert(act,"sleep "..nsl)
- end
- end
- term.clear()
- term.setCursorPos(1,1)
- FB = GUI.NewButton(nil, 7, 6, 8, 3, "FRONT", fw)
- BB = GUI.NewButton(nil, 7, 16, 8, 3, "BACK", bc)
- LB = GUI.NewButton(nil, 3, 10, 3, 5, "LEFT", lt)
- RB = GUI.NewButton(nil, 16, 10, 3, 5, "RIGHT", rh)
- UB = GUI.NewButton(nil, 7, 10, 8, 2, "TOP", up,colors.red)
- DB = GUI.NewButton(nil, 7, 13, 8, 2, "BOTTOM",down,colors.red)
- SETB = GUI.NewButton(nil, 3, 6 ,3,3,"SET",send,colors.green)
- RMB = GUI.NewButton(nil ,16 ,6 , 3,3, "REMOVE",rm,colors.green)
- REC = GUI.NewCheckBox(nil, 22 , 6 ,2 ,1 ,nil ,record , colors.orange)
- EXECUTE = GUI.NewButton(nil, 17, 2, 8, 1, "EXECUTE",execute,colors.red)
- CLEAR = GUI.NewButton(nil, 17, 3, 8, 1, "CLEAR",clear,colors.green)
- SLEEP = GUI.NewButton(nil, 17, 4, 8, 1, "SLEEP",sleep,colors.blue)
- SIDET = GUI.NewLabel(nil, 9,2,"none ")
- GUI.MainPanel:addCHILD(FB,BB,UB,DB,LB,RB,SETB,RMB,REC,EXECUTE,CLEAR,SLEEP,SIDET)
- GUI.MainPanel:draw()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement