mrSkortch / MissionScriptingTools

Mission Scripting Tools for Digital Combat Simulator
GNU General Public License v3.0
190 stars 42 forks source link

Object.getPosition() calls generating errors with some statics #74

Open WirtsLegs opened 1 year ago

WirtsLegs commented 1 year ago

So seems that some calls to Object.getPosition are being made with a nil argument which causes an error with that function (doesn't generate a nil return as seems to be expected), specifically seems to happen when certain statics are destroyed.

Suggest maybe protecting the call

image

WirtsLegs commented 1 year ago

I have personally fixed the issue by adding a function I like ot use for protected calls

local function p(...)  
    local status, retval = pcall(...)  
    env.warning(retval,false)  
    if not status then  
        return nil  
    end  
    return retval  
end  

then replacing local pos = Object.getPosition(val.object) with local pos = p(Object.getPosition,val.object)