Or in other words how should I modify these scripts so that only player vehicle can activate them? The triggers are supposed to turn daylight on and off for extra dark tunnel experience, and they do, but traffic cars keep flickering the light. I tried many ways of adding data.subjectName or subjectID info in it without success. Code: local function sunsky(data) local obj = scenetree.findObject("sunsky") if obj then if data.event == 'enter' then obj:setHidden(true) end end end return sunsky
It should work if you add "and data.subjectID == be:getPlayerVehicleID(0)" to your condition, if not try dump(data) to see the table contents maybe that will give you a clue what's going on. The subjectID works fine, I used it in a more complex trigger handling script that keeps track of trigger enter/exit state for specific vehicles in a table, also because I needed to ignore traffic vehicles. The 'data' table is passed through onBeamNGTrigger hook, I don't know if the custom lua function set in the trigger parameters could be causing issues.
It works like a charm. Thank you so much! Code: local function sunsky(data) local obj = scenetree.findObject("sunsky") if obj then if data.event == 'enter' and data.subjectID == be:getPlayerVehicleID(0) then obj:setHidden(true) end end end return sunsky