Advertisement
Guest User

Untitled

a guest
Nov 3rd, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.04 KB | None | 0 0
  1. local gpu = require("component").gpu
  2. local unicode = require("unicode")
  3. hres = {}
  4.  
  5. function hres.set(x, y, state)
  6.   local x = math.floor(x)
  7.   local y = math.floor(y)
  8.   local scrx = math.ceil(x/2)
  9.   local scry = math.ceil(y/4)
  10.   local maxx, maxy = gpu.getResolution()
  11.   if scrx > maxx or scry > maxy or scrx < 1 or scry < 1 then return end
  12.   local prechar = gpu.get(scrx, scry)
  13.   _, prechar = utf8.codes(prechar)(prechar)
  14.   local offset = 0x2800
  15.   local offsetx = (x-((math.floor(x/2))*2))
  16.   if offsetx == 0 then offsetx = 2 end
  17.   local offsety = y-(math.floor(y/4)*4)
  18.   if offsetx == 1 then
  19.     if offsety == 0 then
  20.       brs = 7
  21.     else
  22.       brs = offsety
  23.     end
  24.   else
  25.     if offsety == 0 then
  26.       brs = 8
  27.     else
  28.       brs = offsety+3
  29.     end
  30.   end
  31.  
  32.   local offsetdec = 2^(brs-1)
  33.  
  34.   if prechar < offset or prechar > 0x28FF then
  35.     prechar = offset
  36.   end
  37.  
  38.   if state then
  39.       gpu.set(scrx, scry, unicode.char(prechar+offsetdec))
  40.   else
  41.       gpu.set(scrx, scry, unicode.char(prechar-offsetdec))
  42.   end
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement