LEDZ widgets: nukeTracker.lua - Page 2

LEDZ widgets: nukeTracker.lua

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

Moderator: Moderators

User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: LEDZ widgets: nukeTracker.lua

Post by Forboding Angel »

Inconsistent, and non-chili gui stuff looks awful comparatively (ZK's fugly ass teal chili skin is not to be used as an example here, that thing is a crime against nature).
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: LEDZ widgets: nukeTracker.lua

Post by smoth »

well chili people can make a chili version.
wolas
Posts: 112
Joined: 30 Jul 2010, 20:40

Re: LEDZ widgets: nukeTracker.lua

Post by wolas »

lets chill
LEDZ
Posts: 66
Joined: 27 Jun 2011, 13:43

Re: LEDZ widgets: nukeTracker.lua

Post by LEDZ »

I've had a look at the Chili GUI and I don't see why a widget like that makes a problem. I'm going to make it look a bit more finished and it will be a smaller screen element (size is based on font size, made bigger only for show in videos) so I don't see the fuss.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: LEDZ widgets: nukeTracker.lua

Post by smoth »

it is just visually conflicting. Don't worry about it. Like i said if someone wants a chilli version they can make it.
LEDZ
Posts: 66
Joined: 27 Jun 2011, 13:43

Re: LEDZ widgets: nukeTracker.lua

Post by LEDZ »

I cannot get the widget to find a nuke projectile consistently after it launches.
At the moment I'm using stockpile change (reduces by one when nuke fires) as a call-in and then looking for projectiles on the map that correspond to a nuke (from weaponDefID) however this doesn't always work.

I believe there some frames passing between the stockpile going down and the sim creating the projectile.

Any help with this would be vastly appreciated and then I can release this cool/useful nukeTracker widget.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: LEDZ widgets: nukeTracker.lua

Post by Jools »

XTA has the ota style minimap X: http://code.google.com/p/xta-springrts/ ... nimapx.lua

Would it be more efficient to call that getprojectiles_in_rect instead of watching weapons?
LEDZ
Posts: 66
Joined: 27 Jun 2011, 13:43

Re: LEDZ widgets: nukeTracker.lua

Post by LEDZ »

That is precisely what it does currently but it seems to call it before the projectile is created. Bit stuck with this one.
LEDZ
Posts: 66
Joined: 27 Jun 2011, 13:43

Re: LEDZ widgets: nukeTracker.lua

Post by LEDZ »

Okay guys, I've reopened my dusty chest of lua scripts.
This widget has stopped working but was at last use practically finished.
There is a new issue however:
Spring.GetUnitCommands is returning an empty table even after being initiated by a widget:UnitCommand callin for a nuke silo attack command. Any ideas why this may be?
I've had a look through the wiki and changelog but I cannot find any clues as yet.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: LEDZ widgets: nukeTracker.lua

Post by knorke »

Is http://springrts.com/phpbb/viewtopic.ph ... =0#p529535 the newest version?

Code: Select all

function widget:UnitCommand(unitID, unitDefID, unitTeam, cmdID, cmdOpts, cmdParams)

	if unitDefID ==  141 or unitDefID == 312 or unitDefID == 333 or unitDefID == 55 or unitDefID == 182 or unitDefID == 2 then
		if cmdID == 20 then
The script is full of "magic numbers" like that.
If the game (BA?) adds or removes a unit then the unitDefID numbers might change and the script gets confused.
:arrow: That might have caused it to stop working.
See http://springrts.com/wiki/Lua_UnitDefs# ... 2Fsnippets how to get unitDefID from a unitname.
Similiar for the commandIDs, they are less likely to randomly change but still better to use the constants. (even if it is just for easier reading)
http://springrts.com/wiki/Lua_CMDs#Commands

About the "new issue" idk.
Do the units/weapon use canManualFire/commandfire? Perhaps with those tags they automatically drop the attack-order after one shot. But that is just guess, would have to test. Maybe give a longer commandqueue and see if it is still empty?
Or if you post your code then maybe can look for error. ;)
LEDZ
Posts: 66
Joined: 27 Jun 2011, 13:43

