View difference between Paste ID: BUDyRH0T and J1ErE7pj
SHOW: | | - or go back to the newest paste.
1-
defaultSide = "left"
1+
os.unloadAPI("button")
2
sleep(1)
3-
pocketID = 36
3+
os.loadAPI("button")
4-
pocketID2 = 60
4+
local m = peripheral.wrap("top")
5
defaultSide = "back"
6
autoModeBool = false
7
8
-- BundledCable Color Declarations
9
local witherColor = colors.black
10-
local autoModeCheckColor = colors.brown
10+
11-
local autoModeCheckColor2 = colors.magenta
11+
12
local autoModeColor2 = colors.cyan
13
local power = colors.purple
14
15
-- Fixes some API changes
16
function colors.subtract(r, ...)
17
        for n, c in ipairs({ ... }) do
18
                r = bit.band(r, bit.bnot(c)%2^31)
19
        end
20
        return r
21
end
22
23
-- Pulses a bundled redstone color
24
function redstonePulse(color, side)
25
addColor(color, side)
26
sleep(.5)
27
delColor(color, side)
28
end
29
30
-- Turns on a color of a bundled cable
31
function addColor(color , side)
32
 rs.setBundledOutput(side, colors.combine(rs.getBundledOutput(side) + color))
33
end
34
35
-- Turns a color off of a bundled cable
36
function delColor(color, side)
37
   rs.setBundledOutput(side, colors.subtract(redstone.getBundledOutput(side), color)) 
38
end
39
40
-- Turns on the UberMiner AutoMode
41-
	bool2 = checkColor(autoModeCheckColor, defaultSide)
41+
42-
	
42+
43-
	-- If Kilo's server is running the AutoMode this will cancel it from running again.
43+
44-
	if bool2 then
44+
45
	 if bool then
46-
		print("Already Running Somewhere else, remaining off @ nearest Server")
46+
		addColor(power, defaultSide)
47-
		rednet.send(pocketID, "running")
47+
48-
		rednet.send(pocketID2, "running")
48+
		term.setTextColor(colors.lime)
49
		print("AutoMode now Online!")
50
51-
	else if bool then
51+
52
	else
53
		delColor(power, defaultSide)
54-
		addColor(autoModeCheckColor2, defaultSide)
54+
55-
		rednet.send(pocketID, true)
55+
56-
		rednet.send(pocketID2, true)
56+
		print("AutoMode now Offline!")		
57
	end
58
	button.toggleButton("AutoMode ON/OFF")
59
end
60
61-
		delColor(autoModeCheckColor2, defaultSide)
61+
62-
		print("AutoMode now Offline!")
62+
63-
		rednet.send(pocketID, false)
63+
64-
		rednet.send(pocketID2, false)
64+
                f.write("shell.run('pastebin run BUDyRH0T')")
65-
	
65+
66-
			
66+
67
68
	--Asks and saves where the bundled cable is locatated
69
	function redstoneVar()
70
		print("Where will the redstone output be? [left,right,bottom,top]")
71
		command = read()
72
		if command == "left" or command == "right" or command == "bottom" or command == "top" then
73
			print("Redstone set to "..command.." side")
74-
                f.write("shell.run('pastebin run J1ErE7pj')")
74+
75
			f.writeLine(command)
76
			f.close()
77
			os.reboot()
78
		else 
79
			term.setTextColor(colors.red) 
80
			print("Invalid Input")
81
			sleep(1)
82
			redstoneVar()
83
	end
84
	end
85
86
87
-- Checks if a file containing where the modem exists, and where the bundled redstone side is, if not
88
-- Then it asks the user where they want it to be and saves it to modemVar and redstoneVar
89
 function startupVars()
90
	if fs.exists("redstoneVar") == false then
91
		redstoneVar()
92
	else 
93
	-- If they have already been configured than it loads the configs,
94
	-- and Prints the current configs to the screen.
95
96-
	-- Asks and saves where the modem is located
96+
97-
	function modemVars()
97+
98-
			print("Where's the Modem? , [left,right,bottom,top]")
98+
99-
			command = read()
99+
100-
			if command == "left" or command == "right" or command == "bottom" or command == "top" then
100+
101-
				print("Modem set to "..command.." side")
101+
102-
				r = fs.open("modemVar", "w")
102+
103-
				r.writeLine(tostring(command))
103+
104-
				r.close()
104+
105-
				redstoneVar()
105+
106-
		else
106+
107
-- Checks if a specific color in bundled cable is on or off / Returns a boolean
108
function checkColor(color, side)
109-
			modemVar()
109+
110
	--print("CheckColor : "..side.." - Side Color - "..color.." Bool -"..tostring(boolean))
111
return boolean
112
end
113
114
function wither()
115
button.flash("WitherSpawn")
116-
	if fs.exists("modemVar") == false then
116+
redstonePulse(witherColor, defaultSide)
117-
		modemVars()
117+
118
119
function forward()
120
redstonePulse(forwardColor, defaultSide)
121-
		f = fs.open("modemVar", "r")
121+
button.flash("Forward")
122-
		sideM = f.readLine()
122+
123-
		rednet.open(sideM)
123+
124
function updateNumbers(number, total)
125
	if checkColor(autoModeColor2, defaultSide) then
126
		term.setTextColor(colors.lime)
127
		print("Iteration : "..number.."/"..total)
128
	end
129
end
130
131
132
function manMode()
133-
		print("Wireless Modem Side : "..sideM)
133+
button.flash("Manual Iterations")
134-
		term.setTextColor(colors.blue)
134+
term.setTextColor(colors.cyan)
135
print("How many iterations would you like?")
136
term.setTextColor(colors.blue)
137
138
command = read()
139
autoMode()
140
i = 0
141
while i <= tonumber(command) do 
142
	event , p1, p2, p3 = os.pullEvent()
143
	if event == "redstone" then
144
		updateNumbers(i, command)
145-
-- Check's if Kilo's UberMiner is on.
145+
		if i == 0 then
146-
function checkCancel()	
146+
		i = i + 1 else
147-
	bool = checkColor(autoModeCheckColor, defaultSide)
147+
		i = i + 0.5
148-
	bool2 = checkColor(autoModeColor, defaultSide)
148+
		fillMenu()
149-
	if bool == true and bool2 == false then
149+
		m.setCursorPos(0,19)
150-
	autoMode()
150+
		button.centerText("Iterations : "..i.."/"..command)
151
		end		
152
	else if event == "monitor_touch" then
153
		button.checkxy(p2,p3)
154
end
155
end
156
end
157
autoMode()
158-
-- Checks if a rednet message was received.
158+
fillMenu()
159-
function rednetReceive()
159+
160-
senderID, message = rednet.receive()
160+
161-
   if senderID == pocketID1  or senderID == pocketID2 then
161+
function newTouchMenu()
162
m.clear()
163-
       if message == "wither" then
163+
button.clearTable()
164-
       		redstonePulse(witherColor, defaultSide)
164+
m.setBackgroundColor(colors.black)
165
m.setTextColor(colors.white)
166-
       else if message == "autoMode" then
166+
167-
		autoMode()
167+
 
168
   
169-
       else if message == "forward" then
169+
function fillMenu()
170-
      		redstonePulse(forwardColor, defaultSide)  
170+
   newTouchMenu()
171-
	
171+
        button.clearTable()
172-
       else if message == "forceshut" then
172+
        button.setTable("AutoMode ON/OFF", autoMode, 2,28 ,3,5)
173-
		rs.setBundledOutput(defaultSide, 0)
173+
        button.setTable("Manual Iterations", manMode, 2,28, 7,9)
174-
		os.reboot()
174+
	button.setTable("Forward", forward, 2,28, 11,13)
175-
		
175+
        button.setTable("WitherSpawn", wither, 2,28, 15,17)
176
    print("Main Menu Filled")
177
    button.screen()
178
    if checkColor(autoModeColor, defaultSide) then
179
    button.toggleButton("AutoMode ON/OFF")
180
    end
181
    end
182
183
addColor(autoModeColor, defaultSide)
184-
rednetReceive()
184+
185
startupVars()
186
fillMenu()
187
188
local function getClick()
189
        while true do
190
                local _,_,x,y = os.pullEvent("monitor_touch")
191
                button.checkxy(x,y)
192
        end
193
end
194
195
196
while true do 
197
getClick()
198
end