I made a scenario where i have multiple prop cars. I want to make the car turn off. I could see people use "command":"electrics.toggle_ignition()", but it wont work for me and in the scenarios it is used in. I dont want to make another .pc file for this with no engine or something. I attached the file, the console is giving errors so it reacts to the code. I searched for this problem but i didnt find anything. But if someone asked it before me then Im sorry and please link it. Thank You!
Today i saw a thread where someone said this: powertrain.getDevice("mainEngine"):setIgnition(0) will turrn of the cars engine. I put it vehicle lua in console and it works. But how to execute it for the prop car when the scenario starts? So how to execute lua command for just one specified vehicle? Sorry, clearing things up: How to make a car (NOT PLAYER CAR) in a scenario shut off instantly with lua or the json.
You can queue a vehicle lua command in the scenario lua by using the command : helper.queueLuaCommandByName('vehicleName', 'vehicleLuaCommand'), after importing the scenario helper (local helper = require('scenario/scenariohelper')) This would give a code like this (save this text as yourScenarioNameHere.lua in the same folder as your scenario .json) Code: local M = {} local helper = require('scenario/scenariohelper') local function shutdownEngines() helper.queueLuaCommandByName('scenario_vehicle0', 'powertrain.getDevice("mainEngine"):setIgnition(0)') -- shutdown the engine for scenario_vehicle0 end M.onScenarioRestarted = shutdownEngines M.onScenarioLoaded = shutdownEngines return M You'll just need to duplicate the queueLuaCommandByName line as much as you have vehicles to shut down
Oh this makes much more sense than what I wrote. I'll try it out when I got computer near again after school. Thank you for your answer!
I got home, tried it and worked perfectly!!! Thank you! Now i just have to recreate everything that lost in the file transfering between the new windows and the old one... I hope nothing like this problem comes up again and i can finish this little story.