Help on Lua Widgets

Help on Lua Widgets

Various things about Spring that do not fit in any of the other forums listed below, including forum rules.

Moderator: Moderators

MarkosTA
Posts: 2
Joined: 25 Mar 2009, 11:42

Help on Lua Widgets

Post by MarkosTA »

Hi there, stupid question:

could anyone please tellme where to find info on how to USE Lua Widgets?

For example, i would like to know 2 use Custom Formations.

http://spring.clan-sy.com/wiki/Lua:WidgetDirectory contains nothing useful.

Thanks
User avatar
Licho
Zero-K Developer
Posts: 3803
Joined: 19 May 2006, 19:13

Re: Help on Lua Widgets

Post by Licho »

Easiest is to open springdownloader go to widgets tab and select this widget..
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Help on Lua Widgets

Post by Google_Frog »

To install widgets put them in Spring/LuaUI/Widgets. If the widget link is a lot of text put the text in a text document(.txt) and rename it to .lua.

To enable them ingame press F11 and click on the widget to enable/disable, use the mousewheel to scroll the list.
MarkosTA
Posts: 2
Joined: 25 Mar 2009, 11:42

Re: Help on Lua Widgets

Post by MarkosTA »

Ok, then I didn't explain correctly then.

I have them installed an running, but I would like to know what does each Widget do and how to take advantage of them in game.

Example: custom formations. What does it do? Do I have to issue any command in order to line up my units? Any particular key does modify widget's behavoiur?

Thanks.
User avatar
very_bad_soldier
Posts: 1397
Joined: 20 Feb 2007, 01:10

Re: Help on Lua Widgets

Post by very_bad_soldier »

Where do you get widgets without at least a brief explanation? You should really change your dealer.

Whats wrong about Licho's suggestion?

When having multiple units selected you can draw a line when giving a move command while hold right-click pressed. Thats what customformations is doing.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Help on Lua Widgets

Post by Beherith »

Sorry about the off topic, but I think the custom formations widget is one of the single greatest RTS UI innovations ever done.
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: Help on Lua Widgets

Post by imbaczek »

Custom Formations can be further improved, like this:
Image
ignore those two stray crosses plz ^^
User avatar
SwiftSpear
Classic Community Lead
Posts: 7287
Joined: 12 Aug 2005, 09:29

Re: Help on Lua Widgets

Post by SwiftSpear »

imbaczek wrote:Custom Formations can be further improved, like this:
Image
ignore those two stray crosses plz ^^
I'd personally prefer the current one, but ya, it'd probably nicer for some players.
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: Help on Lua Widgets

Post by imbaczek »

the current one makes units put each other of of the line and forces you to draw zigzags if you want a proper box. also, the default rmb-drag does box your units if there's too many of them to fit in one line, so there's also the consistency argument.
User avatar
SwiftSpear
Classic Community Lead
Posts: 7287
Joined: 12 Aug 2005, 09:29

Re: Help on Lua Widgets

Post by SwiftSpear »

imbaczek wrote:the current one makes units put each other of of the line and forces you to draw zigzags if you want a proper box. also, the default rmb-drag does box your units if there's too many of them to fit in one line, so there's also the consistency argument.
I prefer minute row control. Tactically speaking boxes are bad, they block your rear units from firing until your front units are dead, effectively halving your group DPS. There are exceptions, like artillery and stuff, but ideally you should be grouping those into separate groups and then just using the widget to draw two lines.

[edit] I'll seed the point of crowding. It should force overcrowed units into a back row as centered as possible to the group. But in all cases of non overcrowedness it should behave as it currently does... Maby a custom keystroke for more complicated formations, but honestly I think they will be more of a curiosity then something legitimately useful. Single file rows are simply the most efficient tactical shape you can form.
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: Help on Lua Widgets

Post by imbaczek »

i agree that lines are the most efficient, i wouldn't like the widget to make a box when a line would be possible; the problem now is that due to units pushing each other you end up with units scattered all around the place if there's enough of them.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Help on Lua Widgets

Post by Beherith »

There could also be one more improvement, involving mixed forces:
Say you had some slashers and levelers, or some morties, a few cans, a 2 jammers and a radar bot:
Image

Since i use mixed forces alot, it would be nice if the unit types stayed mixed in the formation, because currently units of different movetype really tend to get grouped on one side f the formation.

On another note, this is one of the features that deserve a software patent, then we could troll games who implement it for monies and get free publicity :) Seriously, the amount of original ideas and great accomplishments in spring is nothing short of staggering.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Help on Lua Widgets

Post by jK »

Beherith wrote:There could also be one more improvement, involving mixed forces: ...Image...
custom formations thread: "Also you can now use ALT to use a random algorithm."
(perhaps I should put it in the tooltip)
imbaczek wrote:Custom Formations can be further improved, like this:
Image
ignore those two stray crosses plz ^^
Only doable with a lot of math and nearly impossible to compute in a decent time, yeah you would even need a neural network to find out in which direction the box should expand etc.
Not to think of all those tasks without a decent solution (-> what if you draw a circle, spiral, a cross, ...).
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: Help on Lua Widgets

Post by imbaczek »

expansion direction wouldn't be that hard: take average position of all selected units, then take the average position of the custom formation line (average segment endpoints), subtract. the resulting vector, when normalized, gives you an approximate (= hopefully good enough) direction of expansion. shapes could be handled like this:
Image
not perfect but will get the job done as long as it's an option.
User avatar
MidKnight
Posts: 2652
Joined: 10 Sep 2008, 03:11

Re: Help on Lua Widgets

Post by MidKnight »

jK wrote:
Beherith wrote:There could also be one more improvement, involving mixed forces: ...[img]...[/img]...
custom formations thread: "Also you can now use ALT to use a random algorithm."
(perhaps I should put it in the tooltip)
Does this mean that I could, say, put my artillery behind my fighting units, alt+custform them, and expect them to retain their formation? Please say yes please say yes please say yes please say yes please say yes :-)
User avatar
Jazcash
Posts: 5309
Joined: 08 Dec 2007, 17:39

Re: Help on Lua Widgets

Post by Jazcash »

Custom Formations could do with lining up units as quick as possible.

Image
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: Help on Lua Widgets

Post by aegis »

:/ the one I'm using does the one on the right.
User avatar
Jazcash
Posts: 5309
Joined: 08 Dec 2007, 17:39

Re: Help on Lua Widgets

Post by Jazcash »

aegis wrote::/ the one I'm using does the one on the right.
Just did a load of testing on this and it seems that this only occurs when you have a smaller group of units. I tested with 8 Peewees, lined them up then drew the same length line just ahead of them. They did the formation on the right, the good one.

I tested with 30 peewees, the one on the left happened :<

Edit: Nvm, they seem to form into left or right diagrams randomly... Dunno if it depends on which way the units are facing. Unit type seems irrelevant.
User avatar
SwiftSpear
Classic Community Lead
Posts: 7287
Joined: 12 Aug 2005, 09:29

Re: Help on Lua Widgets

Post by SwiftSpear »

I think the algorith goes through the list of units putting them one after another into the shortest pathed location that isn't already taken. So you get weird results as a unit may be closest to X path location when it's turn comes to select a spot, so it selects X spot... but Y unit, who's turn comes later, although they are much closer to X spot they are forced to choose a different spot because X already is taken.

When units are in a straight line adjacent to eachother the closest location each unit can choose is the location directly across from them, but in more complicated formations and groups it breaks completely, and you get some very weird and inefficient movement in order to get in assigned locations.

A good algorithm would use imbaczek's calculation, list the units in order of closeness to the middle location of the line, and then have the units choose a spot based on thier location relative to the calculated center axis vs the other units in the group. If 2 units are directly parallel to the line, then they use the old system of choosing the closest location VS the other unit, so the unit closer to the closest location gets put there, and the farther unit has to go a little bit farther to the next closest location.
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: Help on Lua Widgets

Post by imbaczek »

JAZCASH: the cutoff point is defined in the widget to be around 17 units IIRC (it was like that last time I looked.) The problem is that doing the Right Thing is very CPU-expensive and should probably be written in C, which we don't allow for security reasons. A divide and conquer heuristic could work here, ie. split the selected group into squads and assign segments. This could be done more or less efficiently by leveraging the engine's spatial queries (GetUnitsIn*) so there's no pairwise distance comparisons in Lua to determine squads.
Post Reply

Return to “General Discussion”