We have the option to communicate from gelua to vlua using mailboxes, but I was not able to figure this out the other way around. Maybe I am stuck somewhere else. Here is some context of what I want to achieve: On the event onInventoryPreRemoveVehicleObject I want to store the current beamstate of the vehicle using beamstate.save() However veh:queueLuaCommand() seems to put that command at the end of the execution stack which will then cause the vehicle being removed BEFORE this command could be issued. Is there a way to call this function without using queueLuaCommand() by direcly accessing vlua? Basically I want to communicate that beamstate.save() is done and then continue with the processing inside gelua. Even more context: source
Unfortunately that is "asynchronous" or queued, rather. I mean it's the same method just the other way around. If you have your code like this: print("A") obj:queueGameEngineLua('print("B")') print("C") The output will be A C B which is not ideal for my case. I am hooking into an event where I want to save the vehicle state. After the event callback is finished the vehicle will be removed. Meaning if I use the method above, the vehicle saving will be queued, then the vehicle gets removed and after that it will be saved (which obviousely fails) Maybe I misunderstood your answer.
Oh okay, so i misunderstood your question. Sorry, i don't know how to help,but usually some people on the Modding for Dummies discord know a bit better, so i recommend you ask there maybe --- Post updated --- And have you tried making it wait for your command to finish before unloading somehow? That would fix the async issue i would guess
Yes, usually I would implement something along the lines of: Code: M.isCompleted = false local function checkIsCompleted() while not M.isCompleted do --busy wait end end local function run() object:queueLuaCommand("myModule.isCompleted = true") checkIsCompleted() end But this will never terminate. I would need a proper method of communicating between veh and ge Unfortunately I don't use discord anymore, so I have to stick to the forums
t I do think it is probably possible by using coroutines, with beam's job system and some callback. Im sorry that i dont have an exact solution, but its probably worth looking into that. If that doesn't work, it is probably not possible, at least not by hooking onInventoryPreRemoveVehicleObject
I managed to work around this issue by overwriting the function that removes the vehicles with my own function. I then call the original function afterwards. For reference: source code Thanks for your help!