ZeroK-RTS / Zero-K

Open source RTS game running on the Spring/Recoil engine
https://zero-k.info
GNU General Public License v2.0
690 stars 206 forks source link

Unit renamer utility #4471

Open Sharkgamedev opened 3 years ago

Sharkgamedev commented 3 years ago

Model names are a little spaghetti. Perhaps if somebody (aka I would try my hand at it) were to make a Lua utility (like buildicon generator) to rename the models based on the unitscripts wider adoption would be possible? It would be relatively low effort to run such a thing on the most popular mods and every other mod owner could run it on their own? Would this be a good idea and would it even be worth it?

sprunk commented 1 year ago

If "a Lua utility (like buildicon generator)" means it would be something to run from ingame then I'm not sure how viable that is from a technical PoV (a mod/game doesn't actually know where the model files are located or whether they are even individual files that could be renamed - they could be an archive or a distributed pool).

Some script to run manually in a mod's development repository would probably be fine, but then the issue is making sure people are running something fresh and relevant (as opposed to, say, a 3 year old version of the script they just had lying around).

GoogleFrog commented 1 year ago

Maybe a python script? It would be nice to make the names make sense.

Sharkgamedev commented 1 year ago

I'm drafting up a python script, but another thought that occurs to me-javascript/nodejs? This way we could just instruct end users to run a npx run package which would ensure they always have the latest version too.

I don't love this idea and am moving forward with the python script for now because:

Regardless I figured Id mention it as an option.

sprunk commented 1 year ago

How is the script going to look? There's two approaches of what a mod must do if baseline vanilla ZK renames models.

Approach A: copy-paste models into the mod repo, under the old name. In this case the script could be as simple as (shell):

cd $ZK
git checkout $LAST_COMMIT_BEFORE_RENAME
cp $ZK/Objects3d/{foo,bar,baz}.s3o  $MOD/Objects3d
cp $ZK/unittextures/{foo,baz,quux}.tga $MOD/unittextures

Approach B: rename the references. This may be as simple as (also shell)

find $MOD -iname "*.lua" -print0 | xargs -0 sed -i 's/foo.s3o/new_foo.s3o/g'
find $MOD -iname "*.lua" -print0 | xargs -0 sed -i 's/bar.s3o/new_bar.s3o/g'
find $MOD -iname "*.lua" -print0 | xargs -0 sed -i 's/quux.s3o/new_quux.s3o/g'
Sharkgamedev commented 1 year ago

How is the script going to look? There's two approaches of what a mod must do if baseline vanilla ZK renames models.

Approach A: copy-paste models into the mod repo, under the old name. In this case the script could be as simple as (shell):


cd $ZK

git checkout $LAST_COMMIT_BEFORE_RENAME

cp $ZK/Objects3d/{foo,bar,baz}.s3o  $MOD/Objects3d

cp $ZK/unittextures/{foo,baz,quux}.tga $MOD/unittextures

Approach B: rename the references. This may be as simple as (also shell)


find $MOD -iname "*.lua" -print0 | xargs -0 sed -i 's/foo.s3o/new_foo.s3o/g'

find $MOD -iname "*.lua" -print0 | xargs -0 sed -i 's/bar.s3o/new_bar.s3o/g'

find $MOD -iname "*.lua" -print0 | xargs -0 sed -i 's/quux.s3o/new_quux.s3o/g'

I was in favour of approach B but whatever people think is best. Also - a shell script is a great idea being more portable then requiring a python install, also a thought on outdated scripts, we could always instruct modauthors to curl the script from the repo each time in whatever documentation gets written up.

sprunk commented 1 year ago

We could also just rename all the models at once, so an obsolete script would not be a problem because then there wouldn't be any mass-scale model renaming afterwards.

Sharkgamedev commented 1 year ago

Yes probably quite unnecessarily complex.

Im good with just mass renaming and calling it a day if there are no qualms?

GoogleFrog commented 1 year ago

I prefer python and something standalone.