Implementing a feature selection

Implementing a feature selection

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

Moderator: Moderators

Post Reply
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Implementing a feature selection

Post by gajop »

Roughly a year ago I implemented a tool that could select not only units, but also features (and other non-engine concepts, such as "areas").
To do that I created my own rectangle select, which gets triggered when the mouse moves after clicking it.

The problem that I'm now having is that I can't give unit orders with the left mouse button (since that's what I'm using to start selecting stuff). Example: Let's say I were to select a commander, and choose to attack a unit. Once I click on that unit to attack it, my widget would instead take over and enter the selection mode.

I guess the ingame selection mode works differently, and what I'm lacking is probably the engine(internal) state representation. The engine probably has the information that the user is selecting the object of the command and thus pressing the left mouse button doesn't initiate the selection, but instead sends the command.
And also, my selection works badly when any of the four corners of my rectangle go outside of the bounds o the map. But that's a different (less important) issue.
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: Implementing a feature selection

Post by aegis »

I reimplemented selection logic in SmartSelect, including an engine patch to fix "my selection works badly when any of the four corners of my rectangle go outside of the bounds o the map" (use the includeSky boolean on TraceScreenRay).

It might be useful as a reference: http://springrts.com/phpbb/viewtopic.php?f=23&t=24524
Post Reply

Return to “Lua Scripts”