Advertisement
fatboychummy

TurtleDigitAPI

May 28th, 2020
1,197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.73 KB | None | 0 0
  1. local font = require("font")
  2. local mod = peripheral.wrap("back")
  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.   for i = 1, #word do
  29.     send(i, string.sub(word, i, i), tpOverride or 2)
  30.   end
  31. end
  32.  
  33. return {
  34.   sendWord = sendWord,
  35.   send = send
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement