Wizard1393 Posted March 2, 2019 Posted March 2, 2019 (edited) I have a script where an event handler starts like this: function msn.event_dead:onEvent(Event) 471 if Event.id == world.event.S_EVENT_DEAD then 472 473 local initObj = Event.initiator 474 local initObjName = initObj:getName() This code crashes with error: "474: attempt to index field 'initObj' (a nil value)" I've also tried changing 474 to "local initObjName = Event.initiator:getName()" but then it complains that field "initiator" doesnt exist. Anyone know what I'm doing wrong? Edited March 2, 2019 by chrisofsweden GPU: PALIT NVIDIA RTX 3080 10GB | CPU: Intel Core i7-9700K @ 4,9GHz | RAM: 64GB DDR4 3000MHz VR: HP Reverb G2 | HOTAS: TM Warthog Throttle and Stick OS: Windows 10 22H2
Grimes Posted March 2, 2019 Posted March 2, 2019 Only guess is that the specific object type, when destroyed, fails to give the object to the event handler. Have any idea what it might be that is getting destroyed? Best bet would be to check if the object exists before running functions on it, and if it doesn't then to print out the contents of the event which might help in pinpointing what was causing the event. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
wolle Posted March 2, 2019 Posted March 2, 2019 That's simply because once a unit is dead, it doesn't exist anymore, and you can't access it. Been like that since forever, AFAIK. Makes this function completely useless. [sIGPIC][/sIGPIC] Intel Core I7 4820K @4.3 GHz, Asus P9X79 motherboard, 16 GB RAM @ 933 MHz, NVidia GTX 1070 with 8 GB VRAM, Windows 10 Pro
L39Tom Posted March 3, 2019 Posted March 3, 2019 All event handlers are bugged after one of the last updates. That bug is still reported.
Recommended Posts