View difference between Paste ID: J1ErE7pj and Lu0tTLaF
SHOW: | | - or go back to the newest paste.
1-
os.loadAPI("button")
1+
defaultSide = "left"
2-
local m = peripheral.wrap("monitor_0")
2+
autoModeBool = false
3-
m.clear()
3+
pocketID = 36
4
pocketID2 = 60
5-
function newTouchMenu()
5+
6-
m.clear()
6+
-- BundledCable Color Declarations
7-
m.setBackgroundColor(colors.black)
7+
local witherColor = colors.black
8-
m.setTextColor(colors.white)
8+
local forwardColor = colors.blue
9
local autoModeColor = colors.green
10
local autoModeCheckColor = colors.brown
11-
   
11+
local autoModeCheckColor2 = colors.magenta
12-
function fillTable()
12+
13-
   newTouchMenu()
13+
-- Fixes some API changes
14-
	button.clearTable()
14+
function colors.subtract(r, ...)
15-
        button.setTable("HouseControl", houseControl, 4,26 ,3,6)
15+
        for n, c in ipairs({ ... }) do
16-
        button.setTable("N/A", na, 4,26 ,9,12)
16+
                r = bit.band(r, bit.bnot(c)%2^31)
17-
        button.setTable("N/A2", na2, 4,26 ,14,17)
17+
18-
        button.setTable("Menu", mainMenu, 2,28, 19,20)
18+
        return r
19-
    print("Main Menu Filled")
19+
20-
    button.screen()
20+
21-
    end
21+
-- Pulses a bundled redstone color
22
function redstonePulse(color, side)
23-
function houseControl()
23+
addColor(color, side)
24-
button.flash("HouseControl")
24+
25-
newTouchMenu()
25+
delColor(color, side)
26-
button.clearTable()
26+
27-
  	button.setTable("Obsidian Collection", oC, 4,26 ,2,6)
27+
28-
        button.setTable("Energy Status", energyStatus, 4,26 ,8,12)
28+
-- Turns on a color of a bundled cable
29-
        button.setTable("Menu", mainMenu, 2,28, 19,20)
29+
function addColor(color , side)
30-
        button.setTable("N/A", na, 4,26 ,14,17)
30+
 rs.setBundledOutput(side, colors.combine(rs.getBundledOutput(side) + color))
31-
	print("House Control Filled")
31+
32-
button.screen()
32+
33
-- Turns a color off of a bundled cable
34
function delColor(color, side)
35-
function na()
35+
   rs.setBundledOutput(side, colors.subtract(redstone.getBundledOutput(side), color)) 
36-
button.flash("N/A")
36+
37-
print("I do nothing; Hurray!")
37+
38
-- Turns on the UberMiner AutoMode
39
function autoMode()
40-
function na2()
40+
	bool = checkColor(autoModeColor, defaultSide)
41-
button.flash("N/A2")
41+
	bool2 = checkColor(autoModeCheckColor, defaultSide)
42-
print("I do nothing 2; Hurray!")
42+
	
43
	-- If Kilo's server is running the AutoMode this will cancel it from running again.
44
	if bool2 then
45-
function oC()
45+
		term.setTextColor(colors.red)
46-
button.toggleButton("Obsidian Collection")
46+
		print("Already Running Somewhere else, remaining off @ nearest Server")
47-
rednet.send(63, "oc")
47+
		rednet.send(pocketID, "running")
48
		rednet.send(pocketID2, "running")
49
50-
function mainMenu()
50+
	-- If the Server is running the AutoMode it'll turn it on
51-
button.flash("Menu")
51+
	else if bool then
52-
m.clear()
52+
		print("AutoMode now Online!")
53-
   fillTable()
53+
		delColor(autoModeColor, defaultSide)
54-
--   refresh()
54+
		addColor(autoModeCheckColor2, defaultSide)
55
		rednet.send(pocketID, true)
56
		rednet.send(pocketID2, true)
57
58-
function energyStatus()
58+
	-- Or Else it'll turn AutoMode off.
59-
button.flash("Energy Status")
59+
	else
60-
m.clear()
60+
		addColor(autoModeColor, defaultSide)
61-
sleep(.1)
61+
		delColor(autoModeCheckColor2, defaultSide)
62-
m.setCursorPos(6,10)
62+
		print("AutoMode now Offline!")
63-
m.setTextScale(1)
63+
		rednet.send(pocketID, false)
64-
m.setTextColor(colors.white)
64+
		rednet.send(pocketID2, false)
65-
m.write("Loading Information")
65+
	
66
			
67-
m.clear()
67+
	end
68-
m.write("Loading Information.")
68+
	end
69
end
70-
m.clear()
70+
71-
m.write("Loading Information..")
71+
 -- Edit's the startup to boot up on this pastebin
72
 function startupClear()
73-
m.clear()
73+
                f = fs.open("startup", "w")
74-
m.write("Loading Information...")
74+
                f.write("shell.run('pastebin run J1ErE7pj')")
75
                f.close()
76-
m.clear()
76+
77-
button.clearTable()
77+
78-
button.setTable("Refresh", refresh, 2,28,0,2)
78+
	--Asks and saves where the bundled cable is locatated
