../
kernel
functions
add
all
apply_delta
assert
atan2
btn
btnp
camera
cd
char
chooser
circ
circfill
clip
cls
color
cos
count
cp
create_delta
create_gui
create_process
cursor
date
del
deli
env
error
exit
fetch
fetch_metadata
fget
fillp
foreach
fset
fstat
fullpath
get_clipboard
get_display
get_draw_target
get_spr
include
input
key
keyp
line
ls
map
max
memcpy
memmap
memset
menuitem
mget
mkdir
mouse
mouselock
mset
music
mv
note
on_event
open
oval
ovalfill
peek
peek2
peek4
peek8
peektext
pget
pid
pod
poke
poke2
poke4
poke8
printh
pset
pwd
readtext
rect
rectfill
rm
rrect
rrectfill
scoresub
send_message
set_clipboard
set_draw_target
set_spr
sfx
sin
socket
split
spr
sspr
stat
stop
store
store_metadata
sub
time
tokenoid
type
unmap
unpod
userdata
vec
vid
window
mouse([new_mx,new_my])
Overview
mouse is used to get and set the positioning of the cursor relative to the window.
Source: source.lua
Arguments
new_mx
The new x position of the mouse
new_my
The new y position of the mouse
Returns
mouse_x
x-coordinate of the mouse
mouse_y
y-coordinate of the mouse
mouse_b
a bitfield:
- 0x1 left mouse button
- 0x2 right mouse button
- 0x4 middle mouse button
wheel_x
The amount scrolled on the scrollwheel in the x-axis
wheel_y
The amount scrolled on the scrollwheel in the y-axis
Examples
Get the properties of the mouse & print when you left click or right click.
function _update()
mouse_x, mouse_y, mouse_b, wheel_x, wheel_y = mouse()
if (mouse_b&0x1==0x1) then
print("left click!")
end
if (mouse_b&0x2==0x2) then
print("right click!")
end
end
Limitations
The mouse() function does not allow you to set full properties of the mouse.
This can be fixed using the following snippet to have access to the full mouse properties.
--@astralsparv
function setMouse(x,y,b)
send_message(3,{event="mouse",mx=x,my=y,mb=b or 0})
end