baking unitdefs_post

baking unitdefs_post

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

baking unitdefs_post

Post by Silentwings »

I wrote basic functionality to bake unitdefs post into the individual unitdef files. Probably it has been done before, but I couldn't find it. You can find it attached to this post.

It works by saving the entire unitdef table into ud.customParams as a string, and then unpacking it and writing to file from LuaUI, because there is no io access from unitdefs_post. It doesn't handle OO unitdefs (in the style of e.g. S44), but it wouldn't be hard to modify it to do so.

update: BA 8.19+ contains a more complicated version of this system, which also has the ability to bake weapondefs, allowing for unitdef files which contain weapondefs.

Instructions:

(1) Put unitdefs_post_save_to_customparams.lua in gamedata
(2) Put unitdefs_write.lua in widgets
(3) Add VFS.Include("gamedata/unitdefs_post_save_to_customparams.lua") to unitdefs_post, at the point where you want to bake
(4) Load Spring, then load the widget
(5) Look in the spring folder, unitdefs should all be written to file, cut/paste these over the original files.
(6) Clean out the stuff you just baked into unitdefs from your unitdefs_post.lua.

Notes:
! Make sure your unitdefs don't contain lua keywords as table keys (remove them with unitdefs_post if so)
! Make sure you don't bake in any modoptions that alter unitdefs
! It will round all numbers to 5dp and then remove trailing 0s after the decimal point, to avoid e.g. 0==0.000000234876
! It will convert all string keys to lower case
! It won't bake weapondefs_post (make the changes in unitdefs_post and bake that instead)
Attachments
unitdefs_write.lua
(5.79 KiB) Downloaded 15 times
unitdefs_post_save_to_customparams.lua
(1.31 KiB) Downloaded 10 times
Post Reply

Return to “Game Development”