Mouse clicks in LUA

Mouse clicks in LUA

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
SecurE
Posts: 87
Joined: 29 Apr 2005, 23:49

Mouse clicks in LUA

Post by SecurE »

I'm attempting to create a crude tutorial through a gadget, but to do that I would like to both make use of synced controls, such as CreateUnit and TransferUnit while also being able to display dialog boxes that would only disappear after being clicked on. I've stumbled upon a problem however, as I don't know how to do the dialogs; how do I catch mouse clicks through a gadget?
I've tried looking through the wiki, but if the information is there then I've missed it.
user
Posts: 452
Joined: 22 Jan 2008, 16:33

Re: Mouse clicks in LUA

Post by user »

synced can write anything, but should be limited to synced reading.
unsynced can read anything, but should be limited to unsynced writing.

use send to unsynced function, and receive from synced functions, to communicate between unsynced and synced, to draw the box, i will explain later.
user
Posts: 452
Joined: 22 Jan 2008, 16:33

Re: Mouse clicks in LUA

Post by user »

to make the box make an xyz point 2d array like this:

box = {}
box[1] = {0,0,0}
box[2] = {0,0,8}
box[3] = {0,60,6}
box[4] = {0,9000,5637374383}
(just examples)

use the mouse click calls to find out the position, to check if it is in the box, do a bunch of checks with the position.
SecurE
Posts: 87
Joined: 29 Apr 2005, 23:49

Re: Mouse clicks in LUA

Post by SecurE »

I would assume I would have been able to make a box either way, but what I'd need is what function I have to use to actually catch the mouse clicks?
user
Posts: 452
Joined: 22 Jan 2008, 16:33

Re: Mouse clicks in LUA

Post by user »

Code: Select all

local callInLists = {
  'Shutdown',
  'Update',
  'TextCommand',
  'CommandNotify',
  'AddConsoleLine',
  'ViewResize',
  'DrawScreen',
  'KeyPress',
  'KeyRelease',
  'MousePress', <-
  'MouseWheel', <- 
  'IsAbove',
  'GetTooltip',
  'GroupChanged',
  'CommandsChanged',
  'TweakMousePress',
  'TweakMouseWheel',
  'TweakIsAbove',
  'TweakGetTooltip',
SecurE
Posts: 87
Joined: 29 Apr 2005, 23:49

Re: Mouse clicks in LUA

Post by SecurE »

I should have checked a few more things before asking really, but thank you for that, should be all I need.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Mouse clicks in LUA

Post by KDR_11k »

That looks like the widget list, are you sure that works in gadgets?
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Mouse clicks in LUA

Post by jK »

LuaGadgets have no access to the mouse at all (neither pos nor buttons)

period

(tip: use Spring.SendLuaRulesMsg() in a widget)
User avatar
quantum
Posts: 590
Joined: 19 Sep 2006, 22:48

Re: Mouse clicks in LUA

Post by quantum »

I worked on a tutorial for some time. My solution was to make both a gadget and a widget. The gadget sends events to the widget when needed.

Here are my files: http://trac.caspring.org/browser/trunk/mods/ca-tutorial

Don't try to run them though, the tutorial doesn't work in .76.
Post Reply

Return to “Lua Scripts”