More Widgety Widgets

More Widgety Widgets

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

Moderator: Moderators

Tim-the-maniac
Posts: 250
Joined: 22 Jul 2006, 19:58

More Widgety Widgets

Post by Tim-the-maniac »

Some more and slightly updated widgets:

Idle cons widget
Control idle con with icons at bottom of screen, they now have an auto build capability which will make them build something from a list once they have been idle for a set amount of time, setting like this are at the top of the lua file. (ofcourse its disabled by default)

DL: http://spring.unknown-files.net/file/25 ... eBuilders/

InsertCommands widget
Allows insertion of commands to the front of the command queue see link for more info

DL: http://spring.unknown-files.net/file/25 ... tCommands/

Transport Assister
This widget makes transports which are set to guard a factory take new units to the factories destination.

DL:
http://spring.unknown-files.net/file/25 ... tAssister/

Bomber Controller
Bit harder to explain this one :-). It allows bombing of targets by setting a marker at the target location rather than giving orders to individual bombers. All bombers which are set to wait and have no other commands will be used. A gather point can be set which is the location all bombers will go to when they have finished a bombing run or have come from a factory which is set to send bombers there.
To set the gather point, hold the V key and click the mouse and to set a factory to send bombers to gather point, hold V and click the factory.
To add a target to bomb, hold the N key and press a number from 1 to 9 depending on how many bombers you want to bomb. Hold N and click the target to delete it. Targets stay green until there is enough bombers to attack it.

DL:
http://ray.iamacup.com/unit_bomber_control.lua
screenies showing it in action:
http://ray.iamacup.com/bomber2.jpg
http://ray.iamacup.com/bombers3.jpg
User avatar
BrainDamage
Lobby Developer
Posts: 1164
Joined: 25 Sep 2006, 13:56

Post by BrainDamage »

first of all, nice collection of widgets! :wink:

i've found few issues with them:

the insert command in the cue: after sending an order to the start of the cue, the cue won't be displayed anymore even if the meta-key is kept pressed. to display again, it needs for the key to be released and pushed again

the transport widget: even if the transport supports the loading of multiple units, the transport will pick up only 1 at once; it's very likely that few units will be produced while the transport is moving, making a trip for each of them is not really efficent-wise

the bomber widget: when you set a target, the bomber shoots it and the bomber survives, and you delete the target, the bomber won't be sent back to the rally point, but will keep flying above the ex-target, without shooting (won't be listed as free in the widget anymore)

i don't know if this is good or bad, but the liche is not considered an usable bomber byt the widget.

this is a small request: is the possible to bind a key to assign selected bombers to the widget?
Tim-the-maniac
Posts: 250
Joined: 22 Jul 2006, 19:58

Post by Tim-the-maniac »

Brain Damage wrote:the insert command in the cue: after sending an order to the start of the cue, the cue won't be displayed anymore even if the meta-key is kept pressed. to display again, it needs for the key to be released and pushed again
I dont understand, are you holding shift?
the transport widget: even if the transport supports the loading of multiple units, the transport will pick up only 1 at once; it's very likely that few units will be produced while the transport is moving, making a trip for each of them is not really efficent-wise
Yeah I thought about that but I dont think it would be that usefull in-game.
the bomber widget: when you set a target, the bomber shoots it and the bomber survives, and you delete the target, the bomber won't be sent back to the rally point, but will keep flying above the ex-target, without shooting (won't be listed as free in the widget anymore)
Fixed (i think), thanks.
i don't know if this is good or bad, but the liche is not considered an usable bomber byt the widget.

this is a small request: is the possible to bind a key to assign selected bombers to the widget?
I might try and improve it to take account of different kinds of bombers like emp and such, also whats wrong with the W key for assigning bombers? :)
MelTraX
Posts: 470
Joined: 02 Jan 2007, 16:18

Post by MelTraX »

also whats wrong with the W key for assigning bombers? :)
Well, keys shouldn't be hardcoded.. That's what uikeys.txt is for.. But I'm not sure if you can check if a key is being hold down.. Maybe you would have to make the key toggle your mode or something like that.. :-)
Tim-the-maniac
Posts: 250
Joined: 22 Jul 2006, 19:58

Post by Tim-the-maniac »

I meant the W key for setting them to wait (sure you can use some other key if you want :))
MelTraX
Posts: 470
Joined: 02 Jan 2007, 16:18

Post by MelTraX »

Hmm.. Okay.. I was more talking about your N and V keys, which sound to be harcoded in your widgets.. It's not that a big deal since the widgets are scripts where everyone can change the keys easily but it would still be cooler is all keys are defined in uikeys.txt (well even better in-game in an option dialog but I'm not that far along yet :-) )
User avatar
LordMatt
Posts: 3393
Joined: 15 May 2005, 04:26

Post by LordMatt »

Ray did you update these any since you sent them to me last?
User avatar
BrainDamage
Lobby Developer
Posts: 1164
Joined: 25 Sep 2006, 13:56

Post by BrainDamage »

Tim-the-maniac wrote:I dont understand, are you holding shift?
i tried to use it as shift-replacement (LIFO cue instead of FIFO), but the cue display disappears after you sent the command (even if the key is still pressed), i guess i'll have to be less lazy and press shift as well :P
Tim-the-maniac wrote:whats wrong with the W key for assigning bombers? :)
sorry, i misundertood your guidelines, i tought that the bomber must be set on wait AND comes from a marked factory, i apologize (that's why i asked if there was a way to assign them to the widget manually); yes setting them on wait works
Tim-the-maniac wrote:Yeah I thought about that but I dont think it would be that usefull in-game
my opinion is the opposite :P
Tim-the-maniac wrote:I might try and improve it to take account of different kinds of bombers like emp and such,
i have an half-idea for that; how about dividing the combers by unit type?
instead of displaying the # of total bombers, add a list divided by category, like:

* 2 strategic bombers
3 emp bombers
1 torpedo bomber

the *, is a marker to show wich type of bomber is currectly being about to use (the bomber type will be cycled with a key)

when using the N key, it will send orders to just the type of bombers you have active; allowing to menage different type of bombers with the same widget

oh, a an inside request: if you implement it, pls don't show the bomber's name in the list, instead i think the unit description is much more immediate (expecially for newbies)
chlue
Posts: 101
Joined: 28 Dec 2005, 20:48

Re: More Widgety Widgets

Post by chlue »

Tim-the-maniac wrote:Idle cons widget
Control idle con with icons at bottom of screen, they now have an auto build capability which will make them build something from a list once they have been idle for a set amount of time, setting like this are at the top of the lua file. (ofcourse its disabled by default)
A nice widget, that unfortunately does nearly nothing usefull in EE. So I made a heavy modified version:

- implemented a list of units / buildings. Only things on this list are checked. (implemented currently in a very inefficient and static way)
- this primary results in scouts (you will let them idle with a good reason) and refuilpads (they can't do anything and cause an LUA error in the orginal version) no longer showing up.
- cleared FacChoices, highE and mBurn
- set lowE to {"urcadvreact2", "urcreact2", "gdadvreact2", "gdreact2"}. So units will now build reactors in EE, if the lowE condition is met. Changed the decision, so that they will try the first one first. Result: If a builder can build the advanced one, he will always build it, even if he can build the normal one, too.
- disabled assignment of tasks to factories
- moved the widget up by 77 pixel, so that is does not overlap with 'gui_selbuttons.lua'. fixed an error in the calculationcode (without the blue bars always begin at the bottom of the screen)
- implemented two ugly buttons on the left side of the widget. The upper one affects immobile Builders, the lower one the mobile ones. If the button is green, they will be shown, if he is red, they will not.
- renamed it to 'IdleBuildersEE', so you can have both widgets in your folder and can switch ingame.

the widget can be found here, for the next seven? days:
http://spring.unknown-files.net/file/25 ... rs_ee.lua/
chlue
Posts: 101
Joined: 28 Dec 2005, 20:48

Post by chlue »

I just want to add, if someone posts me some example code, how to detect the mod, i will make a version, that will work with multiple mods. I managed to print the modname with Game.modName, but was unable to search the string and make a desision. I need something like that:

if Game.modName contain "balanced" then
'load Balanced Annihilation settings'
elseif Game.modName contain "Expand" then
'load Expand and Exterminate settings'
else
'load minimalistic universal settings'
end
User avatar
TechnoTone
Posts: 165
Joined: 23 Aug 2005, 22:02

Post by TechnoTone »

Tim-the-maniac wrote:
Brain Damage wrote:the bomber widget: when you set a target, the bomber shoots it and the bomber survives, and you delete the target, the bomber won't be sent back to the rally point, but will keep flying above the ex-target, without shooting (won't be listed as free in the widget anymore)
Fixed (i think), thanks.
Still not working. At least, when I was testing I was setting a point on the ground as a target then using N+Click to clear it. When I did this the bomber(s) wouldn't return and were no longer available. Sometimes they would just land and other times they flew around above their former target.
User avatar
Lindir The Green
Posts: 815
Joined: 04 May 2005, 15:09

Re: More Widgety Widgets

Post by Lindir The Green »

chlue wrote:- set lowE to {"urcadvreact2", "urcreact2", "gdadvreact2", "gdreact2"}. So units will now build reactors in EE, if the lowE condition is met. Changed the decision, so that they will try the first one first. Result: If a builder can build the advanced one, he will always build it, even if he can build the normal one, too.
Wait... So if I have low energy, my idle cons will automatically start building reactors? That really seems like cheating.

We really need a way for hosts to only allow certain widgets/groupAIs in their games, especially tournament/ladder games...
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

Yes it's crossing the line into dgun groupAI territory
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

I've already coded the .nohelp command. It blocks all GroupAI's and
LuaUI's control of units (LuaUI can still draw, select units, etc...) It currently
also blocks GlobalAIs (something that should be fixed, eventually).
Last edited by trepan on 14 Mar 2007, 17:23, edited 1 time in total.
chlue
Posts: 101
Joined: 28 Dec 2005, 20:48

Re: More Widgety Widgets

Post by chlue »

Lindir The Green wrote:Wait... So if I have low energy, my idle cons will automatically start building reactors? That really seems like cheating.
Thats exactly what it does. But it will build the building on the position where it is standing. So it really useless to let them automatically do that. The Economy Group AI may be partially usefull for that, because you define a region where they build, but in this widget its not really usefull.
The main point of this widget is, that you see your idle workers and factories and left click select them, while middle-click select and center them. The automatic building on rightclick or after a certain amount of idle time is primary a gimmick Tim-the-maniac implemented and I enabled it to work with EE.

This is usefull so far, as if you have low energy, left click an idle con and see it is in an area, where an energybuilding does not hurt, you don't have to search for the button in the buildmenu; simply press the right mousebutton. I don't think this seems like cheating.

-------------------------------------------------------------


Updated the widget:
- shows how many units are idle.
- third category. Mobile Builders, that guard something. aka Builders that possible are avaible for more urgend tasks
- some internal reorders. The only further thing I need to get working, is a method to detect the mod. Then this will work for multiple mods.
- set IdleTime to 0. This deactivates autobuilding/assisting after the idle time is over. Can be changed ingame with /luaui autobuild <new time>, but as discussed in the other paragraph, this isn't really usefull at all in a real game.

Interface:
F: Factories
M: MobileUnits
G: GuardingUnits
The number indicated how many units are in that category

Left click on unit: select
middle click: select and center
right click: send unit to assist nearst factory (on factories this does nothing)

New temporary link: http://spring.unknown-files.net/file/25 ... rs_ee.lua/
User avatar
TechnoTone
Posts: 165
Joined: 23 Aug 2005, 22:02

Post by TechnoTone »

I've just made a small addition to the Idle Builders widget so that it doesn't display any icons if there are units currently selected. I've done this so as to avoid the issues caused when using both the IdleBuilders widget and the SelectionButtons widget by trepan.

I added the following lines to the beginning of the widget:DrawScreen() function:

Code: Select all

  local u = Spring.GetSelectedUnits()
  local n = u.n
  if n > 0 then
    return true
  end
Hope you don't mind and I hope this code is ok - it's my first foray into LUA scripting.
chlue
Posts: 101
Joined: 28 Dec 2005, 20:48

Post by chlue »

Updated Version:

http://spring.unknown-files.net/file/25 ... _included/

changes:
- Finally works with BA and EE
- default config for unknown mods
- I merged the change that TechnoTone suggested. (Controlled by the variable in line 18 )

Overview:
I tweaked it, so it works better with Expand and Exterminate
The behavior with BA is mostly the same, as the version from Ray (apart the buttons and the new 'guarders' category)
If you want to add another mod: copy the config_default() function and change it, so that it suits the mod. Then extend the function widget:Initialize(), so that it detects the mod. And don't forgot to post it here!

Interface:
F: Factories
M: MobileUnits
G: GuardingUnits
The number indicate how many units are in that category

Left click on unit: select
middle click: select and center
right click: send unit to assist nearst factory (on factories this does nothing) or assign a task defined by the rules in the config function.

You have to modify line 12-18 to change the default setting
Additionall you can use this ingame:
/luaui autobuild <new time>
/luaui v_pos <new spacing from bottom>
User avatar
Licho
Zero-K Developer
Posts: 3803
Joined: 19 May 2006, 19:13

Post by Licho »

Please consider changing condition in air transport assist to something like

Code: Select all

if (not UD.springCategories["notair"] or not UD.springCategories["notship"]) or (UD.builder and UD.canAssist) then return end 
To make it compatible with FactoryGuard :)
CautionToTheWind
Posts: 272
Joined: 30 May 2006, 17:06

Post by CautionToTheWind »

Hi, the transport-assist-factory widget made tiny tears in my eyes. I further improved it (IMHO) by changing to unload order to an area unload so that you wont get unloading traffic jams when you use many transports on fast-producing factories.

I replaced line 78 with:

Spring.GiveOrderToUnit(transID, CMD_UNLOAD_UNITS, {params[1], params[2], params[3], 100} , {"shift"})
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

Licho wrote:Please consider changing condition in air transport assist to something like

Code: Select all

if (not UD.springCategories["notair"] or not UD.springCategories["notship"]) or (UD.builder and UD.canAssist) then return end 
To make it compatible with FactoryGuard :)
Aw, crap, another thing that's hardcoded to use the categories. I can tell you that's going to fail with all of my mods because I don't use the categories notair and notship.
Post Reply

Return to “Lua Scripts”