Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Difficulty connecting Power Sources and Connection Nodes to Units #90

@Drofseh

Description

@Drofseh

I have two sets of groups Iraq-AA-SAM-SA2-1 to Iraq-AA-SAM-SA2-7 and Iraq-AA-SAM-Support-SA2-1 to Iraq-AA-SAM-Support-SA2-7

Each Support group has C2, supply, and generator units for the SAM group of the same number. SAM-1 is with Support-1, etc.

I'm using this code to try to connect the generators and C2 from the Supply groups to the SAM groups

iraqIADS:addSAMSitesByPrefix("Iraq-AA-SAM-SA2")
for i = 1, 7 do
    iraqIADS:getSAMSiteByGroupName("Iraq-AA-SAM-SA2-" .. i)
        :setAutonomousBehaviour(math.random(SkynetIADSAbstractRadarElement.AUTONOMOUS_STATE_DCS_AI, SkynetIADSAbstractRadarElement.AUTONOMOUS_STATE_DARK))
        :setCanEngageAirWeapons(true)
        :setCanEngageHARM(true)
        :setEngagementZone(SkynetIADSAbstractRadarElement.GO_LIVE_WHEN_IN_SEARCH_RANGE)
        :setGoLiveRangeInPercent(math.random(75, 150))
        :setHARMDetectionChance(math.random(15, 30))

    local connectionNode = Unit.getByName("Iraq-AA-SAM-SA2-" .. i .. "-4")

    local searchRadar = Unit.getByName("Iraq-AA-SAM-SA2-" .. i .. "-1")
    local searchRadarPower = Unit.getByName("Iraq-AA-SAM-Support-SA2-" .. i .. "-16")
    searchRadar:addPowerSource(searchRadarPower):addConnectionNode(connectionNode)

    local trackingRadar = Unit.getByName("Iraq-AA-SAM-SA2-" .. i .. "-2")
    local trackingRadarPower = Unit.getByName("Iraq-AA-SAM-Support-SA2-" .. i .. "-15")
    trackingRadar:addPowerSource(trackingRadarPower):addConnectionNode(connectionNode)

    local rangingRadar = Unit.getByName("Iraq-AA-SAM-SA2-" .. i .. "-3")
    local rangingRadarPower = Unit.getByName("Iraq-AA-SAM-Support-SA2-" .. i .. "-14")
    rangingRadar:addPowerSource(rangingRadarPower):addConnectionNode(connectionNode)
end

however I'm getting this error attempt to call method 'addPowerSource' (a nil value).

I've confirmed that the power source units and SAM units do exist and the names are correct.
ex. ["name"] = "Iraq-AA-SAM-SA2-1-1", and ["name"] = "Iraq-AA-SAM-Support-SA2-1-16",

I'm using this same method earlier in the script to connect power and command to EWR without any error notifications

iraqIADS:addEarlyWarningRadarsByPrefix("Iraq-AA-EWR")
for i = 1, 3 do
    iraqIADS:getEarlyWarningRadarByUnitName("Iraq-AA-EWR-" .. i .. "-1")
        :addPowerSource(Unit.getByName("Iraq-AA-EWR-" .. i .. "-2"))
        :addConnectionNode(Unit.getByName("Iraq-AA-EWR-" .. i .. "-3"))
end

So I'm a little confused at to what I'm doing wrong and any help would be appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions