View difference between Paste ID: 0C26f4SW and ssv6zWG9
SHOW: | | - or go back to the newest paste.
1
--Look throughout the code for comments like this. They explain what to do to change things.
2
3
--What side the monitor will be on (change this if needed)
4
side = "right"
5
args = {...}
6
rednet.open("top")
7
message = args[1]
8
9
10
m = peripheral.wrap(side)
11
12
13
--button on/off color
14
bactive = colors.cyan
15
binactive=colors.gray
16
--text on/off color
17
tactive=colors.white
18
tinactive=colors.black
19
--Background color
20
bgcolor = colors.black
21
22
23
buttons = {}
24
      
25
      
26
27
      function newButton(id,xmin,xmax,ymin,ymax,text,func)
28
        buttons[id] = {}
29
        buttons[id]["xmin"] = xmin
30
        buttons[id]["xmax"] = xmax
31
        buttons[id]["ymin"] = ymin
32
        buttons[id]["ymax"] = ymax
33
        buttons[id]["active"] = false
34
        buttons[id]["text"] = text
35
        buttons[id]["func"] = func
36
        
37
      end
38
      ---------------------------------------------------------------------------------
39
      function printButton(id)
40
        ymin = buttons[id]["ymin"]
41
        ymax = buttons[id]["ymax"]
42
        xmin = buttons[id]["xmin"]
43
        xmax = buttons[id]["xmax"]
44
        text = buttons[id]["text"]
45
        ia = buttons[id]["active"]
46
47
       
48
49
            width = xmax - xmin
50
            height = ymax - ymin
51
            
52
            if ia then m.setBackgroundColor(bactive) m.setTextColor(tactive)
53
            else m.setBackgroundColor(binactive) m.setTextColor(tinactive) end
54
55
            for j = ymin,ymax do
56
             m.setCursorPos(xmin,j)
57
              for i = xmin,xmax do
58
59
                m.write(" ")
60
61
             end
62
63
           end 
64
65
         
66
        m.setCursorPos(xmin + width / 2 - #text / 2 + 1,ymin + height / 2)
67
68
       m.write(text)
69
       m.setBackgroundColor(bgcolor)
70
        
71
      end
72
      ----------------------------------------------------------------------------------
73
      function refreshButtons()
74
        for i = 1,#buttons do
75
          printButton(i)
76
        end
77
      end
78
    function checkxy( x,y )
79
        for i = 1, #buttons do 
80
          if y >= buttons[i]["ymin"] and y <= buttons[i]["ymax"] then
81
            if x >= buttons[i]["xmin"] and x <= buttons[i]["xmax"] then
82
83
              
84
              buttons[i]["active"] = not buttons[i]["active"]
85
              clicked = i
86
              if buttons[i]["func"] ~= nil then
87
88
                buttons[i]["func"]()
89
90
                
91
              end
92
            end
93
          end
94
        end
95
      end
96
97
98
bool1 = false
99
bool2 = false
100
bool3 = false
101
bool4 = false
102
rs.setBundledOutput("back",0)
103
104
105
106
107
--White is pigman, Orange is witch, purple is wither skele (Bundled cable)
108
109
110
111
112
113-
function villager()
113+
114
function Elder()
115
  current = rs.getBundledOutput("back")
116
	bool1 = not bool1
117-
	   rednet.broadcast("lon")
117+
118
	   rednet.broadcast("Elderon")
119-
    rednet.broadcast("loff")
119+
120
    rednet.broadcast("Elderoff")
121
  end
122
end
123-
function znkkiller()
123+
124
function witch()
125
  current = rs.getBundledOutput("back")
126
	bool2 = not bool2
127-
   rednet.broadcast("znkkilleron")
127+
128
   rednet.broadcast("znkwitchon")
129-
    rednet.broadcast("znkkilleroff")
129+
130
    rednet.broadcast("znkwitchoff")
131
  end
132
end
133-
function microsoftkiller()
133+
134
function pinkslime()
135
  current = rs.getBundledOutput("back")
136
	bool3 = not bool3
137-
   rednet.broadcast("microsoftkilleron")
137+
138
   rednet.broadcast("pinkslimeon")
139-
    rednet.broadcast("microsoftkilleroff")
139+
140
    rednet.broadcast("pinkslimeoff")
141
  end
142
end
143
144
function ancientknight()
145
  current = rs.getBundledOutput("back")
146
	bool4 = not bool4
147
	if bool4 then
148
   rednet.broadcast("ancienton")
149
  else
150
    rednet.broadcast("ancientoff")
151
  end
152
end
153
154
155
--You can add more buttons and also change the size of them. The format is startingx,startingy,endingx,endingy,text,function
156
157-
newButton(1, 2,24,2,6,"Villager",villager)
157+
158-
newButton(2, 26,48,2,6,"ZNK Killer",znkkiller)
158+
newButton(1, 2,24,2,6,"Elder Guardian",Elder)
159-
newButton(3, 26,48,7,11,"Microsoft Killer",microsoftkiller)
159+
newButton(2, 26,48,2,6,"Witch",witch)
160
newButton(3, 26,48,7,11,"Pink Slime",pinkslime)
161
newButton(4, 2,24,7,11,"Ancient Knight",ancientknight)
162
------------------------------------------------
163
164
165
166
m.clear()
167
refreshButtons()
168
169
170
--main loop
171
while true do
172
	e,side,x,y = os.pullEvent("monitor_touch")
173
	checkxy(x,y)
174
  
175
	refreshButtons()
176
end
177