Advertisement
john9912

Frame.b Framedrawing WIP

Feb 24th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.21 KB | None | 0 0
  1. local t = {}
  2. local c = {}
  3. local b = {}
  4. setting = {}
  5. setting.useColor = true
  6. setting.format = "normal" --"normal" = xxyy  "large"  = xxxyyy
  7. setting.useGetSize = true
  8. setting.MaxX = 51
  9. setting.MaxY = 19
  10. local function tT(x,y)
  11.    if setting.format == "large" then
  12.       if x < 10 then
  13.          local a = "00"..x
  14.       elseif x < 100 then
  15.          local a = "0"..x
  16.       else
  17.          local a = x
  18.       end
  19.       if y < 10 then
  20.          a = a.."00"..y
  21.       elseif y < 100 then
  22.          a = a.."0"..y
  23.       else
  24.          a = a..y
  25.       end
  26.    elseif setting.format == "normal" then
  27.       if x < 10 then
  28.          local a =  "0"..x
  29.       else
  30.          local a = x
  31.       end
  32.       if y < 10 then
  33.          a = a.."0"..y
  34.       else
  35.          a = a..y
  36.       end
  37.    else
  38.       error("incorrect format")
  39.    end
  40.    return a
  41. end
  42. function sett(x,y,char)
  43.    t[tT(x,y)] = char
  44. end
  45. function setc(x,y,color)
  46.    c[tT(x,y)] = color
  47. end
  48. function setb(x,y,color)
  49.    b[tT(x,y)] = color
  50. end
  51. function gett(x,y)
  52.    return t[tT(x,y)]
  53. end
  54. function getc(x,y)
  55.    return c[tT(x,y)]
  56. end
  57. function getb(x,y)
  58.    return b[tT(x,y)]
  59. end
  60. function init()
  61.    if setting.useGetSize == true then
  62.       MaxX, MaxY = term.getSize()
  63.    end
  64.    local Y = 1
  65.    while Y < MaxY do
  66.       local X = 1
  67.       while X < MaxX do
  68.          sett(X,Y," ")
  69.          setc(X,Y,"0")
  70.          setb(X,Y,"f")
  71.          X = X + 1
  72.       end
  73.       Y = Y + 1
  74.    end
  75.    return true
  76. end
  77. function setText(x,y,text)
  78.    if y > 0 and y < MaxY+1 and x > 0 and x < MaxX+1 and string.len(text) + x < MaxX+1 then
  79.       local a = string.len(text)
  80.       while not a == 0 do
  81.          sett(x,y,text:sub(string.len(text)-a+1)
  82.          a = a - 1
  83.          x = x + 1
  84.       end
  85.    end
  86. end
  87. function setBkg(color)
  88.    local y = 1
  89.    while y < MaxY + 1 do
  90.       local x = 1
  91.       while x < MaxX + 1 do
  92.          setb(x,y,color)
  93.          x = x + 1
  94.       end
  95.       y = y + 1
  96.    end
  97. end
  98. function setCol(color)
  99.    local y = 1
  100.    while y < MaxY + 1 do
  101.       local x = 1
  102.       while x < MaxX + 1 do
  103.          setc(x,y,color)
  104.          x = x + 1
  105.       end
  106.       y = y + 1
  107.    end
  108. end
  109. function export(x,y)
  110.    local a = tT(x,y)
  111.    return t[a]..c[a]..b[a]
  112. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement