Testing and Debugging best practices

Szpilman

Void Co. Chairman
Joined
Dec 2, 2006
Messages
746
Location
Cola
I'm diving headfirst into Civ modding, learning and loving every bit of it.
I can say my biggest bottlenecks at this point are testing and especially debugging, so I wanted to make a thread to share best practices on how to do those efficiently.

To kickstart the sharing:
  • I had heard prior to launch about database changes on the fly, how does that work? I'm currently booting up Civ over again for every tweak ("ok, NOW it should work..") for lack of knowing a better method.
  • About debugging with the Tuner, how to setup breakpoints (I saw a setting in config.ini) and how to best setup Lua dumps into the console?
Hoping to be enlightened,
Be Szpilman
 
Some things I've been doing for testing and debugging are:

Lots of simple print() statements in lua files during early development, and keeping Tuner open on another display to watch the console.

Tuner can be used to make changes to the database on the fly, either through the various tabs to affect standard things, or by using the console to directly make DB calls (I haven't actually tried this though).
 
also if your doing stuff like adding civilizations, units, anything you can plop down with WB, then you don't need to load up the full game to make sure it is at least recognizing your new content.... you can do that with WB.
 
Thanks for the tips, guy! I'll keep WorldBuilder in mind when it's possible testing through it (had never thought about it, really), and directly making calls to DB with Tuner sounds great, hopefully someone will come up with a comprehensive tutorial on it :)

Just read in Kael's manual, under Troubleshooting, about the \My Games\Sid Meier's Civilization 5\Logs\ folder. What's there is probably also told you real time on Tuner (no?) but it's a helpful tool nonetheless.

Another tip is to not fully exit Civ 5 if you are planning on doing a few iterations of debugging. Instead, exit to main menu, then rebuild and reload your mod without waiting for the intro movie and such again. I also keep a simple small saved game to load instead of waiting for another world to be set up in a new game.

When it's UI changes, maybe, but not only are savegames not compatible if you make any gameplay changes, I also can't seem to be able to iterate by just exiting to main menu. If I rebuild, then Mod Browser won't even detect that mod anymore until I leave the game and start it up again. And it's 16 damn seconds :)
 
Thanks for this info, I didn't try the debugger yet - but these tips will be very useful =]

Szpilman, about the on-the-fly database commits I don't think they will be simple, only if we get access to the functions (probably c++?) that does this. I did some tests and this is done exactly at the point where the user hits SINGLE PLAYER subitem on MODS menu (the one with SINGLE PLAYER and BROWSE MODS).
 
I did some tests and this is done exactly at the point where the user hits SINGLE PLAYER subitem on MODS menu (the one with SINGLE PLAYER and BROWSE MODS).

You mean the on-the-fly database commits, or the loading of the mod making it possible to iterate without leaving the game?

I have just tried all possible paths to being able to rebuild and test a new iteration without starting the game again, and haven't been successful. I'm making gameplay changes, and it seems they only load up again if I go through the annoying intro video (skipped on UserSettings.ini, but still 16 seconds of black screen). Today I have been doing some heavy testing and boy is it a pain.
 
You mean the on-the-fly database commits, or the loading of the mod making it possible to iterate without leaving the game?

Hm, now I don't know if it'll redo the commits if you go all the way out to main menu and MODS > SINGLE PLAYER again. I forgot the fact the .xml and .sql files must be reloaded too, flying high here :)

I said that because every step I made since starting the game I went check the sqlite, and the commits were made at that step. I'll do a simple test here to see if one work-around works out.. around and out :p
 
tested here and, if you do like this:
  • after built the mod on ModBuddy, fire Civ V, MODS > BROWSE MODS, enable it (as we always have to do, since it's automatically disabled after rebuilt)
  • next, as soon as you go MODS > SINGLE PLAYER, the mod will be loaded and will commit changes on database.
  • directly after that (you don't need to go anywhere, start a game, nothing), go to ModBuddy, change anything to database and rebuild the mod
  • ingame, go to MODS > BROWSE. The mod will be disabled again, enable it.
  • if you go MODS > SINGLE PLAYER again, the mod will be reloaded and will commit the new changes on database.
I don't know if that was what are you looking for. I guess the ideal will be (if possible) when we can rebuild mods inside a game session but, I think that depends strictly on the game core, we'll have to see if there's a possible way through Lua (probably not) or C++ (when it's released).

EDIT: sorry the double post, I couldn't edit while the 'server was busy' here
 
Back
Top Bottom