Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- buttons={}
- function makeNewButton(name,text,type,IX,IY,FX,FY)
- local z={IX=IX,IY=IY,FX=FX*2,FY=FY,text=text,state=false}
- buttons[name]=z
- end
- function renderButton(button,color,monitor_name)
- if color=="green" then
- color=32
- elseif color=="white" then
- color=1
- elseif color=="red" then
- color=16384
- end
- if monitor_name~=nil then
- term.redirect(monitor_name)
- end
- local b = buttons[button]
- for x=b["IX"],b["FX"] do
- for y=b["IY"],b["FY"] do
- paintutils.drawPixel(x,y,color)
- end
- end
- term.setCursorPos((b["FX"]/2)-#b["text"]/2,b["FY"]/2)
- term.setTextColor(colors.black)
- term.write(b["text"])
- term.setCursorPos(1,1)
- term.restore()
- end
- function isButtonColliding(button,target_x,target_y)
- local b = buttons[button]
- colx = (target_x>=b["IX"] and target_x<=b["FX"])
- coly = (target_y>=b["IY"] and target_y<=b["FY"])
- return (colx and coly)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement