View topic - Linux/mac script for renaming a unit in game code



All times are UTC + 1 hour


Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: 12 Sep 2012, 23:02 

Joined: 10 Jul 2009, 22:34
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:
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:
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:
 ./renameUnit.sh oldunitname newunitname


Top
 Offline Profile  
 
PostPosted: 14 Sep 2012, 13:48 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
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)


Top
 Offline Profile  
 
PostPosted: 14 Sep 2012, 15:59 

Joined: 10 Jul 2009, 22:34
renames everything. edits .lua and .s3o files to change the name. thus it changes the texure filename and the link to the texture


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Site layout created by Roflcopter et al.