Custom AI in Scenario

Discussion in 'Programming' started by bidwars, Apr 27, 2018.

  1. bidwars

    bidwars
    Expand Collapse

    Joined:
    Sep 23, 2014
    Messages:
    171
    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?
     
  2. Occam's Razer

    Occam's Razer
    Expand Collapse

    Joined:
    Aug 7, 2013
    Messages:
    1,152
    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.
     
  3. bidwars

    bidwars
    Expand Collapse

    Joined:
    Sep 23, 2014
    Messages:
    171
    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).
     
  4. bidwars

    bidwars
    Expand Collapse

    Joined:
    Sep 23, 2014
    Messages:
    171
    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")')
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice