Page 1 of 1
Mouse clicks in LUA
Posted: 29 Feb 2008, 00:19
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.
Re: Mouse clicks in LUA
Posted: 29 Feb 2008, 00:26
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.
Re: Mouse clicks in LUA
Posted: 29 Feb 2008, 00:30
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.
Re: Mouse clicks in LUA
Posted: 29 Feb 2008, 00:37
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?
Re: Mouse clicks in LUA
Posted: 29 Feb 2008, 00:47
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',
Re: Mouse clicks in LUA
Posted: 29 Feb 2008, 01:57
by SecurE
I should have checked a few more things before asking really, but thank you for that, should be all I need.
Re: Mouse clicks in LUA
Posted: 29 Feb 2008, 07:52
by KDR_11k
That looks like the widget list, are you sure that works in gadgets?
Re: Mouse clicks in LUA
Posted: 29 Feb 2008, 09:33
by jK
LuaGadgets have no access to the mouse at all (neither pos nor buttons)
period
(tip: use Spring.SendLuaRulesMsg() in a widget)
Re: Mouse clicks in LUA
Posted: 29 Feb 2008, 12:55
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.