Jump to content

[REPORTED]StaticObject.getByName() returns nil for Farps, oil rigs but not cargo


Recommended Posts

Posted

Hi,

myObject = StaticObject.getByName('farp')
if myObject:isExists() then
end

Will error in DCS 2.5.5.41962 because getByName() returns nil for Farps and Oil Rigs (so far, could be more like a static ship with helipad).

 

I've no idea what version this was last OK in. It might be something from a long time back but it came to light for me recently.

 

REPRO steps

 

  • Load the mission attached, (no moose/mist or anything, it's just pure DCS api) the code is on a menu trigger.
  • When the mission is loaded open the F10 menu, "Other" and press F1 to run it.
  • Open the dcs.log, look for "BUG REPORT"
  • You can see the script returned ok for a tech combine object, then a barrel cargo and then tries a farp and causes the error.

 

IMPACT

Actually this is rather severe, despite looking innocuous. getByName() is pretty fundamental and extremely well used method to find any static you want to do something with, in a script, like remove it, find its coordinates, but a farp is absolutely key as an airbase type. The issue comes from existing code already using getByName() in key scripts and being unable to filter between whatever object name you asked for by name. It's broken a lot of things for me, i'm not sure about others, it's quite deep when used by things like MOOSE for larger scripting modules. I tend to get lists of statics and run through them and check if they exist, get their coords and so on and if I try to access farps this way it will halt any scripting.

 

CODE (if you want it seperately)

local function checkIsExist(Name)
local static = StaticObject.getByName(Name) 
if static:isExist() == false then
env.info("BUG REPORT: "..Name.." does not exist (but getByName() works)")
else
env.info("BUG REPORT: "..Name.." returns true for both getByName() and isExist()")
end 
end
env.info("BUG REPORT: trying a techcombine")
checkIsExist('techCombine')--returns true
env.info("BUG REPORT: trying a cargo barrel")
checkIsExist('Barrels')--returns true
env.info("BUG REPORT: trying a farp")
checkIsExist('farp')--errors
env.info("BUG REPORT: trying an oilrig")
checkIsExist('oilrig')--errors

Sorry if this is known/reported and I am late.

getByNameBug-ReadLogUseF10.miz

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...