Messing with the mouse

Make games! Discuss those games here.

Moderators: Bob the Hamster, marionline, SDHawk

Post Reply
User avatar
Master K
King Slime
Posts: 1899
Joined: Sat Jun 11, 2011 9:40 pm
Location: A windswept rock in the Atlantic Ocean

Messing with the mouse

Post by Master K »

So, I have been working on a little game that is testing out the mouse. I was wondering if you could script it so that when you click on an NPC, something would happen, like you could show a text box, move them with the mouse as long as the left button is held down, or when they get clicked on, they move to a new tile. Is any of this possible?
User avatar
Spoonweaver
Liquid Metal King Slime
Posts: 6247
Joined: Mon Dec 08, 2008 7:07 am
Location: Home
Contact:

Post by Spoonweaver »

Yes, all of that is possible.
Have you seen my game [game]Slimes![/game]? It has a lot of mouse control in it. It might be good to give it a go just to get an understanding of what is possible with the mouse on the ohr.
User avatar
Master K
King Slime
Posts: 1899
Joined: Sat Jun 11, 2011 9:40 pm
Location: A windswept rock in the Atlantic Ocean

Post by Master K »

I already played Slimes, spoon. Thanks for reminding me though, because now I know it is possible. But, how can the things I said above be scripted?
TMC
Metal King Slime
Posts: 4101
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Use the "NPC at pixel" command. If your mouse cursor is a slice rather than an NPC, it's even easier, because it won't return the cursor NPC. For example.

Code: Select all

if (mouse click (left button)) then (
  variable (npc ref)
  npc ref := npc at pixel(mouse pixel x, mouse pixel y)
  if (npc ref) then (
    # something!
  )
)
Post Reply