Advertisement
MagmaLP

Fontania-Regel_Tafeln Grün (startup)

Sep 18th, 2020
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.80 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 = 7
  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, "green", "black")
  128. setButton("PageUp", "-->", pageUp, (w-7), (h-3), 7, 3, "green", "black")
  129. setButton("PageDown", "<--", pageDown, (w-15), (h-3), 7, 3, "green", "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.green)
  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] = "Leistungen der Stadt" --heading_string[language][page]
  251. heading_string[1][2] = "Stadtstrom (Teil 1)"
  252. heading_string[1][3] = "Stadtstrom (Teil 2)"
  253. heading_string[1][4] = "Kostenlose Maschinen"
  254. heading_string[1][5] = "Sehenswürdigkeiten"
  255. heading_string[1][6] = "Sonstiges"
  256. heading_string[1][7] = "Drucker"
  257.  
  258. --English
  259. heading_string[2][1] = "Advantages of Fontania" --heading_string[language][page]
  260. heading_string[2][2] = "City current (Part 1)"
  261. heading_string[2][3] = "City current (Part 2)"
  262. heading_string[2][4] = "Free machines"
  263. heading_string[2][5] = "Sights"
  264. heading_string[2][6] = "Other"
  265. heading_string[2][7] = "Prnter"
  266.  
  267. --Lines
  268. text = {}
  269. for d = 1, languages_amount do
  270. text[d] = {}
  271. for e = 1, pages_amount do
  272. text[d][e] = {}
  273. end
  274. end
  275. --Deutsch
  276. text[1][1][1] = "Diese Tafel gibt Dir einen Überblick und weitere"
  277. text[1][1][2] = "Informationen zu allen Leistungen der Stadt die"
  278. text[1][1][3] = "Du nutzen kannst, wenn du der Stadt beitrittst!"
  279.  
  280. text[1][2][1] = "Jedes Grundstück hat im Preis enthalten einen Strom-"
  281. text[1][2][2] = "Anschluss, genannt Stadtstrom, welcher durch ein "
  282. text[1][2][3] = "HV-Solar-Array an einer MFSU versorgt wird. Daher "
  283. text[1][2][4] = "ist zu beachten:"
  284. text[1][2][5] = "-> Der ausgegebene Strom hat HV-Stärke! Die meisten"
  285. text[1][2][6] = " Maschinen explodieren ohne entsprechende Trans-"
  286. text[1][2][7] = " formatoren, welche wir aber bereitstellen und "
  287. text[1][2][8] = " benutzt werden dürfen."
  288. text[1][2][9] = "-> Für durch fehlerhafte Anwendung des HV-Stroms "
  289. text[1][2][10] = " zerstörte Maschinen übernehmen wir keine Haftung!"
  290.  
  291. text[1][3][1] = "-> Der Anschluss ist keine unendliche Stromquelle!"
  292. text[1][3][2] = " Wenn Du mehr Strom aus der MFSU ziehst als das"
  293. text[1][3][3] = " HV-Solar nachliefert hast du über Nacht KEINEN"
  294. text[1][3][4] = " Strom! Dies ist insbesondere der Fall wenn ein"
  295. text[1][3][5] = " Mass Fabricator direkt durch Stadtstrom betrieben"
  296. text[1][3][6] = " wird."
  297. text[1][3][7] = "-> BatBox sowie Transformatoren dürfen auch verlegt,"
  298. text[1][3][8] = " abgebaut oder behalten werden - sie sind im Preis "
  299. text[1][3][9] = " inklusive."
  300. text[1][3][10] = "-> Dies gilt NICHT für das HV Solar und die MFSU!!"
  301.  
  302. text[1][4][1] = "Am Stadtspawn finden sich allerlei Maschinen und"
  303. text[1][4][2] = "Apparate, welche durch Stadtbewohner nutzbar sind."
  304. text[1][4][3] = "Dazu zählen:"
  305. text[1][4][4] = "-> Electric Furnace, Macerator, Extractor und"
  306. text[1][4][5] = " Compressor"
  307. text[1][4][6] = "-> Pulverizer, Induction Smelter, Magma Crucible"
  308. text[1][4][7] = " und Liquid Transposer"
  309. text[1][4][8] = "-> Assembly Table mit 36 Lasern"
  310. text[1][4][9] = "-> Enchanting Table mit Anvils"
  311. text[1][4][10] = "-> Der schnellste Universal Charger auf dem Server"
  312.  
  313. text[1][5][1] = "-> Stadtteil Ocean - für das Grundstück mit See-Blick!"
  314. text[1][5][2] = " Auch befindet sich hier der Stadt-Tauschshop."
  315. text[1][5][3] = " "
  316. text[1][5][4] = "-> U-Bahn-System verbindet Fontania, Ocean und Babulmia"
  317. text[1][5][5] = " "
  318. text[1][5][6] = "-> Stausee, Hobbit-Höhle, Gartenverein - von Usern"
  319. text[1][5][7] = " errichtete Sehenswürdigkeiten"
  320. text[1][5][8] = " "
  321. text[1][5][9] = "-> Stammi-Haus - Mustergültiges Grundstück zum"
  322. text[1][5][10] = " Selbstvergleich vor der eigenen Stammi-Bewerbung"
  323.  
  324. text[1][6][1] = "-> Für jeden nutzbare XP-Farm links am Stadtspawn"
  325. text[1][6][2] = " "
  326. text[1][6][3] = "-> Jeder neue Spieler erhält nach einmaliger Anfrage ein"
  327. text[1][6][4] = " gratis Jetpack!"
  328. text[1][6][5] = " "
  329. text[1][6][6] = "-> Auf Grundstücken im Schnee-Biom fällt kein Schnee!"
  330. text[1][6][7] = " "
  331. text[1][6][8] = "-> Wir haben einen eigenen TeamSpeak-Channel auf dem"
  332. text[1][6][9] = " Lycodon-TeamSpeak-Server (server.lycodon.com)"
  333. text[1][6][10] = " "
  334. text[1][6][11] = "-> Alle Erlöse aus MagmaLP's Shop gehen an die Stadt"
  335.  
  336. text[1][7][1] = "Wenn Du zu fau.. ähhm beschäftigt bist alle Regeln"
  337. text[1][7][2] = "durchzulesen hast Du hier die Möglichkeit eine"
  338. text[1][7][3] = "Kurzfassung der Stadtregeln kostenlos auszudrucken"
  339. text[1][7][4] = "und mitzunehmen!"
  340. text[1][7][5] = " "
  341. text[1][7][6] = " [Demnächst verfügbar!]"
  342.  
  343.  
  344. --English
  345. text[2][1][1] = "This screen shows you everything our city has to"
  346. text[2][1][2] = "offer. All of the following things are usable for"
  347. text[2][1][3] = "free if you are a member of Fontania!"
  348.  
  349. text[2][2][1] = "Every plot has a High Voltage current, called 'City"
  350. text[2][2][2] = "current', which can be used by all people living on "
  351. text[2][2][3] = "this plot. Its powered by an HV Solar connected to"
  352. text[2][2][4] = "a MFSU, therefore keep in mind:"
  353. text[2][2][5] = "-> The current has a strength of 512eu/t, so most"
  354. text[2][2][6] = " machines will explode without the usage of trans-"
  355. text[2][2][7] = " formers. However, we provide fitting transformers"
  356. text[2][2][8] = " to be used by the plot owners."
  357. text[2][2][9] = "-> We don't provide replacements for things destroyed"
  358. text[2][2][10] = " due to wrong usage of the city current!"
  359.  
  360. text[2][3][1] = "-> The city current is not an infinite power source."
  361. text[2][3][2] = " If you suck more power out of the MFSU than the"
  362. text[2][3][3] = " Solar Array can produce you won't have power at"
  363. text[2][3][4] = " night time! This will happen especially if you power"
  364. text[2][3][5] = " a Mass Fabricator off the city current, which is"
  365. text[2][3][6] = " why we highly recommend against it."
  366. text[2][3][7] = "-> You can move, break or keep the BatBox as well as"
  367. text[2][3][8] = " the transformers, because they are fully included"
  368. text[2][3][9] = " in the plot's price."
  369. text[2][3][10] = "-> This does NOT apply to the HV Solar or the MFSU!!"
  370.  
  371. text[2][4][1] = "Located at the city spawn you can find a lot of"
  372. text[2][4][2] = "useful machines, to be used by members of the city."
  373. text[2][4][3] = "These are:"
  374. text[2][4][4] = "-> Electric Furnace, Macerator, Extractor and"
  375. text[2][4][5] = " Compressor"
  376. text[2][4][6] = "-> Pulverizer, Induction Smelter, Magma Crucible"
  377. text[2][4][7] = " and Liquid Transposer"
  378. text[2][4][8] = "-> Assembly Table powered by 36 Lasers"
  379. text[2][4][9] = "-> Enchanting Table with Anvils"
  380. text[2][4][10] = "-> The fastest Universal Charger on the server"
  381.  
  382. text[2][5][1] = "-> Outpost Ocean - for a plot with a view on the"
  383. text[2][5][2] = " ocean! You also find the exchange shop here."
  384. text[2][5][3] = " "
  385. text[2][5][4] = "-> Underground railway system to connect city parts"
  386. text[2][5][5] = " "
  387. text[2][5][6] = "-> Stausee, Hobbit-Höhle, Gartenverein - build by"
  388. text[2][5][7] = " city members!"
  389. text[2][5][8] = " "
  390. text[2][5][9] = "-> 'Stammi'-House - this is a demo plot to compare"
  391. text[2][5][10] = " with your own plot before applying for Stammi."
  392.  
  393. text[2][6][1] = "-> XP-Farm at the spawn is usable for everyone."
  394. text[2][6][2] = " "
  395. text[2][6][3] = "-> Every new member gets a free Jetpack once, but"
  396. text[2][6][4] = " you may ask us for that."
  397. text[2][6][5] = " "
  398. text[2][6][6] = "-> No annoying snowfall on Tundra biome plots!"
  399. text[2][6][7] = " "
  400. text[2][6][8] = "-> We do have an own TeamSpeak-Channel on the server"
  401. text[2][6][9] = " provided by Lycodon (server.lycodon.com)!"
  402. text[2][6][10] = " "
  403. text[2][6][11] = "-> All revenue of MagmaLP's Shop will help the city"
  404.  
  405. text[2][7][1] = "If you were to laz... ehhm busy to read all of the"
  406. text[2][7][2] = "rules you have the chance to print them here instead"
  407. text[2][7][3] = "for free! They are a lot shorter and you can take them"
  408. text[2][7][4] = "anywhere you want!"
  409. text[2][7][5] = " "
  410. text[2][7][6] = " [Available very soon!]"
  411.  
  412.  
  413. --Highlights
  414. highlight = {}
  415. --setHighlight(id, sprache, seite, "text", xpos, ypos, "backcolor", "textcolor")
  416. --Deutsch
  417. setHighlight(1, 1, 2, "Stadtstrom", 22, 5, "black", "green")
  418.  
  419. setHighlight(2, 1, 4, "durch Stadtbewohner nutzbar", 20, 5, "black", "green")
  420.  
  421. setHighlight(3, 1, 5, "Stadtteil Ocean", 6, 4, "black", "green")
  422.  
  423. setHighlight(4, 1, 6, "gratis Jetpack", 6, 7, "black", "green")
  424. setHighlight(5, 1, 6, "TeamSpeak-Channel", 30, 11, "black", "green")
  425.  
  426. setHighlight(6, 1, 7, "kostenlos auszudrucken", 31, 6, "black", "green")
  427.  
  428.  
  429. --English
  430. setHighlight(7, 2, 2, "'City", 49, 4, "black", "green")
  431. setHighlight(8, 2, 2, "current'", 3, 5, "black", "green")
  432.  
  433. setHighlight(9, 2, 4, "used by members of the city", 26, 5, "black", "green")
  434.  
  435. setHighlight(10, 2, 5, "Outpost Ocean", 6, 4, "black", "green")
  436.  
  437. setHighlight(11, 2, 6, "free Jetpack", 30, 6, "black", "green")
  438. setHighlight(12, 2, 6, "TeamSpeak-Channel", 24, 11, "black", "green")
  439.  
  440. setHighlight(13, 2, 7, "for free", 3, 6, "black", "green")
  441.  
  442.  
  443. end
  444.  
  445. function setHighlight(id, sprache, seite, text, xpos, ypos, backColor, textColor)
  446. highlight[id] = {}
  447. highlight[id]["lang"] = sprache
  448. highlight[id]["page"] = seite
  449. highlight[id]["text"] = text
  450. highlight[id]["x"] = xpos
  451. highlight[id]["y"] = ypos
  452. highlight[id]["backColor"] = backColor
  453. highlight[id]["textColor"] = textColor
  454. end
  455.  
  456. textZuweisen()
  457. screen()
  458. while true do
  459. main()
  460. end
  461.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement