build que? - Page 2

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

Re: build que?

Post by smoth »

knorke wrote:
smoth wrote:so what does any of this mean?
[1]
1712
this might be x!
yeah I am thinking the same thing

My guesses
[id]
-25 cmdID?
[tag]
5
[options]
[coded]
32 - unitdefidMaybe?
[shift]
true
[params]definitely coordinates
[1]
1872
[2]
132.29370117188
[3]
1568
[4]
Pako
Posts: 174
Joined: 12 Jul 2009, 18:57

Re: build que?

Post by Pako »

http://springrts.com/wiki/Lua_CMDs

Negative CMD ID is a build command as negative unitDefID and parameters are mappos + heading.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: build que?

Post by smoth »

First, said "tags" are unique command identifiers, so each command that gets inserted into a unit's command queue gets its unique "tag" number. (It is used to sync command queue operations, also it makes things much easier.)
To receive those "tags" you can do the following:

local cmdQueue = Spring.GetUnitCommands(unitID);
if (#cmdQueue>0) then
local cmdTag = cmdQueue[1].tag
..
end
tags.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: build que?

Post by smoth »

yay so this covers mobile builders, NOT factories!

so for factories

Code: Select all

	local buildQueue = spGetFullBuildQueue(unitID)

Code: Select all

============ table: 1 =============
     [142]
        1
============ table: 2 =============
     [66]
        1
============ table: 3 =============
     [65]
        1
============ table: 4 =============
     [88]
        10
============ table: 5 =============
     [126]
        25
================================
which is :
[126] - [unitID]
25 - queue count


also this is in order..
Don't worry guys, I will make a small guide in the wiki about this after I am done.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: build que?

Post by smoth »

what a waste of a fing weekend. will wiki the knowledge up after I have rested up with work.

for later wikification:

Code: Select all

local function AlterQueue(teamID, factoryID, researchItems)
		local upgrades = researchItems.upgrades
		local facCmds = spGetFactoryCommands(factoryID)
  
		if facCmds then -- nil check
			for i = 1, #facCmds do
				local cmd = facCmds[i]
				local newBuildID = upgrades[-cmd.id]
				if newBuildID then
					-- ctrl in options here forces it to use factory build queue 
					spGiveOrderToUnit(factoryID, CMD.REMOVE, {cmd.tag}, {"ctrl"}) 
					spGiveOrderToUnit(factoryID, CMD.INSERT, {i, -newBuildID, 0}, {"ctrl", "alt"}) 
				end
			end
		end
	end

Code: Select all

spEditUnitCmdDesc(unitID,f,{disabled=true,hidden=true})
apparently people can make buttons of their own to issue the command id still

be sure to ultramegacockblockwith:

Code: Select all

	function gadget:AllowCommand(unitID, unitDefID, teamID, cmd, param, opt, tag, synced)
		if cmd < 0 then
			if lockedUnits[teamID][-cmd] then --list of shit he cannot build for that team.
				return false
			end
		end
build commands for units have fing negative values to tell them apart from regular commands.

I would like some waffles.
idntgvadmn
Posts: 1
Joined: 19 Jan 2012, 06:17

Re: build que?

Post by idntgvadmn »

did this ever get uploaded to the wiki? A guide looks promising.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: build que?

Post by smoth »

not yet, I have a few bits to figure out but I can post it later if desired.
Post Reply

Return to “Lua Scripts”