Linux/mac script for renaming a unit in game code

Linux/mac script for renaming a unit in game code

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
yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

Linux/mac script for renaming a unit in game code

Post by yanom »

I put together this shell script (runs on Linux and Mac) that will go through all your game files and attempt to rename a unit. It will rename all appropriate files and go through all your files and replace all instances of the old unit name with the new name.

Code: Select all

Disclaimer - this works for me, but YMMV. Back up your data before trying this.
save this program as "renameUnit.sh" and place it inside your mod's folder.

Code: Select all

for file in `find . -name "*.lua"`
do
	sed -i "s/$1/$2/g" $file
done

for file in `find . -name "*.s3o"`
do
        sed -i "s/$1/$2/g" $file
done


for infile in `find . \( ! -regex '.*/\..*' \)`
do 
	newname=`echo $infile | sed "s/$1/$2/"`
	if [ "$infile" != "$newname" ]
	then 
		mv $infile $newname
		#### ^^^ important! ^^^
		#if you use a version-control system like SVN or Git,
		# change that line to from "mv" to "git mv", 
		# "svn mv", or whatever your VCS requires.
		####
	fi
done
run it like:

Code: Select all

 ./renameUnit.sh oldunitname newunitname 
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Linux/mac script for renaming a unit in game code

Post by knorke »

from what I understand it renames the .s3o file but not the texture?
(the link to texture would have to to be changed in the s3o file as well)
yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

Re: Linux/mac script for renaming a unit in game code

Post by yanom »

renames everything. edits .lua and .s3o files to change the name. thus it changes the texure filename and the link to the texture
Post Reply

Return to “Game Development”