Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("CCGUI");
- os.loadAPI("RPAPI")
- local side = "back";
- local running = RPAPI.getPower(side, "black");
- local up = "green";
- local down = "lime";
- function pulse(dir, dist)
- RPAPI.setPower(side, "black", true);
- for i=0, dist, 1 do
- RPAPI.setPower(side, dir, true);
- os.sleep(1);
- RPAPI.setPower(side, dir, false);
- os.sleep(1);
- end
- RPAPI.setPower(side, "black", false);
- end
- function getLvl()
- if RPAPI.getPower(side, "magenta") == true then
- return 1;
- elseif RPAPI.getPower(side, "purple") == true then
- return 2;
- elseif RPAPI.getPower(side, "brown") == true then
- return 3;
- elseif RPAPI.getPower(side, "lightBlue") == true then
- return 4;
- elseif RPAPI.getPower(side, "yellow") == true then
- return 5;
- elseif RPAPI.getPower(side, "lightGray") == true then
- return 6;
- elseif RPAPI.getPower(side, "gray") == true then
- return 7;
- elseif RPAPI.getPower(side, "white") == true then
- return 8;
- elseif RPAPI.getPower(side, "orange") == true then
- return 9;
- end
- end
- function getDir(from, to)
- if from > to then
- return up;
- else
- return down;
- end
- end
- function calcDist(from, to, dir)
- local dif = 0;
- local layers = 0;
- if from == 1 or to == 1 then
- dif = 3;
- end
- if dir == up then
- layers = from - to;
- else
- layers = to - from;
- end
- layers = (layers * 8) - dif;
- return layers;
- end
- function procesPress(to)
- local dir = getDir(getLvl(), to);
- local dist = calcDist(getLvl(), to, dir);
- pulse(dir, dist);
- end
- function drawScreen()
- def = CCGUI.newMenu()
- b1 = CCGUI.newItem()
- b2 = CCGUI.newItem()
- b3 = CCGUI.newItem()
- b4 = CCGUI.newItem()
- b5 = CCGUI.newItem()
- b6 = CCGUI.newItem()
- b7 = CCGUI.newItem()
- b8 = CCGUI.newItem()
- b9 = CCGUI.newItem()
- b1:newName("[ 1]")
- b1:newType("bp1")
- b1:newColour(colours.magenta)
- b2:newName("[ 0]")
- b2:newType("bp2")
- b2:newColour(colours.magenta)
- b3:newName("[-1]")
- b3:newType("bp3")
- b3:newColour(colours.magenta)
- b4:newName("[-2]")
- b4:newType("bp4")
- b4:newColour(colours.magenta)
- b5:newName("[-3]")
- b5:newType("bp5")
- b5:newColour(colours.magenta)
- b6:newName("[-4]")
- b6:newType("bp6")
- b6:newColour(colours.magenta)
- b7:newName("[-5]")
- b7:newType("bp7")
- b7:newColour(colours.magenta)
- b8:newName("[-6]")
- b8:newType("bp8")
- b8:newColour(colours.magenta)
- b9:newName("[-7]")
- b9:newType("bp9")
- b9:newColour(colours.magenta)
- def:newItem(b1)
- def:newItem(b2)
- def:newItem(b3)
- def:newItem(b4)
- def:newItem(b5)
- def:newItem(b6)
- def:newItem(b7)
- def:newItem(b8)
- def:newItem(b9)
- while true do
- bp = def:draw()
- if bp =="bp1" then procesPress(1); CCGUI.msgBox({"Going to 1" , "They see me rollin","They waitin"}); end
- if bp =="bp2" then procesPress(2); CCGUI.msgBox({"Going to 0" ,"They see me rollin","They waitin"}); end
- if bp =="bp3" then procesPress(3); CCGUI.msgBox({"Going to -1","They see me rollin","They waitin"}); os.reboot(); end
- if bp =="bp4" then procesPress(4); CCGUI.msgBox({"Going to -2","They see me rollin","They waitin"}); os.reboot(); end
- if bp =="bp5" then procesPress(5); CCGUI.msgBox({"Going to -3","They see me rollin","They waitin"}); os.reboot(); end
- if bp =="bp6" then procesPress(6); CCGUI.msgBox({"Going to -4","They see me rollin","They waitin"}); os.reboot(); end
- if bp =="bp7" then procesPress(7); CCGUI.msgBox({"Going to -5","They see me rollin","They waitin"}); os.reboot(); end
- if bp =="bp8" then procesPress(8); CCGUI.msgBox({"Going to -6","They see me rollin","They waitin"}); os.reboot(); end
- if bp =="bp9" then procesPress(9); CCGUI.msgBox({"Going to -7","They see me rollin","They waitin"}); os.reboot(); end
- end
- end
- drawScreen()
Advertisement
Add Comment
Please, Sign In to add comment