Hiranus icon

window move

Hiranus | PRO | 10/02/14 09:44:41 AM UTC | 0 ⭐ | 517 👁️ | Never ⏰ | []
Lua |

770 B

|

None

|

0 👍

/

0 👎

local screen = window.create(term.current(),1,1,100,100)
screen.setCursorPos(15,15)
screen.write("haha")
local pp2=0
local pp3=0
local motionX=0
local motionY=0
local event,p1,p2,p3,p4,p5
while true do
    local posX,posY = screen.getPosition()
     event,p1,p2,p3,p4,p5 = os.pullEvent()
    if event=="mouse_click" and p1==2 then
        pp2=p2
        pp3=p3
    elseif event=="mouse_drag" and p1==2 then
        if pp2<p2 then
            motionX=1
            pp2=p2
        elseif pp2>p2 then
            motionX=-1
            pp2=p2
        else
            motionX=0
            pp2=p2
        end
        
        if pp3<p3 then
            motionY=1
            pp3=p3
        elseif pp3>p3 then
            motionY=-1
            pp3=p3
        else
            motionY=0
            pp3=p3
        end
        screen.reposition(posX+motionX,posY+motionY)
    elseif event=="mouse_click" and p1==3 then
        screen.reposition(1,1)
    end
end

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