Jump to content

Recommended Posts

Posted (edited)

Hello,

 

I wanted to report an issue with the external cargo and event handler that I discovered while working on a game mode and some related lua code.

This error occurs when a piece of external cargo is lifted and then destroyed, by either being dropped or damaged mid-air. When this situation occurs, and an instance of the event handler has been called in the mission, the following error is prompted:
 

[string "..."]:10: attempt to call method 'getName' (a nil value)
stack traceback:
    [C]: in function 'getName'
    [string "..."]:10: in function 'onEvent'
    [string "Scripts/World/EventHandlers.lua"]:13: in function <[string "Scripts/World/EventHandlers.lua"]:11>

null
image.png

null

I have also seen this error in the forementioned game mode be prompted with a getPosition or getPlayerName call; but always occurred when the external cargo was picked up and then destroyed.

I have slimed the conditions of the error down to its most basic state, involving an external-cargo capable helicopter (in this case a CH-47), a piece of external cargo (in this case a small ISO container), and a 'Do Script' trigger calling the event handler, in the attached mission file.

I have also attached my DCS log for the instance and a video of the error occurring with this mission: https://youtu.be/Jlano9twZQ0

(Please excuse the delay in hooking the cargo, it's more stressful when recording 😅)

 

Lastly, here is the event handler code I used in the mission. For simplicity's sake, it is a slightly modified version of the event handler code found on the DCS hoggitworld wiki here: DCS func addEventHandler - DCS World Wiki - Hoggitworld.com

Code:

local e = {}
function e:onEvent(event)
    local m = {}
    m[#m+1] = "Event ID: " 
    m[#m+1] = event.id
    if event.initiator then 
        m[#m+1] = "\nInitiator : "
        m[#m+1] = event.initiator:getName()
    end
    if event.weapon then 
        m[#m+1] = "\nWeapon : "
        m[#m+1] = event.weapon :getTypeName()
    end 
    if event.target then 
        m[#m+1] = "\nTarget : "
        m[#m+1] = event.target :getName()
    end
    if event.id == 30 then
        m[#m+1] = "idx "
        m[#m+1] = event.idx
    end
    trigger.action.outText(table.concat(m), 10)
end
world.addEventHandler(e)

 

As a closing remark, I am quite new to Lua coding. As such, when this error began occurring, I did believe it to be a mistake from myself; especially given the complexity of my game modes code. However, after doing an extensive amount of testing, I became more confident in the idea this may be an actual bug. I look forward to learning more about the issue and hearing other's thoughts.
 

Thanks!

EventCrash.miz dcs.log

Edited by Jh3tski
  • Recently Browsing   0 members

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