Coded GiveOrderToUnit didn't work correct

Coded GiveOrderToUnit didn't work correct

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

Moderator: Moderators

Post Reply
oRRoSpike
Posts: 5
Joined: 04 Dec 2011, 10:44

Coded GiveOrderToUnit didn't work correct

Post by oRRoSpike »

Hi Guys,
(My english is not realy perfect)

First a little code sample:

Code: Select all

  Spring.GiveOrderToUnit(unitId, 90, {unitToReclaim}, {})
  local unitCommands = Spring.GetCommandQueue(unitId);
the first line is more or less clear, i give to a reclaimer the order to reclaim a unit.
the second is also not a challenge, i try to get the orders from this unit.

And here ist the Problem
The Method GetCommandQueue() returns null.

I have no Idea why.
I know the method GiveOrderToUnit() (the Unit does his order) and I know also the method GetCommandQueue(), in an other Widget it works. But only for clicked Commands. I tried since 3 Days all diverent possibility and I use also google, but I found no direction to solve this isssue.

is this a Bug in the new version, or is the usage wrong?
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Coded GiveOrderToUnit didn't work correct

Post by Google_Frog »

Network lag.
oRRoSpike
Posts: 5
Joined: 04 Dec 2011, 10:44

Re: Coded GiveOrderToUnit didn't work correct

Post by oRRoSpike »

network lag?
Sure?
...
coding
...
shit, 3 Gameframes later the commands are here.
and with this knowledge i found an solution vor my Problem

Thanks, my solution looks like an hack, but it works.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Coded GiveOrderToUnit didn't work correct

Post by Google_Frog »

A method that relies on a small number of game frames between issuing the command and it appearing in the command queue is not robust in multiplayer.
oRRoSpike
Posts: 5
Joined: 04 Dec 2011, 10:44

Re: Coded GiveOrderToUnit didn't work correct

Post by oRRoSpike »

thanks for the hint.
I avoid to use "hardnumbers"
I wait in gameframe of the command which i give:

Code: Select all

  local resurectorT1Commands = Spring.GetUnitCommands(resurectorT1Id)
    local resurectorT1Commands = Spring.GetUnitCommands(resurectorT1Id)
  if resurectorT1Commands ~= nil then
    for index=1, #resurectorT1Commands do
	  local unitCommand = resurectorT1Commands[index]
	  if unitCommand.id == CMD.RECLAIM then
		local unitToReclaimId = unitCommand.params[1]
		WG.AddTargetUnit(unitToReclaimId, resurectorT1Id)
		-- Do magic stuff
	  end
    end
  end
@more or less floris

/* uncommented because code above changed
Please one help again, it is realy a stupid question:
You see the if? i have no Idea to write something like in c#
if resurectorT1Commands != nil then
if have no Idea how i can write a "not"
what is the fucking sign?
*/
Last edited by oRRoSpike on 04 Dec 2011, 14:13, edited 2 times in total.
oRRoSpike
Posts: 5
Joined: 04 Dec 2011, 10:44

Re: Coded GiveOrderToUnit didn't work correct

Post by oRRoSpike »

I search since 2 Weeks for this shit
~=
thanks if found it now
I think there was a time in which i was better in programming
User avatar
Niobium
Posts: 456
Joined: 07 Dec 2008, 02:35

Re: Coded GiveOrderToUnit didn't work correct

Post by Niobium »

oRRoSpike wrote:Please one help again, it is realy a stupid question:
You see the if? i have no Idea to write something like in c#
if resurectorT1Commands != nil then
if have no Idea how i can write a "not"
what is the fucking sign?

Code: Select all

if not x then

Code: Select all

if x ~= nil then
oRRoSpike
Posts: 5
Joined: 04 Dec 2011, 10:44

Re: Coded GiveOrderToUnit didn't work correct

Post by oRRoSpike »

thx

this forum is realy fast, i am surprissed!!!
Post Reply

Return to “Lua Scripts”