MagmaLP

Einzahl-Computer English

Apr 4th, 2021 (edited)
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.80 KB | None | 0 0
  1. os.loadAPI("ocs/apis/sensor")
  2. local s = sensor.wrap("top")
  3. rednet.open("front")
  4. mon = peripheral.wrap("back")      
  5. side = "back"      --Bildschirmseite für Button-Abfrage setzen
  6. mon.setBackgroundColor(32768)
  7. mon.setTextScale(1.5)
  8. mon.clear()
  9.  
  10. --Hilfs-Funktionen--
  11.  
  12. function calc_color(color)
  13.     return math.pow(2, color - 1)
  14. end
  15. function msg(gap, line, color, groundb, text)
  16.     mon.setBackgroundColor(calc_color(groundb))
  17.     mon.setCursorPos(gap,line)
  18.     mon.setTextColor(calc_color(color))
  19.     text = mon.write(text)
  20. end
  21.  
  22. function firstlayer()
  23.     rednet.send(6324, "abfrage")
  24.     rednet.send(6324, name)
  25.     id, coins, z = rednet.receive()
  26.     mon.setBackgroundColor(32768)
  27.     mon.clear()
  28.     msg(01,1,4,16,"Welcome " ..name.. "          ")
  29.     msg(27,1,6,16,"Coins: " ..coins.. "          ")
  30.     msg(01,2,5,16,"------------------------------------------------------------")
  31. end
  32.  
  33. function keinbutton1()
  34.     msg(01,17,01,15,"  There is no button xD                 ")
  35.     sleep(1)
  36.     msg(01,17,16,16,"                                        ")
  37.     msg(33,17,01,15," <back> ")
  38.     msg(01,17,01,15," -> logout <- ")
  39.     deutsch1()
  40. end
  41. function keinbutton2()
  42.     msg(01,17,01,15,"  There is no button xD                 ")
  43.     sleep(1)
  44.     msg(01,17,16,16,"                                        ")
  45.     msg(33,17,01,15," <back> ")
  46.     count1()
  47. end
  48. function keinbutton3()
  49.     msg(01,17,01,15,"  There is no button xD                 ")
  50.     sleep(1)
  51.     msg(01,17,16,16,"                                        ")
  52.     count2()
  53. end
  54.  
  55. function deutsch1()
  56.     firstlayer()
  57.     msg(01,4,10,16,"What do you want to deposit?")
  58.     msg(01,5,10,16,"Just click on the name of the item.")
  59.    
  60.     msg(1,07,01,16,"Amount|       Item        |  Equivalent")
  61.     msg(01,8,01,16,"~~~~~~|~~~~~~~~~~~~~~~~~~~|~~~~~~~~~~~~")
  62.     msg(02,09,01,16," 1x  |  Shard of Minium  |   25 Coins")
  63.     msg(02,10,09,16," 1x  |  Lead Ingot       |   10 Coins")
  64.     msg(02,11,01,16," 1x  |  Lead Ore         |   20 Coins")
  65.     msg(02,12,09,16," 1x  |  Shiny Ingot      |  100 Coins")
  66.     msg(02,13,01,16," 1x  |  Ferrous Ore      |   10 Coins")
  67.     msg(02,14,09,16," 1x  |  Quartz Crystal   |   25 Coins")
  68.     msg(02,15,01,16," 1x  |  Silver Ore       |   12 Coins")
  69.      
  70.     msg(33,17,01,15," <back> ")
  71.     msg(01,17,01,15," -> logout <- ")
  72.  
  73.     local event, side, X, Y = os.pullEvent("monitor_touch")
  74.     if X >= 33 and X <=40 and Y >= 17 and Y <= 18 and side == side then         -- zurück Button
  75.         fs.delete("Player")
  76.         shell.run("startup")
  77.     elseif X >= 1 and X <=40 and Y >= 1 and Y <= 8 and side == side then
  78.         keinbutton1()
  79.     elseif X >= 1 and X <=40 and Y >= 16 and Y <= 16 and side == side then
  80.         keinbutton1()
  81.     elseif X >= 15 and X <=32 and Y >= 17 and Y <= 18 and side == side then
  82.         keinbutton1()
  83.  
  84.     elseif X >= 1 and X <=40 and Y >= 9 and Y <= 9 and side == side then
  85.         item = "Shard of Minium"
  86.         ID = 6311
  87.         itemwert = 25
  88.         count1()
  89.     elseif X >= 1 and X <=40 and Y >= 10 and Y <= 10 and side == side then
  90.         item = "Lead Ingot"
  91.         ID = 6313
  92.         itemwert = 10
  93.         count1()
  94.     elseif X >= 1 and X <=40 and Y >= 11 and Y <= 11 and side == side then
  95.         item = "Lead Ore"
  96.         ID = 6316
  97.         itemwert = 20
  98.         count1()
  99.     elseif X >= 1 and X <=40 and Y >= 12 and Y <= 12 and side == side then
  100.         item = "Shiny Ingot"
  101.         ID = 6317
  102.         itemwert = 100
  103.         count1()
  104.     elseif X >= 1 and X <=40 and Y >= 13 and Y <= 13 and side == side then
  105.         item = "Ferrous Ore"
  106.         ID = 6318
  107.         itemwert = 10
  108.         count1()
  109.     elseif X >= 1 and X <=40 and Y >= 14 and Y <= 14 and side == side then
  110.         item = "Quartz Crystal"
  111.         ID = 6319
  112.         itemwert = 25
  113.         count1()
  114.     elseif X >= 1 and X <=40 and Y >= 15 and Y <= 15 and side == side then
  115.         item = "Silver Ore"
  116.         ID = 6320
  117.         itemwert = 12
  118.         count1()
  119.     elseif X >= 1 and X <=14 and Y >= 17 and Y <= 18 and side == side then          --logout Button
  120.         fs.delete("Player")
  121.         shell.run("startup")                                
  122.     end
  123. end
  124.  
  125. function count1()
  126.     firstlayer()
  127.     msg(33,17,01,15," <back> ")
  128.  
  129.     msg (01,4,10,16,"Please now throw "..item.." into the")
  130.     msg (01,5,10,16,"Input and then click here on OK")
  131.  
  132.     msg (01,7,02,16,"Please only insert a maximum of 16 stacks!")
  133.    
  134.     msg(17,09,16,01,"        ")
  135.     msg(17,10,16,01,"        ")
  136.     msg(17,11,16,01,"   OK   ")
  137.     msg(17,12,16,01,"        ")
  138.     msg(17,13,16,01,"        ")
  139.  
  140.     local event, side, X, Y = os.pullEvent("monitor_touch")
  141.     if X >= 1 and X <=40 and Y >= 1 and Y <= 8 and side == side then
  142.         keinbutton2()
  143.     elseif X >= 01 and X <=40 and Y >= 14 and Y <= 16 and side == side then
  144.         keinbutton2()
  145.     elseif X >= 01 and X <=32 and Y >= 17 and Y <= 18 and side == side then
  146.         keinbutton2()
  147.     elseif X >= 01 and X <=16 and Y >= 09 and Y <= 13 and side == side then
  148.         keinbutton2()
  149.     elseif X >= 25 and X <=40 and Y >= 09 and Y <= 13 and side == side then
  150.         keinbutton2()
  151.  
  152.     elseif X >= 33 and X <=40 and Y >= 17 and Y <= 18 and side == side then     --zurück
  153.         deutsch1()
  154.     elseif X >= 17 and X <=24 and Y >= 9 and Y <= 13 and side == side then  --OK
  155.         count2()
  156.     end
  157. end
  158.  
  159. function count2()
  160.     y = 1
  161.     rednet.send(ID,y)
  162.     x, y, z = rednet.receive()
  163.  
  164.     if y > 0 then
  165.         firstlayer()
  166.         wert = y * itemwert
  167.         msg (01,04,10,16,""..y.." "..item.." were counted.")
  168.         msg (01,05,10,16,"This corresponds to a value of "..wert.."")
  169.         msg(01,06,10,16,"Coins.")
  170.         msg (01,08,10,16,"Would you like to deposit them now?")
  171.  
  172.         msg(8,10,1,6,"           ")     msg(23,10,1,15,"           ")
  173.         msg(8,11,1,6,"    YES    ")     msg(23,11,1,15,"    NO     ")
  174.         msg(8,12,1,6,"           ")     msg(23,12,1,15,"           ")
  175.  
  176.         local event, side, X, Y = os.pullEvent("monitor_touch")
  177.         if X >= 01 and X <=40 and Y >= 01 and Y <= 09 and side == side then
  178.             keinbutton3()
  179.         elseif X >= 01 and X <=07 and Y >= 10 and Y <= 12 and side == side then
  180.             keinbutton3()
  181.         elseif X >= 19 and X <=22 and Y >= 10 and Y <= 12 and side == side then
  182.             keinbutton3()
  183.         elseif X >= 33 and X <=40 and Y >= 10 and Y <= 12 and side == side then
  184.             keinbutton3()
  185.         elseif X >= 01 and X <=40 and Y >= 13 and Y <= 18 and side == side then
  186.             keinbutton3()
  187.  
  188.  
  189.         elseif X >= 08 and X <=18 and Y >= 10 and Y <= 12 and side == side then         -- Klick JA
  190.             rednet.send(6324, "einzahlen")
  191.             sleep(0.5)
  192.             rednet.send(6324, name)
  193.             sleep(0.5)
  194.             rednet.send(6324, wert)
  195.             id, coins, z = rednet.receive()
  196.                
  197.             y = 1000000                                         --Shards an mich
  198.             rednet.send(ID,y)
  199.  
  200.             msg(01,1,4,16,"Welcome " ..name.. "          ")
  201.             msg(27,1,6,16,"Coins: " ..coins.. "          ")
  202.  
  203.             msg (01,14,10,16,""..wert.." Coins where deposited.")
  204.             sleep(3)
  205.             deutsch1()
  206.  
  207.         elseif X >= 23 and X <=33 and Y >= 09 and Y <= 11 and side == side then --Klick NEIN
  208.             y = 0
  209.             rednet.send(ID,y)
  210.             msg(01,14,10,16,"--> Item return")
  211.             sleep(3)
  212.             deutsch1()  
  213.         end
  214.  
  215.     elseif y == 0 then
  216.         firstlayer()    
  217.         msg(01,07,15,16,"No "..item.." where found.")                       --keine shards drin
  218.         sleep(3)
  219.         count1()    
  220.     end
  221. end
  222.  
  223.  
  224. ------------- Programm START -------------
  225.  
  226. file = fs.open("Player", "r")
  227. name = file.readLine()
  228. file.close()
  229.  
  230. deutsch1()
Add Comment
Please, Sign In to add comment