SHOW:
|
|
- or go back to the newest paste.
1 | os.pullEvent = coroutine.yield | |
2 | os.setComputerLabel("Information board") | |
3 | mon = peripheral.find("monitor") | |
4 | mX, mY = mon.getSize() | |
5 | activeScreen = 1 | |
6 | buttonTime = 0.2 | |
7 | ||
8 | listColor = colors.green | |
9 | listItemColor = colors.lightGray | |
10 | headerColor = colors.yellow | |
11 | subHeaderColor = colors.orange | |
12 | ||
13 | function monPrint(txt) | |
14 | local this = term.current() | |
15 | term.redirect(mon) | |
16 | print(txt) | |
17 | term.redirect(this) | |
18 | end | |
19 | ||
20 | function writeRequirement(req_,val_) | |
21 | mon.setTextColor(listColor) | |
22 | local thisX, thisY = mon.getCursorPos() | |
23 | mon.write("- "..req_..":") | |
24 | mon.setCursorPos(20,thisY) | |
25 | mon.setTextColor(listItemColor) | |
26 | monPrint(val_) | |
27 | end | |
28 | ||
29 | function drawActiveScreen() | |
30 | if screens[activeScreen] then | |
31 | mon.setBackgroundColor(colors.black) | |
32 | mon.setTextColor(headerColor) | |
33 | - | mon.setTextColor(colors.yellow) |
33 | + | mon.setCursorPos(1,1) |
34 | setlabel(screens[activeScreen]()) | |
35 | else | |
36 | print("something went wrong!") | |
37 | activeScreen = 1 | |
38 | - | return " Information" |
38 | + | |
39 | end | |
40 | ||
41 | function setlabel(text) | |
42 | mon.setBackgroundColor(colors.gray) | |
43 | mon.setTextColor(colors.white) | |
44 | - | mon.setTextColor(colors.yellow) |
44 | + | |
45 | mon.setCursorPos(1,mY-i-3) | |
46 | mon.write(" ") | |
47 | end | |
48 | - | monPrint("These ranks blablabla information blabla sigh I gotta sleep") |
48 | + | |
49 | end | |
50 | ||
51 | function screen1() | |
52 | mon.write("Main information:") | |
53 | mon.setCursorPos(1,3) | |
54 | mon.setTextColor(colors.white) | |
55 | monPrint("You can rightclick the buttons below to switch tabs to see more info on ranks, paths and their differences.") | |
56 | monPrint("\nEvery item in the store can be aquired by using reward points, these are obtained by voting or donating.") | |
57 | monPrint("\nThere are four paths, you will gradually rank up inside the path chosen, starting with rank type 1.") | |
58 | return "Information" | |
59 | - | mon.setCursorPos(math.ceil(mX/2)-(len/2),line) |
59 | + | |
60 | ||
61 | function screen2() | |
62 | mon.write("Rank type 1 information:") | |
63 | mon.setTextColor(colors.white) | |
64 | - | local text = "unset" |
64 | + | |
65 | monPrint("This rank requires no playtime and is granted when joining a path.") | |
66 | mon.setTextColor(subHeaderColor) | |
67 | monPrint() | |
68 | monPrint("Commands / Permissions:") | |
69 | mon.setTextColor(listColor) | |
70 | monPrint("- All default commands") | |
71 | return "Rank type 1" | |
72 | end | |
73 | ||
74 | function screen3() | |
75 | mon.write("Rank type 2 information: ") | |
76 | mon.setCursorPos(1,3) | |
77 | mon.setTextColor(colors.white) | |
78 | monPrint("To achieve this rank you must meet all requirements, ranking up doesnt cost anything, you just need to have the status.") | |
79 | mon.setTextColor(subHeaderColor) | |
80 | monPrint("\nRequirements:") | |
81 | mon.setTextColor(listColor) | |
82 | writeRequirement("Total playtime","1 day") | |
83 | writeRequirement("Money","500$") | |
84 | writeRequirement("Exp","5 levels") | |
85 | mon.setTextColor(subHeaderColor) | |
86 | monPrint("\nAdded permission:") | |
87 | mon.setTextColor(listColor) | |
88 | monPrint("- Bank access") | |
89 | return "Rank type 2" | |
90 | end | |
91 | ||
92 | ||
93 | function screen4() | |
94 | monPrint("Rank type 3 information:") | |
95 | mon.setTextColor(colors.white) | |
96 | monPrint("\nTo rank up, or check your status use: /ar check.") | |
97 | - | drawButton("prev") |
97 | + | mon.setTextColor(subHeaderColor) |
98 | - | drawButton("next") |
98 | + | monPrint("\nRequirements:") |
99 | writeRequirement("Total playtime","2 days") | |
100 | - | event = {os.pullEvent("monitor_touch")} |
100 | + | writeRequirement("Money","2.000$") |
101 | writeRequirement("Exp","10 levels") | |
102 | - | --print(textutils.serialize(event)) |
102 | + | mon.setTextColor(subHeaderColor) |
103 | - | if event[4] >= mY-3 then |
103 | + | monPrint("\nAdded command:") |
104 | - | if event[3] < centerP then |
104 | + | mon.setTextColor(listColor) |
105 | - | activeScreen = activeScreen - 1 |
105 | + | monPrint("- /hat") |
106 | - | if activeScreen == 0 then |
106 | + | return "Rank type 3" |
107 | - | activeScreen = #screens |
107 | + | |
108 | - | end |
108 | + | |
109 | - | elseif event[3] > centerP then |
109 | + | function screen5() |
110 | - | activeScreen = activeScreen + 1 |
110 | + | monPrint("Rank type 4 information:") |
111 | - | if activeScreen > #screens then |
111 | + | |
112 | - | activeScreen = 1 |
112 | + | monPrint("\nStaff isn't allowed to loan money to players in order for them to rank up, ask someone who trusts you and isn't staff instead.") |
113 | - | end |
113 | + | mon.setTextColor(subHeaderColor) |
114 | monPrint("\nRequirements:") | |
115 | writeRequirement("Total playtime","5 days") | |
116 | - | --print(activeScreen) |
116 | + | writeRequirement("Money","5.000") |
117 | writeRequirement("Exp","25 levels") | |
118 | mon.setTextColor(subHeaderColor) | |
119 | - | screens = {screen1,screen2,screen3} |
119 | + | monPrint("\nAdded command:") |
120 | mon.setTextColor(listColor) | |
121 | monPrint("- /back") | |
122 | return "Rank type 4" | |
123 | end | |
124 | ||
125 | function screen6() | |
126 | mon.setCursorPos(1,1) | |
127 | mon.setTextColor(headerColor) | |
128 | monPrint("Rank type 5 information:") | |
129 | mon.setTextColor(colors.white) | |
130 | monPrint("\nVote points are aquired by voting or donating, Check back on the donation shop regularly to spend these points!") | |
131 | mon.setTextColor(subHeaderColor) | |
132 | monPrint("\nRequirements:") | |
133 | writeRequirement("Total playtime","10 days") | |
134 | writeRequirement("Money","10.000") | |
135 | writeRequirement("Exp","40 levels") | |
136 | mon.setTextColor(subHeaderColor) | |
137 | monPrint("\nAdded permission:") | |
138 | mon.setTextColor(listColor) | |
139 | monPrint("- /back on death.\n (Might be replaced)") | |
140 | return "Rank type 5" | |
141 | end | |
142 | ||
143 | function cWrite(text,line) | |
144 | local len = string.len(text) | |
145 | mon.setCursorPos(math.ceil(mX/2)-math.floor(len/2),line) | |
146 | mon.write(text) | |
147 | end | |
148 | ||
149 | function drawButton(mode,active) | |
150 | local text | |
151 | if active == true then | |
152 | mon.setBackgroundColor(colors.white) | |
153 | else | |
154 | mon.setBackgroundColor(colors.lightGray) | |
155 | end | |
156 | mon.setTextColor(colors.black) | |
157 | if mode == "prev" then | |
158 | xStart = 1 | |
159 | text = "Back" | |
160 | else | |
161 | xStart = (mX-1)/2 + 2 | |
162 | text = "Next" | |
163 | end | |
164 | bgText = "" | |
165 | repeat | |
166 | bgText = bgText.." " | |
167 | until string.len(bgText) >= math.floor(mX/2) | |
168 | for i=1,3 do | |
169 | mon.setCursorPos(xStart,mY-(i-1)) | |
170 | mon.write(bgText) | |
171 | end | |
172 | if mode == "prev" then | |
173 | mon.setCursorPos(xStart+5,mY-1) | |
174 | else | |
175 | mon.setCursorPos(xStart+5,mY-1) | |
176 | end | |
177 | mon.write(text) | |
178 | end | |
179 | ||
180 | buttonNext = false | |
181 | buttonPrev = false | |
182 | function main() | |
183 | mon.setBackgroundColor(colors.black) | |
184 | mon.clear() | |
185 | drawActiveScreen() | |
186 | drawButton("prev",buttonPrev) | |
187 | drawButton("next",buttonNext) | |
188 | if restore ~= true then | |
189 | sleep(buttonTime) | |
190 | else | |
191 | mon.setTextColor(colors.gray) | |
192 | mon.setBackgroundColor(colors.black) | |
193 | cWrite("Board set to resting state.",mY-3) | |
194 | end | |
195 | buttonPrev = false | |
196 | buttonNext = false | |
197 | drawButton("prev",buttonPrev) | |
198 | drawButton("next",buttonNext) | |
199 | timeOutTimer = os.startTimer(120) | |
200 | restore = false | |
201 | event = {os.pullEvent()} | |
202 | centerP = mX / 2 | |
203 | if event[1] == "monitor_touch" then | |
204 | if event[4] >= mY-3 then | |
205 | if event[3] < centerP then | |
206 | activeScreen = activeScreen - 1 | |
207 | if activeScreen == 0 then | |
208 | activeScreen = #screens | |
209 | end | |
210 | buttonPrev = true | |
211 | elseif event[3] > centerP then | |
212 | activeScreen = activeScreen + 1 | |
213 | if activeScreen > #screens then | |
214 | activeScreen = 1 | |
215 | end | |
216 | buttonNext = true | |
217 | end | |
218 | end | |
219 | os.cancelTimer(timeOutTimer) | |
220 | elseif event[1] == "timer" and event[2] == timeOutTimer and activeScreen ~= 1 then | |
221 | activeScreen = 1 | |
222 | restore = true | |
223 | end | |
224 | end | |
225 | ||
226 | screens = {screen1,screen2,screen3,screen4,screen5,screen6} | |
227 | while true do | |
228 | main() | |
229 | end |