79-
button.setTable("Menu", mainMenu, 2,28, 19,20)
79+
	function redstoneVar()
80-
button.screen()
80+
		print("Where will the redstone output be? [left,right,bottom,top]")
81-
m.setTextScale(1.4)
81+
		command = read()
82-
m.setCursorPos(0,10)
82+
		if command == "left" or command == "right" or command == "bottom" or command == "top" then
83-
button.centerText("Power : ..en")
83+
			print("Redstone set to "..command.." side")
84-
m.setCursorPos(21,3)
84+
			f = fs.open("redstoneVar", "w")
85
			f.writeLine(command)
86
			f.close()
87
			os.reboot()
88-
function getPower()
88+
		else 
89-
c = peripheral.wrap("right")
89+
			term.setTextColor(colors.red) 
90-
while true do
90+
			print("Invalid Input")
91-
en = c.getEnergyStored("south")
91+
			sleep(1)
92-
sleep(.1)
92+
			redstoneVar()
93
	end
94
	end
95
96
	-- Asks and saves where the modem is located
97-
function lockScreen()
97+
	function modemVars()
98-
m.clear()
98+
			print("Where's the Modem? , [left,right,bottom,top]")
99-
button.clearTable()
99+
			command = read()
100-
m.setTextColor(colors.red)
100+
			if command == "left" or command == "right" or command == "bottom" or command == "top" then
101-
m.setCursorPos(3,9)
101+
				print("Modem set to "..command.." side")
102-
button.centerText("Locked")
102+
				r = fs.open("modemVar", "w")
103-
m.setCursorPos(6,10)
103+
				r.writeLine(tostring(command))
104-
m.write("Unlock with Digitizer")
104+
				r.close()
105-
m.setCursorPos(3,11)
105+
				redstoneVar()
106-
m.write("Given by Owner EliteGaming")
106+
		else
107
			term.setTextColor(colors.red) 
108
			print("Invalid Input")
109
			modemVar()
110-
local function getClick()
110+
	end
111-
        while true do
111+
112-
                local _,_,x,y = os.pullEvent("monitor_touch")
112+
113-
                button.checkxy(x,y)
113+
-- Checks if a file containing where the modem exists, and where the bundled redstone side is, if not
114
-- Then it asks the user where they want it to be and saves it to modemVar and redstoneVar
115
 function startupVars()
116
	if fs.exists("modemVar") == false then
117-
local function rednetReceiver()
117+
		modemVars()
118-
        while true do
118+
	else 
119-
                local senderID, message = rednet.receive()
119+
	-- If they have already been configured than it loads the configs,
120-
                if senderID == 62 then
120+
	-- and Prints the current configs to the screen.
121-
                        if message == "unlock" then
121+
		f = fs.open("modemVar", "r")
122-
                                fillTable()
122+
		sideM = f.readLine()
123
		rednet.open(sideM)
124-
                        elseif message == "lock" then
124+
125-
                                lockScreen()
125+
		f1 = fs.open("redstoneVar", "r")
126
		defaultSide = f1.readLine()
127-
                        elseif message == "oc" then
127+
		f1.close()
128-
                                rednet.send(63, "oc")
128+
		term.setTextColor(colors.cyan)
129-
                        end
129+
		print("Loaded with configuration :")
130
		term.setTextColor(colors.red)
131
		print("Redstone Side : "..defaultSide)
132
		term.setTextColor(colors.gray)
133
		print("Wireless Modem Side : "..sideM)
134-
function refresh()
134+
		term.setTextColor(colors.blue)
135-
button.flash("Refresh")
135+
136-
   button.screen()
136+
end	
137
138
-- Checks if a specific color in bundled cable is on or off / Returns a boolean
139-
fillTable()
139+
function checkColor(color, side)
140-
-- refresh()
140+
	boolean = rs.testBundledInput(side, color)
141-
rednet.open("front")
141+
	--print("CheckColor : "..side.." - Side Color - "..color.." Bool -"..tostring(boolean))
142
return boolean
143-
parallel.waitForAny(getClick, rednetReceiver)
143+
144
145
-- Check's if Kilo's UberMiner is on.
146
function checkCancel()	
147
	bool = checkColor(autoModeCheckColor, defaultSide)
148
	bool2 = checkColor(autoModeColor, defaultSide)
149
	if bool == true and bool2 == false then
150
	autoMode()
151
end
152
end
153
154
addColor(autoModeColor, defaultSide)
155
startupClear()
156
startupVars()
157
158
-- Checks if a rednet message was received.
159
function rednetReceive()
160
senderID, message = rednet.receive()
161
   if senderID == pocketID1  or senderID == pocketID2 then
162
163
       if message == "wither" then
164
       		redstonePulse(witherColor, defaultSide)
165
166
       else if message == "autoMode" then
167
		autoMode()
168
169
       else if message == "forward" then
170
      		redstonePulse(forwardColor, defaultSide)  
171
	
172
       else if message == "forceshut" then
173
		rs.setBundledOutput(defaultSide, 0)
174
		os.reboot()
175
		
176
end
177
end
178
end
179
end
180
end
181
end
182
183
while true do 
184
rednetReceive()
185
end