Re: LEDZ widgets: nukeTracker.lua

Post by LEDZ »

I noticed that problem already. They did indeed change recently so that was broken. I'm now using the unit names (corsilo) instead. And I've add CMD.ATTACK instead too. Thanks.

This is the part of the code that I'm having problems with; the newest command order is not within the tables. For example, if (whilst holding shift) I select an armsilo and perform the following orders:
Wait, Attack (somewhere on map), Attack, Attack
Each time, only the commands up to and not including the latest one are in the table.

Code: Select all

function widget:UnitCommand(unitID, unitDefID, unitTeam, cmdID, cmdOpts, cmdParams)
	uDef = UnitDefs[unitDefID]
	unitName = uDef.name
	commands = Spring.GetCommandQueue(unitID,10)
	
	Spring.Echo("Start 1")
	for x = 0, 3 do
		command = commands[x]
		Spring.Echo("x",x)
		Spring.Echo("command",command)
		if command ~= nil then
			for j, expanded in pairs(command) do
					Spring.Echo("j",j)
					Spring.Echo("expanded",expanded)
			end
		end
	end	
	end
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: LEDZ widgets: nukeTracker.lua

Post by Silentwings »

I guess its just that the table starts indexed at 1 (and not 0) ?

Also, if you just want to see an array table in numerical order of its keys, started at 1, ipairs() is better.
LEDZ
Posts: 66
Joined: 27 Jun 2011, 13:43

Re: LEDZ widgets: nukeTracker.lua

Post by LEDZ »

Oh sorry, the 0 was something I tried in case I was missing something, and I was using ipairs at first. This was an attempt to investigate further.
8611
XTA Developer
Posts: 242
Joined: 29 Dec 2014, 08:22

Re: LEDZ widgets: nukeTracker.lua

Post by 8611 »

Does not really answer the question but might be worth noting...

I used BA 7.91 with /luaurules disable and all widgets disabled, except the test widget.

Code: Select all

function widget:UnitCommand(unitID, unitDefID, unitTeam, cmdID, cmdOpts, cmdParams)
   uDef = UnitDefs[unitDefID]
   unitName = uDef.name
   commands = Spring.GetCommandQueue(unitID,10)
   
   Spring.Echo("-----")
   local s = ""
   for _,command in pairs (commands) do
      if command ~= nil then
		s=s..CMD[command.id].."-"
      end
   end
   Spring.Echo (s)
end
This widget is supposed to print a units commands as text, example output:

MOVE-SET_WANTED_MAX_SPEED-PATROL-PATROL-SET_WANTED_MAX_SPEED-FIGHT-

The set_wanted_max_speed thing is bit annoying but rest looks okay.
(it will of course fail with build-orders where the ID is negative and in some other cases, so just test with "normal" commands like move, patrol, fight etc)

In spring 98.0:
The strange thing is that if a unit is given attack-order on the ground or on enemy unit then it prints "LOOPBACKATTACK"
:arrow: I would have expected "ATTACK" :shock:
Tested with ARM commander, armsilo and armpw.

In spring 94.1:
Here it prints "ATTACK", like expected.

Should LOOPBACKATTACK not be the immelmann-style attack move of aircraft?
Did not look further, so not sure what to make of that.

/edit
https://github.com/spring/spring/blob/d ... MD.cpp#L73
:?: LuaInsertDualMapPair(L, "LOOPBACKATTACK", CMD_ATTACK); // backward compability (TODO: find a way to print a warning when used!)

Similiar with DGUN/MANUALFIRE: A Dgun-command given by players causes "DGUN" command not, the more political correct MANUALFIRE?
Post Reply

Return to “Lua Scripts”