Right, so I had all my custom AI scripts in data/ai/default/ and everything was groovy. Then I moved them to data/scripts/races/HWAT_generic/scripts/ and adjusted the path_ai in the props/default.lua for the relevant race to point at it, as well as changing the paths in any dofiles inside the scripts. When I test, I get log errors that only make sense if it’s still loading the original base AI, is there a step I’m missing?
So, after you posted this, I went looking… and yeah, there’s a pretty nasty error in the AI loading script (100% my fault).
The negative is that I can’t make it work without a code change, which isn’t going to happen for a while.
The positive is that we can fix it for Mods, with some careful thinking… and only script!
Here’s the steps:
1 - Copy ai/default/default.lua to ai/default/base.lua
2 - Replace ai/default/default.lua with:
s_AIPath = "Data:AI/Default/Base.lua"
s_AIPath = SelfRace_GetString("path_ai", s_AIPath)
dofilepath(s_AIPath)
In theory this allows the existing default.lua to self-override by asking if the Race of that AI has a different path it should use. Right?
Looks like it ought to work, I’ll give it a try and report back.
The redirection seems to be working, but something after it is breaking. It seems like the dofilepaths in the race-specific AI are not getting executed before oninit() is, as it crashes upon trying to execute a function from another file and trace prints from those files aren’t showing up. For that matter, prints from the body of the race’s main lua file aren’t getting executed before the ones in the oninit and the subsequent errors show up.
We may have to Skype this out - so that I can see your script and debug inline. That, or have your entire Mod local here - which is likely a much bigger pain.
The script is being loaded into the context it actually is keeping for the AI - anything you do there is ‘global’ for that AI. Certainly some things at initial load aren’t safe (init order, etc) - but certainly the dofilepaths inside of the AI should be valid and safe… and the prints should be appearing.
Got it. I’ll shelve these changes for now and roll back to a working version to work on other things. Feel free to PM me some times that’d be good for debugging sessions, I imagine your time is pretty in demand and I’m not in a hurry here.
Hey Dave,
Not saying the next update will be out soon, but any idea of what type of update will it be? I mean, focused on what or just broad?
I didn’t see it in the patch notes, but is it possible now to pass information from a level file to a gametype script? I have a table of ship names in each level file, and need to pass the table on to the gametype script to spawn the ships (depending on the gametype option). Thanks.