Keep in mind that I'm not a very good programmer, but I at least know something. My mod manager is programmed in python, so that it's cross-platform, there's no compiling because it's an interpreted language, and because I can't for the life of me figure out how C even works. It's probably some really simple thing that I haven't realized yet, but that's beside the point. I've made a basic mod manager for Lugaru, and I'm releasing it here.
You will need to download the python interpreter for this to work. You can get it here if you don't have it, but make sure to get the 2.6 version, as I have not tested it on version 3.
I have tested this script and it SHOULD work. The key word is SHOULD. There's always a chance that something can go wrong, especially if you're running Windows or Mac, as I have not tested this script on either operating system. So, if for some reason something goes wrong, I'm not responsible.
Anyway, here is the script. Copy and paste the following text into a text file with an extension of .py and you should be good. Just make sure to follow the directions at the top of the file and to start out with a clean Data file.
UPDATES:
All listed updates are already put into the main script. The links are only there for reference.
Windows Support (and a grammatical error) fixed by Xuor
Code: Select all
#!/usr/bin/python2.6
# Script created by iLag!!!!!
# Windows support fixed by Xuor
# Released under cc-by-sa 3.0 license
# http://creativecommons.org/licenses/by-sa/3.0/
# Neither iLag nor any other contributor is responsible for any damage which might be inflicted upon your computer
# through the use of this script, even though no damage should be inflicted at all. *NOT A GUARANTEE.
# READ THROUGH EVERYTHING AND FOLLOW ALL INSTRUCTIONS UP TO THE LINE I MADE
# This script should be placed in the main Lugaru directory
# When first ran, this script will create a Mods directory if it isn't present.
# Place all of the mod folders in this directory.
# For the mod folders, make sure that the contents of the folder are in the same directory structure as the main data folder.
# That means that any the mod's textures folder (which would have its contents copied into Data/Textures) should be named Textures and
# be in the directory directly below the main mod's folder. If you don't know what I mean, then I'm sorry that I'm horrible at
# explaining things. If you can do a better job, please correct me.
# When you run this script, you'll need to run it in a console or terminal window, or else it will hang.
# In Windows, this should be automatic. In Linux w/Gnome, you can tell it to run in terminal when you launch it.
# I am unsure about other Linux Desktop Environments or Mac. Please correct me.
# One final note: If for some reason a mod doesn't work right, such as textures not working right, check the mod folder's structure.
# Chances are that the author, through no fault of his own, didn't have everything packaged just right for this script to work.
# You'll have to fix that yourself.
import os
import shutil
# IMPORTANT!!!! MAKE SURE THAT THE VARIABLE BELOW IS THE PROPER COMMAND TO LAUNCH LUGARU FROM THE DIRECTORY CONTAINING THE EXECUTABLE.
# For Windows users, it should be Lugaru.exe.
# For Linux, ./lugaru (or wine ./Lugaru.exe if you're using the windows .exe like me, which I recommend)
# For Mac, I believe that it's the same as linux, but I do not know for sure. Please correct me.
lexe="wine ./Lugaru.exe"
# Don't edit anything below this unless you know what you're doing.
#==================================================================================================
# Create the Mods dir if it doesn't exist
if not os.path.exists("./Mods/"):
os.mkdir("./Mods/")
os.chdir("./Mods/")
# Copy over the Data folder if it isn't already in the Mods folder.
if not os.path.exists("./Data/"):
shutil.move("../Data/","./Data/")
# Don't forget to move the saves to the saves folder.
# This will make the necessary folders if they don't already exist.
if not os.path.exists("../saves/"):
os.mkdir("../saves/")
if not os.path.exists("../saves/Data/"):
os.mkdir("../saves/Data/")
# If the file in question is already in the save folder, delete it if it's in the data folder.
# Otherwise, move it to the save folder.
if os.path.isfile("../saves/config.txt"):
if os.path.isfile("./Data/config.txt"):
os.remove("./Data/config.txt")
else:
shutil.move("./Data/config.txt","../saves/")
if os.path.isfile("../saves/Data/Users"):
if os.path.isfile("./Data/Users"):
os.remove("./Data/Users")
else:
shutil.move("./Data/Users","../saves/Data/")
# If for some reason the Data folder already existed in the Mods folder, assume the script crashed and
# delete the main Data folder. This SHOULD be safe. *NOT A GUARANTEE.
if os.path.exists("../Data/"):
shutil.rmtree("../Data/")
# Get mod list
a=os.listdir("./")
# Make Data appear on top
a.remove("Data")
a.append("Data")
a.reverse()
# Print the mod list, ask what you want.
b=1;
for c in a:
print str(b)+") "+c
b+=1
print "Please pick which mod you would like to load. Note that entering something"
print " other than a number will cause the mod manager to fail."
d=int(raw_input())-1
# Copy back over Data
shutil.copytree("./Data/","../Data/")
if not d==0:
# If you picked an actual mod, copy over the contents of Campaigns, Maps, and Textures.
# Sorry, but I couldn't figure out how to make python copy everything...yet.
# This WILL be changed. I promise. *IS A GUARANTEE.
shutil.copytree(a[d],"./tocopy/")
e=os.listdir("./tocopy/Campaigns/")
for f in e:
if os.path.isfile("../Data/Campaigns/"+f):
os.remove("../Data/Campaigns/"+f)
shutil.move("./tocopy/Campaigns/"+f,"../Data/Campaigns/")
e=os.listdir("./tocopy/Maps/")
for f in e:
if os.path.isfile("../Data/Maps/"+f):
os.remove("../Data/Maps/"+f)
shutil.move("./tocopy/Maps/"+f,"../Data/Maps/")
e=os.listdir("./tocopy/Textures/")
for f in e:
if os.path.isfile("../Data/Textures/"+f):
os.remove("../Data/Textures/"+f)
shutil.move("./tocopy/Textures/"+f,"../Data/Textures/")
shutil.rmtree("./tocopy/")
# Make the saves directory if it doesn't exist already, and copy over the save files if they exist.
os.chdir("../")
if not os.path.exists("./saves/"):
os.mkdir("./saves/")
if not os.path.exists("./saves/"+a[d]+"/"):
os.mkdir("./saves/"+a[d]+"/")
if os.path.isfile("./saves/config.txt"):
if os.path.isfile("./Data/config.txt"):
os.remove("./Data/config.txt")
shutil.copy2("./saves/config.txt","./Data/")
if os.path.isfile("./saves/"+a[d]+"/Users"):
if os.path.isfile("./Data/Users"):
os.remove("./Data/Users")
shutil.copy2("./saves/"+a[d]+"/Users","./Data/")
# Launch that thing!
os.system(lexe)
# Set everything back up so that the game can run.
# First, backup the saves.
if os.path.isfile("./saves/config.txt"):
os.remove("./saves/config.txt")
shutil.move("./Data/config.txt","./saves/")
if os.path.isfile("./saves/"+a[d]+"/Users"):
os.remove("./saves/"+a[d]+"/Users")
shutil.move("./Data/Users","./saves/"+a[d]+"/")
# Next, delete our modified data folder
shutil.rmtree("./Data/")
# Now move the main game and its save files back
shutil.move("./Mods/Data/","./Data/")
shutil.move("./saves/config.txt","./Data/")
if os.path.isfile("./saves/Data/Users"):
shutil.move("./saves/Data/Users","./Data")
# DONE!