Page 1 of 2

Antinuke Rocket Autobuild

Posted: 20 Jul 2009, 14:51
by mildarf
I want to antinuke must have 3 rockets always. If enemy attack me with nuke, antinuke spend 1 rocket and automaticaly begin to create 1 more. And not need to check load antinuke.
I think that need to make a minimal threshold for nuke and antinuke?
Can you realize this?

Re: Antinuke Rocket Autobuild

Posted: 20 Jul 2009, 15:12
by Regret
No.

Re: Antinuke Rocket Autobuild

Posted: 20 Jul 2009, 15:39
by Jazcash
I have stockpiler widget which automatically adds 100 nukes and anti-nukes to each silo when built.

Re: Antinuke Rocket Autobuild

Posted: 21 Jul 2009, 01:18
by troycheek
I was working on something similar when I noticed the one that just stockpiles 100, so I just went with that.

The only benefit I can see for mildarf's version is that stockpiling 100 instead of 3 can take a fair chunk of your resources for a fair amount of time. On the other hand, I'd hate to lose most of my economy because I had one too few anti nukes.

On the other other hand, this shouldn't be too difficult...

Here we go. This widget monitors units that can stockpile and adds orders to stockpile more whenever they fall below a certain level. Change line 26 local stockpile = 3 to whatever you want that level to be.

Re: Antinuke Rocket Autobuild

Posted: 21 Jul 2009, 04:54
by Niobium
widget:StockpileChanged(unitID, unitDefID, unitTeam, weaponNum, oldCount, newCount)

Makes it heaps easier :D

Re: Antinuke Rocket Autobuild

Posted: 21 Jul 2009, 16:18
by mildarf
2 troycheek:
Thanks. Where this file must be placed?

Re: Antinuke Rocket Autobuild

Posted: 21 Jul 2009, 16:56
by SirMaverick
mildarf wrote:Where this file must be placed?
<Spring-Directory>/LuaUI/Widgets/

Re: Antinuke Rocket Autobuild

Posted: 21 Jul 2009, 17:26
by BrainDamage
I made a better version, only thing that it misses is that I don't know how to remove the 100 stockpile items when you capture/recieve an unit

Re: Antinuke Rocket Autobuild

Posted: 21 Jul 2009, 18:51
by SirMaverick
Optimized Brain Damage's version:
Uses ctr + shift to issue less commands.
Uses "right" as command option to cancel excess.

Re: Antinuke Rocket Autobuild

Posted: 21 Jul 2009, 19:17
by manolo_
cool, talked to grapefruit about that and he was making the same :) (or tries to :D )

Re: Antinuke Rocket Autobuild

Posted: 21 Jul 2009, 19:30
by manolo_
manolo_ wrote:cool, talked to grapefruit about that and he was making the same :) (or tries to :D )

edit: so summing up, that widget keeps the stockpile at a constant predefinied amount (what does ctrl or shift do?)

Re: Antinuke Rocket Autobuild

Posted: 21 Jul 2009, 19:40
by very_bad_soldier
Brain Damage wrote:I made a better version, only thing that it misses is that I don't know how to remove the 100 stockpile items when you capture/recieve an unit

Code: Select all

Spring.SendCommands{"luaui disablewidget Stockpiler"} -- Disable the old stockpiler widget which could conflict
This line makes my spring.exe freeze on "Loading LuaUI" if Stockpiler is already disabled.

Re: Antinuke Rocket Autobuild

Posted: 21 Jul 2009, 19:43
by troycheek
SirMaverick wrote:Optimized Brain Damage's version:
Uses ctr + shift to issue less commands.
I'd considered that, but then decided that if you're stockpiling large amounts, you'd probably be better off using trepan's old "just add 100" widget. I mean, I think the whole point of this widget is to keep a small stockpile to conserve resources. I think.

(If you need more than 100 nukes or anti nukes or anything else that can be stockpiled, you're probably doing something wrong.)

Niobium: I found StockpileChanged after I already had it working the other way, naturally. Some day soon, I'm going to have to alphabetize or otherwise organize that wiki more to my liking. My latest revision is enough like the others that I'm not going to bother releasing it. Just another interesting little programming exercise.

Re: Antinuke Rocket Autobuild

Posted: 21 Jul 2009, 20:35
by SirMaverick
very_bad_soldier wrote:

Code: Select all

Spring.SendCommands{"luaui disablewidget Stockpiler"} -- Disable the old stockpiler widget which could conflict
This line makes my spring.exe freeze on "Loading LuaUI" if Stockpiler is already disabled.
Spring version? I don't have any problems with 0.79.1.2 (single thread).

Re: Antinuke Rocket Autobuild

Posted: 21 Jul 2009, 20:51
by SirMaverick
troycheek wrote:
SirMaverick wrote:Optimized Brain Damage's version:
Uses ctr + shift to issue less commands.
I'd considered that, but then decided that if you're stockpiling large amounts, you'd probably be better off using trepan's old "just add 100" widget. I mean, I think the whole point of this widget is to keep a small stockpile to conserve resources. I think.
The point of this widget is to keep the stockpile at a certain number. This number is defined by the user.

Re: Antinuke Rocket Autobuild

Posted: 21 Jul 2009, 21:00
by manolo_
so what is the difference between troys and bd/sirs widget?
and sir mav what did u ment with ctrl+shift...?

Re: Antinuke Rocket Autobuild

Posted: 21 Jul 2009, 21:14
by SirMaverick
manolo_ wrote:so what is the difference between troys and bd/sirs widget?
in short: every of those stockpiles 3 anti nukes.

troys: stock pile up to the number defined in the widget (default 3)

bd: like toys
+ stock pile can be changed ingame: "/luaui stockpilecount 100" (the number is saved in spring settings and will be restored in the next game)

mine: like bd's
+ fix when you disable and reenable the widget ingame
and sir mav what did u ment with ctrl+shift...?
Implementation details. There are no differences for the user.

Re: Antinuke Rocket Autobuild

Posted: 21 Jul 2009, 21:37
by manolo_
i dont want to bind /luaui stockpilecount 100 to a key, so how could i change it without modify the widget itself?

Re: Antinuke Rocket Autobuild

Posted: 21 Jul 2009, 21:39
by troycheek
manolo_ wrote:[(what does ctrl or shift do?)
If you hold down shift when left clicking to add to the stockpile, it adds 5 instead of just 1. When you hold down ctrl, it adds 20. Both together adds 100. (Same when giving factories build orders.) Right clicking while holding those keys takes the same number away. This works for orders issued by the player and for orders issued by widgets if you do it right.

So if you wanted to add 127 stockpiled anti nukes as efficiently as possible, you'd shift-ctrl-click, ctrl-click, shift-click, click, click. Or something like that.

Re: Antinuke Rocket Autobuild

Posted: 21 Jul 2009, 21:40
by very_bad_soldier
SirMaverick wrote:
very_bad_soldier wrote:

Code: Select all

Spring.SendCommands{"luaui disablewidget Stockpiler"} -- Disable the old stockpiler widget which could conflict
This line makes my spring.exe freeze on "Loading LuaUI" if Stockpiler is already disabled.
Spring version? I don't have any problems with 0.79.1.2 (single thread).
Yeah same version here. It's strange, dont know, absolutely reproducable for me. Can't run it two times in a row, spring doesn't start anymore after the widget disabled originalStockpile once. Have to out-comment that line or enable origStockpiler again (makes me able to run it one more time).
Besides that, great widget! :mrgreen:

@manolo:
Just type that command in chat.