build que?

build que?

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

Moderator: Moderators

User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

build que?

Post by smoth »

How do I get at the current build que, find out what is currently being built, what is the que count etc?
User avatar
det
Moderator
Posts: 737
Joined: 26 Nov 2005, 11:22

Re: build que?

Post by det »

¿que?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: build que?

Post by knorke »

manger à la fortune du pot:
Spring.GetUnitIsBuilding and http://springrts.com/wiki/Lua_SyncedRead#CommandQueues
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: build que?

Post by Jools »

det wrote:¿que?
Actually you can't write ¿que?, it must be ¿qué?.

que = conjuction = "that" (he said that he would come)
qué = interrogative pronoun = "what?" (what did he say)
User avatar
Prominence
Posts: 97
Joined: 24 Jun 2008, 07:21

Re: build que?

Post by Prominence »

Jools wrote:
det wrote:¿que?
Actually you can't write ¿que?, it must be ¿qué?.

que = conjuction = "that" (he said that he would come)
qué = interrogative pronoun = "what?" (what did he say)
You forgot to include abbreviation for Quebec.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: build que?

Post by Google_Frog »

Factory build queues are extremely broken. Check Integral Menu for examples of buildqueues and haxy workaround required to read and edit them.

Unit build queues are a bit less broken but still suck because CMD.SET_WANTED_MAX_SPEED is a really really annoying implementation of it's feature.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: build que?

Post by jK »

Google_Frog wrote:Factory build queues are extremely broken. Check Integral Menu for examples of buildqueues and haxy workaround required to read and edit them.
bullshit
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: build que?

Post by Forboding Angel »

det wrote:¿que?
queue even :-)
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: build que?

Post by smoth »

jK wrote:
Google_Frog wrote:Factory build queues are extremely broken. Check Integral Menu for examples of buildqueues and haxy workaround required to read and edit them.
bullshit
Care to explain jk? Not disagreeing, just want to understand what google is talking about and why it is wrong
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: build que?

Post by jK »

It's not my job to further extend my statement.
It was googlefrog who made a clumsy statement w/o any arguments.

I know the functions work fine period
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: build que?

Post by smoth »

Well google? What do you mean
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: build que?

Post by FLOZi »

jK wrote:It's not my job to further extend my statement.
It was googlefrog who made a clumsy statement w/o any arguments.

I know the functions work fine period

The functions may work as intended, I think google was implying that the architect is at fault, not the bricklayer.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: build que?

Post by smoth »

Ok, so then how is this question:

Google, what is the expected behavior in your eyes and what happens? What is undesired, what is desired?
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: build que?

Post by Google_Frog »

I don't recall many specifics as I worked with them 15 months ago. According to these comments if you remove units from a queue they are left behind with ID 0. There was a bit of unexpected stuff like that so just be wary of them.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: build que?

Post by smoth »

get build queue

Code: Select all

					local buildQueue = spGetUnitCommands(unitID)
					
					if buildQueue ~= nil then
						recursiveTableReader(buildQueue, "")
					end
Traverse

Code: Select all

	local function recursiveTableReader(currTable, dashes)
		dashes = dashes .. " - "
		if type(currTable) == 'table' then
			for k,v in pairs(currTable) do
				if (v ~= nil) then
					Spring.Echo(dashes .. "table :" .. k)
					recursiveTableReader(v, dashes)

				end
			end
		else
			if (k ~= nil and v ~= nil) then
				Spring.Echo(dashes .. " " .. k .. " " .. v)
			else
				if (v ~= nil) then
					Spring.Echo(dashes .. " value: " .. v)
				else
					if (k ~= nil) then
						Spring.Echo(dashes .. " key: " .. k)
					else
						Spring.Echo(dashes .. " nil ")
					end
				end
			end
		end
	end
result
- table :1
- - table :id
- - - nil
- - table :tag
- - - nil
- - table :options
- - - table :coded
- - - - nil
- - - table :shift
- - - - nil
- - table :params
- - - table :1
- - - - nil
- - - table :2
- - - - nil
- - - table :3
- - - - nil
- - - table :4
- - - - nil
What am I doing wrong here?
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: build que?

Post by jK »

smoth wrote:What am I doing wrong here?
Your recursiveTableReader() is bugged:

Code: Select all

local function recursiveTableReader(currTable, dashes)
	dashes = dashes .. " - "
	if type(currTable) == 'table' then
		...
		recursiveTableReader(v, dashes)
		...
	else
		if (k ~= nil and v ~= nil) then <<<<<<<<<<<<<<<<<<<<
			Spring.Echo(dashes .. " " .. k .. " " .. v)
		else
			...
		end
	end
k & v aren't defined there. only currTable is and that is not a table, instead it is of a different type.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: build que?

Post by smoth »

I am a retard..
thanks jk
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: build que?

Post by smoth »

So the fixed code now

get orders

Code: Select all

				
					local buildQueue = spGetUnitCommands(unitID)
					
					if buildQueue ~= nil then
						for k,v in pairs(buildQueue) do
							Spring.Echo("============" .. " table: " .. k .. " =============")
							recursiveTableReader(v, "  ")
						end
					end
get parameters

Code: Select all

	local function recursiveTableReader(currTable, dashes)
		dashes = dashes .. "   "
		if type(currTable) == 'table' then
			for k,v in pairs(currTable) do
				if (v ~= nil) then
					Spring.Echo(dashes .. "[" .. k .. "]")
					recursiveTableReader(v, dashes)
				end
			end
		else
			if (currTable ~= nil) then
				Spring.Echo(dashes .. tostring(currTable) )
			end
		end
	end

Code: Select all

 ============ table: 1 =============
      [id]
         -33
      [tag]
         1
      [options]
         [coded]
            32
         [shift]
            true
      [params]
         [1]
            8880
         [2]
            85.338134765625
         [3]
            2224
         [4]
            0
 ============ table: 2 =============
      [id]
         70
      [tag]
         2
      [options]
         [coded]
            32
         [shift]
            true
      [params]
         [1]
            0
 ============ table: 3 =============
      [id]
         -32
      [tag]
         3
      [options]
         [coded]
            32
         [shift]
            true
      [params]
         [1]
            8728
         [2]
            49.150390625
         [3]
            2600
         [4]
            0
 ============ table: 4 =============
      [id]
         70
      [tag]
         4
      [options]
         [coded]
            32
         [shift]
            true
      [params]
         [1]
            0
 ============ table: 5 =============
      [id]
         -31
      [tag]
         5
      [options]
         [coded]
            32
         [shift]
            true
      [params]
         [1]
            8832
         [2]
            32.40234375
         [3]
            3024
         [4]
            0
 ============ table: 6 =============
      [id]
         70
      [tag]
         6
      [options]
         [coded]
            32
         [shift]
            true
      [params]
         [1]
            0
 ================================
ok, now, to make sense of this.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: build que?

Post by smoth »

Code: Select all

============ table: 1 =============
     [id]
        -33
     [tag]
        1
     [options]
        [coded]
           32
        [shift]
           true
     [params]
        [1]
           1712
        [2]
           132.29370117188
        [3]
           1312
        [4]
           0
============ table: 2 =============
     [id]
        70
     [tag]
        2
     [options]
        [coded]
           32
        [shift]
           true
     [params]
        [1]
           0
============ table: 3 =============
     [id]
        -33
     [tag]
        3
     [options]
        [coded]
           32
        [shift]
           true
     [params]
        [1]
           1904
        [2]
           132.29370117188
        [3]
           1312
        [4]
           0
============ table: 4 =============
     [id]
        70
     [tag]
        4
     [options]
        [coded]
           32
        [shift]
           true
     [params]
        [1]
           0
============ table: 5 =============
     [id]
        -25
     [tag]
        5
     [options]
        [coded]
           32
        [shift]
           true
     [params]
        [1]
           1872
        [2]
           132.29370117188
        [3]
           1568
        [4]
           0
============ table: 6 =============
     [id]
        70
     [tag]
        6
     [options]
        [coded]
           32
        [shift]
           true
     [params]
        [1]
           0
================================
so what does any of this mean?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: build que?

Post by knorke »

smoth wrote:so what does any of this mean?
[1]
1712
this might be x!
Post Reply

Return to “Lua Scripts”