Click.lua

Description: Libraries made for LunaLUA.
Moderator: Moderators

Yoshi021 M
Topic author, Moderator
Moderator
Avatar
Yoshi021 M
Topic author, Moderator
Moderator
Age: 17
Reputation: 87
Posts: 644
Joined: 15 Feb 2016
Location: Yoshi's Island

Post #1by Yoshi021 » 4 Jan 2017, 20:14

Hello! Today I present click.lua a library that allows you to use the cursor, and the left mouse button. The API allows you to set a cursor image, check its position from the screen or scene, check if the mouse is clicked/held/released, and identify the mouse in squares. The cursor is a feature that I have never seen in SMBX, and I hope you can take its full advantage! I present to you some examples.

EXAMPLES
Example 1
Image

Code: Select all

local click = API.load("click")
click.setCursor()
Example 2
Image

Code: Select all

local click = API.load("click")
click.setCursor()

function onTick()
  if click.hold then
    click.setCursor("Goomba.png")
    NPC.spawn(1,click.sceneX,click.sceneY,player.section)
  else
    click.setCursor("click/example.png")
  end
end
Example 3
Image

Code: Select all

local click = API.load("click")
click.setCursor("Goomba.png")
click.setCursorOff()

function onTick()
  if click.click() then
    click.setCursorOn()
    click.setCursorOff(15)
    NPC.spawn(1,click.sceneX,click.sceneY,player.section)
  end
end
Example 4
Image

Code: Select all

local click = API.load("click")
click.setCursor()

function onTick()
  for k,v in pairs(NPC.get()) do
    v.speedX = (click.sceneX - v.x)/50
    v.speedY = (click.sceneY - v.y)/50
  end
end
Example 5
Image

Code: Select all

local click = API.load("click")
click.setCursor()
click.setCursorOff()

function onTick()
  Text.print(click.sqrFind("example"),0,0)
  if click.sqr(click.click,0,0,800,32,"example") then
    player.speedY = -5
  end
  if click.click then
    click.setCursorOn()
    click.setCursorOff(15)
  end
end
Example 6
Image

Code: Select all

local click = API.load("click")
click.setCursor()

function onTick()
  if math.abs(click.speedX) > 50 or math.abs(click.speedY) > 50 then
    Defines.earthquake = 5
  end
end


NOTE
In SMBX, for some reason, it has trouble identifying fast double clicks. I am not sure why but this is SMBX's fault. You can test this in the episode select menu, and see the same result.

Documentation: http://wohlsoft.ru/pgewiki/Click.lua

If you see any errors, please tell me as soon as possible so I can fix them.
Links
ImageImageImage
Image
Image
"Going to University is FUN!" :pardon:

Zwertll
Close friend
Close friend
Zwertll
Close friend
Close friend
Reputation: 28
Posts: 82
Joined: 6 Dec 2016

Post #2by Zwertll » 11 Jan 2017, 2:10

I liked. Depending on how you use it on one level can be quite useful since it can do several things. It can be cool for gimmicks and minigames.


Return to “LunaLUA APIs”

Who is online (over the past 5 minutes)

Users browsing this forum: 1 guest