Advertisement
MagmaLP

Fontania-Regel_Tafeln Rot (startup)

Sep 18th, 2020 (edited)
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.52 KB | None | 0 0
  1. local monitor = peripheral.wrap("back")
  2. local main_text_scale = 1
  3. local main_back_color = colors.black
  4. local main_text_color = colors.lightGray
  5. local w, h = monitor.getSize()
  6. monitor.clear()
  7. local button = {}
  8. local language = 1
  9. local page = 1
  10. local languages_amount = 2
  11. local pages_amount = 6
  12.  
  13. function setupScreen()
  14. monitor.setTextScale(main_text_scale)
  15. monitor.setBackgroundColor(main_back_color)
  16. monitor.setTextColor(main_text_color)
  17. end
  18.  
  19. --button-api start
  20.  
  21. function convertColor(color)
  22. if color == "white" then
  23. return 1
  24. end
  25. if color == "lightgray" then
  26. return 256
  27. end
  28. if color == "gray" then
  29. return 128
  30. end
  31. if color == "black" then
  32. return 32768
  33. end
  34. if color == "brown" then
  35. return 4096
  36. end
  37. if color == "red" then
  38. return 16384
  39. end
  40. if color == "orange" then
  41. return 2
  42. end
  43. if color == "yellow" then
  44. return 16
  45. end
  46. if color == "lime" then
  47. return 32
  48. end
  49. if color == "green" then
  50. return 8192
  51. end
  52. if color == "blue" then
  53. return 2048
  54. end
  55. if color == "cyan" then
  56. return 512
  57. end
  58. if color == "lightblue" then
  59. return 8
  60. end
  61. if color == "purple" then
  62. return 1024
  63. end
  64. if color == "magenta" then
  65. return 4
  66. end
  67. if color == "pink" then
  68. return 64
  69. end
  70. end
  71.  
  72. function setButton(name, caption, func, xpos, ypos, width, height, backColor, textColor)
  73. button[name] = {}
  74. button[name]["func"] = func
  75. button[name]["caption"] = caption
  76. button[name]["x"] = xpos
  77. button[name]["y"] = ypos
  78. button[name]["width"] = width
  79. button[name]["height"] = height
  80. button[name]["backColor"] = backColor
  81. button[name]["textColor"] = textColor
  82. button[name]["visible"] = false
  83. end
  84.  
  85. function drawButton(title)
  86. for name, data in pairs(button) do
  87. if name == title then
  88. data["visible"] = true
  89. monitor.setBackgroundColor(convertColor(data["backColor"]))
  90. monitor.setTextColor(convertColor(data["textColor"]))
  91. local xspot = data["x"] + math.floor((data["width"] - string.len(data["caption"])) / 2 ) + 1
  92. local yspot = data["y"] + math.floor(data["height"] / 2) + 1
  93. for i = 1, data["height"] do
  94. for j = 1, data["width"] do
  95. monitor.setCursorPos(data["x"] + j, data["y"] + i)
  96. monitor.write(" ")
  97. end
  98. end
  99. monitor.setCursorPos(xspot, yspot)
  100. monitor.write(data["caption"])
  101. end
  102. end
  103. end
  104.  
  105. function buttonHit(x, y)
  106. for name, data in pairs(button) do
  107. if data["visible"] == true then
  108. if math.floor(y) >= data["y"] + 1 and y <= data["y"] + data["height"] then
  109. if math.floor(x) >= data["x"] + 1 and x <= data["x"] + data["width"] then
  110. data["func"]()
  111. screen()
  112. return true
  113. end
  114. end
  115. end
  116. end
  117. end
  118.  
  119.  
  120. --button-api ende
  121.  
  122.  
  123. --alle button-fkt start
  124.  
  125. function assignButtons()
  126. local caption = language_button_caption[language]
  127. setButton("Language", caption, nextLanguage, 0, (h-3), 12, 3, "red", "black")
  128. setButton("PageUp", "-->", pageUp, (w-7), (h-3), 7, 3, "red", "black")
  129. setButton("PageDown", "<--", pageDown, (w-15), (h-3), 7, 3, "red", "black")
  130. end
  131.  
  132. function nextLanguage()
  133. language = language + 1
  134. if language == (languages_amount + 1) then
  135. language = 1
  136. end
  137. end
  138.  
  139. function pageUp()
  140. page = page + 1
  141. if page == (pages_amount + 1) then
  142. page = 1
  143. end
  144. end
  145.  
  146. function pageDown()
  147. page = page - 1
  148. if page == 0 then
  149. page = pages_amount
  150. end
  151. end
  152.  
  153. function zeilenAnzahl()
  154. local b = 1
  155. while text[language][page][b] ~= nil do
  156. b = b + 1
  157. end
  158. return b-1
  159. end
  160.  
  161. --alle Button-Fkt ende
  162.  
  163.  
  164. --alle Screen-Fkt start
  165.  
  166. function drawButtons()
  167. assignButtons()
  168. drawButton("Language")
  169. drawButton("PageUp")
  170. drawButton("PageDown")
  171. end
  172.  
  173. function drawHeading()
  174. local heading = heading_string[language][page]
  175. local string_length = string.len(heading)
  176. setupScreen()
  177. monitor.setTextColor(colors.red)
  178. monitor.setCursorPos((w - string_length) / 2 + 1, 2)
  179. monitor.write(heading)
  180. end
  181.  
  182. function drawLines()
  183. setupScreen()
  184. for c = 1, zeilenAnzahl() do
  185. monitor.setCursorPos(3 , c + 3)
  186. monitor.write(text[language][page][c])
  187. end
  188. end
  189.  
  190. function drawHighlights()
  191. for name, data in pairs(highlight) do
  192. if data["lang"] == language then
  193. if data["page"] == page then
  194. monitor.setBackgroundColor(convertColor(data["backColor"]))
  195. monitor.setTextColor(convertColor(data["textColor"]))
  196. local xspot = data["x"]
  197. local yspot = data["y"]
  198.  
  199. monitor.setCursorPos(xspot, yspot)
  200. monitor.write(data["text"])
  201. end
  202. end
  203. end
  204. end
  205.  
  206. function drawPageNumber()
  207. setupScreen()
  208. monitor.setCursorPos(w-2,1)
  209. monitor.write(string.gsub(page, ".0", ""))
  210. monitor.write("/")
  211. monitor.write(string.gsub(pages_amount, ".0", ""))
  212. end
  213.  
  214. function screen()
  215. setupScreen()
  216. monitor.clear()
  217.  
  218. drawButtons()
  219.  
  220. drawHeading()
  221.  
  222. drawLines()
  223.  
  224. drawHighlights()
  225.  
  226. drawPageNumber()
  227. end
  228.  
  229. --alle Screen-Fkt ende
  230.  
  231. function main()
  232. local event, button, x, y = os.pullEvent( "monitor_touch" )
  233. --if event == "mouse_click" then
  234. buttonHit(x, y)
  235. --end
  236. end
  237.  
  238. function textZuweisen()
  239. --Change Language - Button
  240. language_button_caption = {}
  241. language_button_caption[1] = "English"
  242. language_button_caption[2] = "Deutsch"
  243.  
  244. --Headings
  245. heading_string = {}
  246. for a = 1, languages_amount do
  247. heading_string[a] = {}
  248. end
  249. --Deutsch
  250. heading_string[1][1] = "Stadtregeln" --heading_string[language][page]
  251. heading_string[1][2] = "Grundstücksbezogene Regeln (Teil 1)"
  252. heading_string[1][3] = "Grundstücksbezogene Regeln (Teil 2)"
  253. heading_string[1][4] = "Grundstücksbezogene Regeln (Teil 3)"
  254. heading_string[1][5] = "Verbotene bzw. eingeschränkte Maschinen (Teil 1)"
  255. heading_string[1][6] = "Verbotene bzw. eingeschränkte Maschinen (Teil 2)"
  256.  
  257. --English
  258. heading_string[2][1] = "City rules" --heading_string[language][page]
  259. heading_string[2][2] = "Rules for plots (Part 1)"
  260. heading_string[2][3] = "Rules for plots (Part 2)"
  261. heading_string[2][4] = "Rules for plots (Part 3)"
  262. heading_string[2][5] = "Banned or restricted devices (Part 1)"
  263. heading_string[2][6] = "Banned or restricted devices (Part 2)"
  264.  
  265.  
  266. --Lines
  267. text = {}
  268. for d = 1, languages_amount do
  269. text[d] = {}
  270. for e = 1, pages_amount do
  271. text[d][e] = {}
  272. end
  273. end
  274. --Deutsch
  275. text[1][1][1] = "Hier findest Du alle Regeln die Du beachten solltest wenn"
  276. text[1][1][2] = "Du Stadtmitglied bist oder ein Grundstück besitzt. Bitte"
  277. text[1][1][3] = "vollständig lesen, Unwissenheit schützt vor Strafe nicht!"
  278. text[1][1][4] = " "
  279. text[1][1][5] = "Die Serverregeln gelten hier insbesondere!"
  280.  
  281. text[1][2][1] = "-> KEIN Weiterverkauf oder -mietung von Grundstücken!"
  282. text[1][2][2] = " "
  283. text[1][2][3] = "-> Unvollständig geclaimte Grundstücke werden komplett"
  284. text[1][2][4] = " gelöscht und es gibt keinen Schadensersatz!"
  285. text[1][2][5] = " "
  286. text[1][2][6] = "-> Maximal 1 Grundstück pro Spieler"
  287. text[1][2][7] = " "
  288. text[1][2][8] = "-> Die Glasdecke der Schnee-Grundstücke darf nicht"
  289. text[1][2][9] = " abgebaut oder verändert werden."
  290.  
  291. text[1][3][1] = "-> Die maximale Bauhöhe beträgt y=100. Ausnahmen gelten"
  292. text[1][3][2] = " für die Wald-Grundstücke auf dem Plateau. Da diese"
  293. text[1][3][3] = " höher liegen darf auch etwas (10 Blöcke) höher gebaut"
  294. text[1][3][4] = " werden wenn das finale Bauwerk:"
  295. text[1][3][5] = " A) nicht überflüssig hoch / unfunktional ist und"
  296. text[1][3][6] = " B) nicht nicht gut aussieht"
  297. text[1][3][7] = " "
  298. text[1][3][8] = "-> Nach einem Perm-Ban wird ein GS entfernt, auch falls"
  299. text[1][3][9] = " dieser rückgängig gemacht werden sollte."
  300.  
  301. text[1][4][1] = "-> Quickie-Häuser, auch bekannt als '10-Minuten-Häuser'"
  302. text[1][4][2] = " sind ungerne gesehen und werden nach missachteten"
  303. text[1][4][3] = " Hinweisen vom Stadtteam abgerissen."
  304. text[1][4][4] = " "
  305. text[1][4][5] = "-> Auch das allseits beliebte 'Ich pflanze nur Rubber "
  306. text[1][4][6] = " Trees'-Grundstück ist zu meiden, versucht schnellst-"
  307. text[1][4][7] = " möglich ein akzeptables Haus zu bauen."
  308. text[1][4][8] = " "
  309. text[1][4][9] = "-> Leerstehende Grundstücke können nach Hinweis von der"
  310. text[1][4][10] = " Stadt zurückgekauft werden."
  311.  
  312. text[1][5][1] = "-> Alarme (Howler & Industrial Alarm) sind ausnahmslos "
  313. text[1][5][2] = " verboten!"
  314. text[1][5][3] = " "
  315. text[1][5][4] = "-> Dauerhafte Geräuschquellen (Noteblocks, Jukebox,"
  316. text[1][5][5] = " Maschinen mit zu wenig Strom) sind zu vermeiden!"
  317. text[1][5][6] = " "
  318. text[1][5][7] = "-> Harvester sind so zu verwenden dass die die "
  319. text[1][5][8] = " Bepflanzung der Stadtwege nicht abbauen - wir raten"
  320. text[1][5][9] = " zu unterirdischen Baumfarmen!"
  321.  
  322. text[1][6][1] = "-> Reaktoren sind nur erlaubt wenn:"
  323. text[1][6][2] = " - von ihnen keine Gefahr ausgeht wenn der Besitzer "
  324. text[1][6][3] = " offline ist"
  325. text[1][6][4] = " - sie unterirdisch und in mindestens 1 Schicht von"
  326. text[1][6][5] = " Reinforced Stone eingebaut sind"
  327. text[1][6][6] = " - sie stabil ihre Temperatur halten"
  328. text[1][6][7] = " - keine Effekte in ihrer Umgebung verursachen (Fire,"
  329. text[1][6][8] = " Evaporation, Poison etc.)"
  330.  
  331.  
  332. --English
  333. text[2][1][1] = "Here you will find all the rules to obey if you are a"
  334. text[2][1][2] = "member of the city or own a plot. Please read all of"
  335. text[2][1][3] = "them, because 'ignorance is no excuse in law'!"
  336. text[2][1][4] = " "
  337. text[2][1][5] = "The server rules apply especially here!"
  338.  
  339. text[2][2][1] = "-> NO reselling or rental of plots!"
  340. text[2][2][2] = " "
  341. text[2][2][3] = "-> Plots which aren't claimed fully will be deleted, and"
  342. text[2][2][4] = " there will be no compensation or payback!"
  343. text[2][2][5] = " "
  344. text[2][2][6] = "-> At most 1 plot (2x2) per player is allowed."
  345. text[2][2][7] = " "
  346. text[2][2][8] = "-> Don't change or break the glass roof on top of the"
  347. text[2][2][9] = " Taiga plots."
  348.  
  349. text[2][3][1] = "-> You must not build any higher than y=100. Exceptions"
  350. text[2][3][2] = " are made for the forest plots on the plateau, because"
  351. text[2][3][3] = " their entrance is located higher. There you may build"
  352. text[2][3][4] = " up to 10 blocks higher if your building:"
  353. text[2][3][5] = " A) isn't unnecessarily high / not functional and"
  354. text[2][3][6] = " B) doesn't look hideous"
  355. text[2][3][7] = " "
  356. text[2][3][8] = "-> A plot gets deleted if the owner receives a permanent"
  357. text[2][3][9] = " ban, even if it gets reversed."
  358.  
  359. text[2][4][1] = "-> Quick-Houses aka 'Dirt Blocks' etc. are not desired"
  360. text[2][4][2] = " and will be demolished after several allusions by"
  361. text[2][4][3] = " members of the city staff."
  362. text[2][4][4] = " "
  363. text[2][4][5] = "-> Also don't just plant some rubber trees and leave"
  364. text[2][4][6] = " (like most users do). Please try to set up a fine"
  365. text[2][4][7] = " building as soon as possible."
  366. text[2][4][8] = " "
  367. text[2][4][9] = "-> Plots which remain empty after obtaining can be bought"
  368. text[2][4][10] = " back by the town."
  369.  
  370. text[2][5][1] = "-> Any alarms (Howler & Industrial Alarm) are completely"
  371. text[2][5][2] = " forbidden!"
  372. text[2][5][3] = " "
  373. text[2][5][4] = "-> Continuous noise sources (Noteblocks, Jukebox,"
  374. text[2][5][5] = " Maschines with not enough power) are also undesirable!"
  375. text[2][5][6] = " "
  376. text[2][5][7] = "-> Harvesters have to be used in a way not to interfere"
  377. text[2][5][8] = " with other plots or the trees on the paths. We"
  378. text[2][5][9] = " recommend to build tree farms below ground!"
  379.  
  380. text[2][6][1] = "-> Nuclear Reactors are only allowed if:"
  381. text[2][6][2] = " - there is zero damage potential if their owner is"
  382. text[2][6][3] = " not online."
  383. text[2][6][4] = " - they were build below ground inside at least 1 layer"
  384. text[2][6][5] = " of Reinforced Stone."
  385. text[2][6][6] = " - they are able to remain a constant temperature."
  386. text[2][6][7] = " - there are no negative effects to other players (Fire,"
  387. text[2][6][8] = " Evaporation, Poison etc.) by e.g. a breeder reactor."
  388.  
  389.  
  390. --Highlights
  391. highlight = {}
  392. --setHighlight(id, sprache, seite, "text", xpos, ypos, "backcolor", "textcolor")
  393. --Deutsch
  394. setHighlight(1, 1, 1, "Die Serverregeln gelten hier insbesondere!", 3, 8, "black", "red")
  395.  
  396. setHighlight(2, 1, 2, "Kein Weiterverkauf", 6, 4, "black", "red")
  397. setHighlight(3, 1, 2, "1", 14, 9, "black", "red")
  398.  
  399. setHighlight(4, 1, 3, "y=100", 35, 4, "black", "red")
  400.  
  401. setHighlight(5, 1, 5, "Alarme", 6, 4, "black", "red")
  402.  
  403. setHighlight(6, 1, 6, "nur erlaubt", 21, 4, "black", "red")
  404.  
  405. --English
  406. setHighlight(7, 2, 1, "The server rules apply especially here!", 3, 8, "black", "red")
  407.  
  408. setHighlight(8, 2, 2, "NO reselling", 6, 4, "black", "red")
  409. setHighlight(9, 2, 2, "1", 14, 9, "black", "red")
  410.  
  411. setHighlight(10, 2, 3, "y=100", 41, 4, "black", "red")
  412.  
  413. setHighlight(11, 2, 5, "Any alarms", 6, 4, "black", "red")
  414.  
  415. setHighlight(12, 2, 6, "only allowed", 27, 4, "black", "red")
  416.  
  417. end
  418.  
  419. function setHighlight(id, sprache, seite, text, xpos, ypos, backColor, textColor)
  420. highlight[id] = {}
  421. highlight[id]["lang"] = sprache
  422. highlight[id]["page"] = seite
  423. highlight[id]["text"] = text
  424. highlight[id]["x"] = xpos
  425. highlight[id]["y"] = ypos
  426. highlight[id]["backColor"] = backColor
  427. highlight[id]["textColor"] = textColor
  428. end
  429.  
  430. textZuweisen()
  431. screen()
  432. while true do
  433. main()
  434. end
  435.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement