Advertisement
jamawie

Werbungsanzeige

Jul 18th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.42 KB | None | 0 0
  1. --Werbungsprogramm gesteuert von einem Zentralrechner
  2. zantralid = 9773
  3. redside = "top"
  4. monside = "back"
  5.  
  6.  
  7. mon = peripheral.wrap(monside)
  8.  
  9.  
  10. function drawGUI()
  11.     mon.clear()
  12.     mon.setCursorPos(1,1)
  13.     mon.setBackgroundColor(colors.white)
  14.     x,y = mon.getSize()
  15.  
  16.     mon.setCursorPos((x-11)/2,1)
  17.     mon.setTextColor(colors.cyan)
  18.     mon.write("Jo")
  19.     mon.setTextColor(colors.orange)
  20.     mon.write("Ja")
  21.     mon.setTextColor(colors.lightGray)
  22.     mon.write(" Productions")
  23. end
  24.  
  25. function drawText(str)
  26.     screenPos = 3
  27.     pos = 1
  28.  
  29.     mon.setTextColor(colors.white)
  30.     abbruch = false
  31.     mon.setCursorPos(1,screenPos)
  32.     while true do
  33.         stelleA = string.find(str,"<",pos)
  34.  
  35.         if stelleA == nil then
  36.             substr = string.sub(str,pos)
  37.         else
  38.             substr = string.sub(str,pos,stelleA-1)
  39.         end
  40.         mon.write(substr)
  41.  
  42.  
  43.         if abbruch==true then
  44.             break
  45.         end
  46.  
  47.  
  48.         stelleE = string.find(str,">",pos)
  49.  
  50.         if stelleE then
  51.             col = string.sub(str,stelleA+1,stelleE-1)
  52.         else
  53.             abbruch = true
  54.         end
  55.  
  56.         if not string.match(col,"[a-zA-Z]+") then
  57.             mon.setTextColor(tonumber(col))
  58.         elseif col == "E" then
  59.             screenPos = screenPos+1
  60.             mon.setCursorPos(1,screenPos)
  61.         end
  62.  
  63.         if stelleE then
  64.             pos = stelleE+1
  65.         end
  66.  
  67.         sleep(0.1)
  68.     end
  69. end
  70.  
  71.  
  72. --mainprogram
  73. rednet.open(redside)
  74. while true do
  75.     a, b = rednet.receive()
  76.     if a==zentralid then
  77.         drawGUI()
  78.         drawText(b)
  79.     end
  80. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement