I am trying to find a way to create a custom ai lua file that I call in a scenario to the vehicle lua. The file would be called customai.lua. I don't see a easy way to make this work without calling the file ai.lua. If I name the file other than the default ai.lua it gives an error that it cannot find global customai. Any suggestions or ideas would be helpful. Also if updateGFX(dt) is per graphics update. What is onPreRender(dt) and which one is better for running ai steering and throttle?
The only reference I can suggest is the Airfield Showdown scenario, I know that uses a custom AI script (still official, though). As far as I'm aware, onPreRender is called only once while the level is loading. Don't quote me on that, though.
Good find on the Airfield Showdown scenario. I put my custom ai lua file in the lua\vehicle\extensions\ folder and call it from the scenario using helper.queueLuaCommandByName('AIName', 'customai.go()'). It gives the same error that it cannot find the global customai file. onPreRender is called more than once but it seems to be called less than the updateGFX(dt).
Might have this figured out. So what I did was set a call to the vehicle lua in my scenario to load the extension. helper.queueLuaCommandByName(vName, 'extensions.load("customai")')