Click.lua
Jump to navigation
Jump to search
A small library for the cursor. You can find its coordinates in the scene, find the speed's cursor, or set an image cursor.
Installation
Place the file click.lua into the LuaScriptsLib folder.
How to Use
To enable the click.lua, add this line to lunadll.lua:
local click = API.load("click");
This will load the API.
Example
local click = API.load("click")
click.setCursor("example.png")
function onTick()
Text.print(click.cursorTimer("off"),click.x()-32,click.y()-32)
if click.click() then
click.setCursorOn()
click.setCursorOff(15)
NPC.spawn(1,click.sceneX(),click.sceneY(),player.section)
end
end
This example will:
1) Spawn a goomba where the cursor is placed when the mouse is clicked. 2) Show the cursor for 15 frames when the mouse is clicked. 3) Have the timer near the cursor showing how long until the cursor disappears.
Documentation
| click() | |||||
|---|---|---|---|---|---|
| Returns true for the first frame the mouse was clicked. | |||||
| hold() | |||||
| Returns true if the mouse is being clicked. | |||||
| released() | |||||
| Returns true for the first frame the mouse was released. | |||||
| x() | |||||
| Returns the X-coordinate relative to the screen. | |||||
| y() | |||||
| Returns the Y-coordinate relative to the screen. | |||||
| sceneX() | |||||
| Returns the X-coordinate relative to the scene. | |||||
| sceneY() | |||||
| Returns the Y-coordinate relative to the scene. | |||||
| speedX() | |||||
| Returns the X-speed of the cursor. NOTE: Doesn't work on 'onTickEnd()'. | |||||
| speedY() | |||||
| Returns the Y-speed of the cursor. NOTE: Doesn't work on 'onTickEnd()'. | |||||
| setCursor() | Image Path | Priority | X offset | Y Offset | |
| Sets the cursor with an image. Note: This doesn't turn on the image, it simply loads it. | Required, string
Provide a file path to the image |
Optional, number.
Provide the priority for the cursor. Default: 5 |
Optional, number.
Provide an X-offset for the image. Default: 0 |
Optional, number.
Provide a Y-offset for the image. Default: 0 | |
| setCursorOn() | Time | ||||
| Turns on the image for the cursor. | Optional, number
A delay for when the image should be turned on. Default: 0 | ||||
| setCursorOff() | Time | ||||
| Turns off the image for the cursor. | Optional, number
A delay for when the image should be turned off. Default: 0 | ||||
| cursorTimer() | Type | ||||
| Returns the timer until the cursor image is turned on/off | Required, string
Have either "on", or "off". | ||||
| isCursor() | |||||
| Returns true if the cursor is being displayed |