Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.setBackgroundColor(colors.black)
- term.clear()
- local boxlocation = {2, 2}
- local clickX, clickY = nil, nil
- while true do
- term.setCursorPos(1, 1)
- term.write("click & drag")
- paintutils.drawFilledBox(boxlocation[1], boxlocation[2], boxlocation[1] + 4, boxlocation[2] + 2, colors.gray)
- local events = {os.pullEvent()}
- term.setBackgroundColor(colors.black)
- term.clear()
- if events[1] == "mouse_click" and events[2] == 1 then
- clickX, clickY = events[3], events[4]
- end
- if events[1] == "mouse_drag" and events[2] == 1 and clickX and clickY and clickX >= boxlocation[1] - 1 and clickX <= boxlocation[1] + 5 and clickY >= boxlocation[2] - 1 and clickY <= boxlocation[2] + 2 then
- clickX, clickY = events[3], events[4]
- boxlocation = {clickX, clickY}
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement