Click.lua

This is the place for discussion and support for LunaLua and related modifications and libraries.

Moderator: Userbase Moderators

Forum rules
Before you make a topic/post, consider the following:
-Is there a topic for this already?
-Is your post on topic/appropriate?
-Are you posting in the right forum/following the forum rules?
Yoshi021
Gold Yoshi Egg
Gold Yoshi Egg
Posts: 691
Joined: Thu Jan 21, 2016 9:06 pm
Flair: :)
Pronouns: He/Him

Click.lua

Postby Yoshi021 » Wed Jan 04, 2017 12:13 pm

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.
Example 1: show
Image

Code: Select all

local click = API.load("click")
click.cursorLoad({{}})
click.cursorSet()
Example 2: show
Image

Code: Select all

local click = API.load("click")
click.cursorLoad({
  {Graphics.loadImage("goomba.png")},
  {}
})

function onTick()
  if click.hold then
    click.cursorSet(1)
    NPC.spawn(1,click.sceneX,click.sceneY,player.section)
  else
    click.cursorSet(2)
  end
end
Example 3: show
Image

Code: Select all

local click = API.load("click")
click.cursorLoad()
click.cursorSet(1)

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 4: show
Image

Code: Select all

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

function onTick()
  Text.print(click.findNameVal("example"),0,0)
  if click.box{bool=click.click,x=0,y=0,width=800,height=32,name="example"} then
    player.speedY = -5
  end
  if click.click then
    click.cursorSet(1)
  elseif click.released then
    click.cursorSet(0)
  end

end
Example 5: show
Image

Code: Select all

local click = API.load("click")
click.cursorLoad()
click.cursorSet(1)

function onTick()
  if math.abs(click.speedX) > 50 or math.abs(click.speedY) > 50 then
    Defines.earthquake = 5
  end
end
NOTE: show
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.
Last edited by Yoshi021 on Sat May 20, 2017 11:02 am, edited 2 times in total.

ivanmegafanboy
Flurry
Flurry
Posts: 175
Joined: Wed Aug 12, 2015 11:47 am

Re: Click.lua

Postby ivanmegafanboy » Wed Jan 04, 2017 6:47 pm

Holy thwomp, that is so cool. Like for puzzle levels or "editor-PGE" themed levels.

kr4k1n
Reznor
Reznor
Posts: 2927
Joined: Sun Dec 11, 2016 8:02 pm
Flair: cats are cool
Pronouns: he/him/his
Contact:

Re: Click.lua

Postby kr4k1n » Sat Jan 07, 2017 5:53 pm

So, technically you can now use the mouse as one of the controls for a game. I've never seen the mouse before until now, and it looks like it's one Mario's hands, that's cool!

Yoshi021
Gold Yoshi Egg
Gold Yoshi Egg
Posts: 691
Joined: Thu Jan 21, 2016 9:06 pm
Flair: :)
Pronouns: He/Him

Re: Click.lua

Postby Yoshi021 » Sun Jan 08, 2017 12:54 am

practicalshorty014 wrote:So, technically you can now use the mouse as one of the controls for a game. I've never seen the mouse before until now, and it looks like it's one Mario's hands, that's cool!
You can set the image to the cursor you want, but there is a default image. Use setCursor() for that.

Yoshi021
Gold Yoshi Egg
Gold Yoshi Egg
Posts: 691
Joined: Thu Jan 21, 2016 9:06 pm
Flair: :)
Pronouns: He/Him

Re: Click.lua

Postby Yoshi021 » Fri May 19, 2017 10:01 am

Click v1.1 has been released. There is a new system to set the image cursor that now allows animated images, and a new box{}, and circle{} functions that make using the cursor easier. The download is in the documentation.

ElectriKong
Bowser
Bowser
Posts: 4653
Joined: Mon Jun 06, 2016 4:32 pm
Pronouns: he/him
Contact:

Re: Click.lua

Postby ElectriKong » Sat May 20, 2017 2:27 am

Is there a way this could be used to pick up specific items? Then we could make episodes like SMG where the cursor could pick up starbits.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 2 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari