RELEASE: Nano Controls Widget

RELEASE: Nano Controls Widget

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

Moderator: Moderators

Post Reply
User avatar
TechnoTone
Posts: 165
Joined: 23 Aug 2005, 22:02

RELEASE: Nano Controls Widget

Post by TechnoTone »

Current version available at UF:
Image

Nano Controls widget by TechnoTone
Version 1.00

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

Provides GUI controls for nano towers.
Nano towers can be set to: Automatic / Repair / Reclaim.

Automatic: repairs units, reclaims features if required, assists construction of new units, assists factories.

Repair: repairs units, assists construction of new units (except factories).

Reclaim: reclaims all features/wrecks, irrespective or whether the resources are needed or not.


New towers are initially assigned the last order used, or Automatic if no order has been given.


This was initially a proof-of-concept project and the intention was to convert it into a gadget and place the controls into the standard unit control panel. I have tried to write the gadget and failed but BigHead has offered to do it (it was his idea to do it that way in the first place). In the mean time, this is available for testing purposes.

REQUIREMENTS: This widget requires the IceUI framework.

INSTALLATION: Please place this widget in the Spring/LuaUI/Widgets/IceUI folder.


Credits to:
Trepan - for the original ImmobileBuilder widget which I borrowed some code from
BigHead - for the inspiration for this widget and for some help producing it
MelTraX, AlfaSub - for the IceUI framework which made this widget so easy to produce

--------------------------------------------------------------------------------------------------------------------------
Last edited by TechnoTone on 13 Oct 2007, 14:22, edited 2 times in total.
User avatar
Pendrokar
Posts: 658
Joined: 30 May 2007, 10:45

Re: RELEASE: Nano Controls Widget

Post by Pendrokar »

TechnoTone wrote:
INSTALLATION: Please this widget in the Spring/LuaUI/Widgets/IceUI folder.

You forgot a word!
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

A version of this widget in gadget form that was automated would do wonders for AI nanotower usage. A simple check could disable the auomation for non AI players.
User avatar
BigHead
Posts: 145
Joined: 12 Jul 2007, 18:55

Post by BigHead »

A simple check could disable the auomation for non AI players.
Ehm, could you be more specific? I don't understand what you're trying to say ... edit: ... and I'm the one who's working on the gadget version so I'm concerned :)
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

ok each player controls a team and thus controls a commander right?

if(player is an AI){
do stuff
}

It is possible to check if the current player the gadget is running for is a human or an AI, trepan posted a quick snippet that showed it not long ago IIRC.

Why shouldn't the gadget be able to tell if its one fo the latter 2 and do extra work if it is?
Last edited by AF on 13 Oct 2007, 13:52, edited 1 time in total.
DZHIBRISH
Posts: 357
Joined: 16 Mar 2007, 22:28

Post by DZHIBRISH »

Big head nice stuff...any chace ull do a lua thingy that allows labs to self reclaim?
User avatar
TechnoTone
Posts: 165
Joined: 23 Aug 2005, 22:02

Re: RELEASE: Nano Controls Widget

Post by TechnoTone »

Edited first post. Forgot to mention this:
TechnoTone wrote:New towers are initially assigned the last order used, or Automatic if no order has been given.
User avatar
BigHead
Posts: 145
Joined: 12 Jul 2007, 18:55

Post by BigHead »

AF: I've read your "Unrealistic Expectations" thread so I know where you're aiming. However you still haven't written what { do stuff } should do :)

DZHIBRISH: TechnoTone made this widget. About your request: Good news is that what you want shouldn't be hard to implement. Bad news is that my time to work on spring is limited to weekends and I already have plans for something BIG. However I offer my help to anyone who decides to help you with this.

Code: Select all

These call-outs can be used to simulate reclaiming:
Spring.SetUnitHealth - diminishing health
Spring.AddUnitResource  - adding metal&energy make for the self-reclaiming factory
Spring.DestroyUnit - obvious
Edit: ... and please post to the right thread.
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Post by imbaczek »

FYI I committed a patch that stops allied builders on guard or patrol from repairing units that are being reclaimed. Testers welcome, as always.
User avatar
TechnoTone
Posts: 165
Joined: 23 Aug 2005, 22:02

Post by TechnoTone »

^ Nice one.

Does it check that the unit performing the reclamation is allied too? Wouldn't want nano's to ignore the enemy slowly reclaiming a factory, etc.
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Post by imbaczek »

Yes, in theory 8) As I said, the more testers, the better. Try it by yourself if you want to be 100000% sure and report a bug if this change broke something else.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

the do stuff is basically the whole point of this widget

aka if this widget had no 'do stuff' then it would do absolutely nothign and we'd all be complaining that someone had released an empty widget that did absolutely nothing.

As said above this widget assigns the last command applied. So that's basically all that's required, something to decide which command to initially assign.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Post by lurker »

Is it possible to add a repair-only mode?
User avatar
TechnoTone
Posts: 165
Joined: 23 Aug 2005, 22:02

Post by TechnoTone »

The engine doesn't distinguish between repair and build assist so to do that the widget would have to continuously check all units within reach of the nano tower to see which ones are in need of repair but that aren't still being built. This would have much more impact on the cpu usage of the widget.

In answer to your question: yes, it is possible. I won't be doing it any time soon though - if at all.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

You can use Spring.GetUnitHealth() -> health, maxHealth, paralyze, capture, buildProgress

If the unit is idle, find all units within its repair radius with Spring.GetUnitsInCylinder().
Search through the units to find which ones have buildProgress >= 1, and that have
health < maxHealth. Pick the closest / weakest / whatever and issue a repair order.

P.S. You'll want to set the move mode for this to work, iirc.
User avatar
BigHead
Posts: 145
Joined: 12 Jul 2007, 18:55

Post by BigHead »

Wow, this is very good news. I was aware of that call-out but always thought it does something else :)
Post Reply

Return to “Lua Scripts”