local HarvestButton = {
Name = "HarvestButton",
Title = "TXT_KEY_BUILD_SCRUB_FIVEOUT", -- or a TXT_KEY
OrderPriority = 200, -- default is 200
IconAtlas = "UNIT_ACTION_ATLAS", -- 45 and 64 variations required
PortraitIndex = 51,
ToolTip = function(build, unit)
local sTooltip = Locale.ConvertTextKey("TXT_KEY_BUILD_SCRUB_FIVEOUT_HELP");
local resourceType = unit:GetPlot():GetResourceType()
if ( resourceType == -1 ) then
sTooltip = sTooltip .. "[NEWLINE][NEWLINE]" ..Locale.ConvertTextKey("TXT_KEY_BUILD_SCRUB_FIVEOUT_NO_FIVEOUT_TEXT")
end;
if ( resourceType == GameInfoTypes["RESOURCE_L5"] ) then
sTooltip = sTooltip .. "[NEWLINE][NEWLINE]" ..Locale.ConvertTextKey("TXT_KEY_BUILD_SCRUB_FIVEOUT_RED_ZONE_TEXT")
end;
return sTooltip;
end,
Condition = function(build, unit)
if unit:GetMoves() == 0 then return false end;
local resourceType = unit:GetPlot():GetResourceType()
if ( resourceType == GameInfoTypes["RESOURCE_L2"] ) then return true end;
if ( resourceType == GameInfoTypes["RESOURCE_L3"] ) then return true end;
if ( resourceType == GameInfoTypes["RESOURCE_L4"] ) then return true end;
return false
end,
Disabled = function(build, unit)
if unit:GetUnitType() ~= GameInfoTypes["UNIT_WORKER"] then return true end;
local resourceType = unit:GetPlot():GetResourceType()
if ( resourceType == GameInfoTypes["RESOURCE_L2"] ) then return false end;
if ( resourceType == GameInfoTypes["RESOURCE_L3"] ) then return false end;
if ( resourceType == GameInfoTypes["RESOURCE_L4"] ) then return false end;
return true
end,
Build = function(build, unit, eClick)
return GameInfo.Builds.BUILD_SCRUB_FIVEOUT2
end,
}
LuaEvents.UnitPanelBuildAddin(HarvestButton)