Advertisement
fatboychummy

TurtleDigitServer.lua

Jan 10th, 2020
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.97 KB | None | 0 0
  1. local font = require("font")
  2. local mod = peripheral.wrap("bottom")
  3.  
  4. local function send(digit, char, tp)
  5.   tp = tp or 2
  6.   if type(char) == "string" then char = string.upper(char) end
  7.   local toSend = font[char]
  8.   if toSend == nil then
  9.     error("Invalid character: " .. tostring(char), 2)
  10.   end
  11.  
  12.   local isIn = {}
  13.   for i = 1, 13 do
  14.     if not toSend[i] then break end
  15.     isIn[toSend[i]] = true
  16.   end
  17.  
  18.   for i = 1, 13 do
  19.     mod.transmit(1, 1, {
  20.         pos = i,
  21.         tp = isIn[i] and tp or 1,
  22.         digit = digit
  23.       })
  24.   end
  25. end
  26.  
  27. local function sendWord(word, tpOverride)
  28.   send(1, string.sub(word, 1, 1), tpOverride or 2)
  29.   send(2, string.sub(word, 2, 2), tpOverride or 2)
  30.   send(3, string.sub(word, 3, 3), tpOverride or 2)
  31. end
  32.  
  33. os.sleep(3)
  34. for i = 1, 3 do
  35.   sendWord("19 ")
  36.   os.sleep(1)
  37.   sendWord(".  ")
  38.   os.sleep(1)
  39.   send(2, '.', 2)
  40.   os.sleep(1)
  41.   send(3, '.', 2)
  42.   os.sleep(1)
  43. end
  44. sendWord("OLD", 3)
  45. os.sleep(1)
  46. sendWord("888", 4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement