Advertisement
Guest User

test

a guest
Apr 4th, 2020
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. buttons={}
  2.  
  3. function makeNewButton(name,text,type,IX,IY,FX,FY)
  4.  local z={IX=IX,IY=IY,FX=FX*2,FY=FY,text=text,state=false}
  5.  buttons[name]=z
  6. end
  7.  
  8. function renderButton(button,color,monitor_name)
  9.  if color=="green" then
  10.   color=32
  11.  elseif color=="white" then
  12.   color=1
  13.  elseif color=="red" then
  14.   color=16384
  15.  end
  16.  if monitor_name~=nil then
  17.   term.redirect(monitor_name)
  18.  end
  19.  local b = buttons[button]
  20.  for x=b["IX"],b["FX"] do
  21.   for y=b["IY"],b["FY"] do
  22.    paintutils.drawPixel(x,y,color)
  23.   end
  24.  end
  25.  term.setCursorPos((b["FX"]/2)-#b["text"]/2,b["FY"]/2)
  26.  term.setTextColor(colors.black)
  27.  term.write(b["text"])
  28.  term.setCursorPos(1,1)
  29.  term.restore()
  30. end
  31.  
  32. function isButtonColliding(button,target_x,target_y)
  33.  local b = buttons[button]
  34.  colx = (target_x>=b["IX"] and target_x<=b["FX"])
  35.  coly = (target_y>=b["IY"] and target_y<=b["FY"])
  36.  return (colx and coly)
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement