down there is a codesample of the Build-Splitter Widget how was working before
to get in the "if", u have to make 2+ Builders and build some line or quader with the metakey holded
the interesting part is now after the new versions, only one buildcommand is returned if "return true" is set at the end
Code: Select all
function widget:GetInfo()
return {
name = "only a test",
desc = "test of the commandnotify",
author = "djmad",
version = "v1.0",
date = "Dez 30, 2011",
license = "GNU GPL, v2 or later",
layer = 0,
enabled = true -- loaded by default?
}
end
local floor = math.floor
local spGetGameFrame = Spring.GetGameFrame
local spGetSpecState = Spring.GetSpectatingState
local spTestBuildOrder = Spring.TestBuildOrder
local spGetSelUnitCount = Spring.GetSelectedUnitsCount
local spGetSelUnitsSorted = Spring.GetSelectedUnitsSorted
local spGiveOrderToUnit = Spring.GiveOrderToUnit
local spGiveOrderToUnitArray = Spring.GiveOrderToUnitArray
local uDefs = UnitDefs
local buildID = 0
local buildLocs = {}
local buildCount = 0
function widget:Initialize()
if spGetGameFrame() > 0 then
widget:GameStart()
end
end
function widget:GameStart()
local areSpec = spGetSpecState()
if areSpec then
widgetHandler:RemoveWidget(self)
end
end
function widget:CommandNotify(cmdID, cmdParams, cmdOpts)
Spring . Echo ( cmdID , #cmdParams , #cmdOpts, buildCount, spGetSelUnitCount() )
if not (cmdOpts.shift and cmdOpts.meta) then return false end
if spGetSelUnitCount() < 2 then return false end
if #cmdParams < 4 then return false end
if spTestBuildOrder(-cmdID, cmdParams[1], cmdParams[2], cmdParams[3], cmdParams[4]) == 0 then return false end
buildID = -cmdID
buildOpts = cmdOpts
buildCount = buildCount + 1
buildLocs[buildCount] = cmdParams
return true --<<< THIS HERE
end
function widget:Update() -- 0 of 0 parameters
if buildCount == 0 then return end
Spring . Echo ( "i build now ", buildCount, "jobs" )
buildCount = 0
end
Was there changed some logic in the background?
Code: Select all
function widget:GetInfo()
return {
name = "only a test",
desc = "test of the commandnotify",
author = "djmad",
version = "v1.0",
date = "Dez 30, 2011",
license = "GNU GPL, v2 or later",
layer = 0,
enabled = true -- loaded by default?
}
end
local floor = math.floor
local spGetGameFrame = Spring.GetGameFrame
local spGetSpecState = Spring.GetSpectatingState
local spTestBuildOrder = Spring.TestBuildOrder
local spGetSelUnitCount = Spring.GetSelectedUnitsCount
local spGetSelUnitsSorted = Spring.GetSelectedUnitsSorted
local spGiveOrderToUnit = Spring.GiveOrderToUnit
local spGiveOrderToUnitArray = Spring.GiveOrderToUnitArray
local uDefs = UnitDefs
local buildID = 0
local buildLocs = {}
local buildCount = 0
function widget:Initialize()
if spGetGameFrame() > 0 then
widget:GameStart()
end
end
function widget:GameStart()
local areSpec = spGetSpecState()
if areSpec then
widgetHandler:RemoveWidget(self)
end
end
function widget:CommandNotify(cmdID, cmdParams, cmdOpts)
Spring . Echo ( cmdID , #cmdParams , #cmdOpts, buildCount, spGetSelUnitCount() )
if not (cmdOpts.shift and cmdOpts.meta) then return false end
if spGetSelUnitCount() < 2 then return false end
if #cmdParams < 4 then return false end
if spTestBuildOrder(-cmdID, cmdParams[1], cmdParams[2], cmdParams[3], cmdParams[4]) == 0 then return false end
buildID = -cmdID
buildOpts = cmdOpts
buildCount = buildCount + 1
buildLocs[buildCount] = cmdParams
return false --<<< THIS HERE
end
function widget:Update() -- 0 of 0 parameters
if buildCount == 0 then return end
Spring . Echo ( "i build now ", buildCount, "jobs" )
buildCount = 0
end
btw, this issue is atm in 2 widgets i know, Build-Split + Centralbuild AI