View Full Version : BtS Mod Install Script


phungus420
Sep 25, 2008, 10:42 AM
BtS Mod Install Script with Icon and optional Add On scripting (http://forums.civfanatics.com/downloads.php?do=file&id=12230)
BtS Mod Install Script with Icon scripting (http://forums.civfanatics.com/downloads.php?do=file&id=12229)
BtS Mod Install Script (http://forums.civfanatics.com/downloads.php?do=file&id=11887)
BtS Mod Patching Script (http://forums.civfanatics.com/downloads.php?do=file&id=12060)

To use these scripts download and install the free program NSIS installer, found here:
http://nsis.sourceforge.net/Download


What these Scripts do:

The install scripts make it so any person can simply double click on the .exe you create and automatically installs your mod. No complex instructions for people wanting to use your mod. More importantly, it automatically creates optional shortcuts to launch your mod from the desktop and Start Menu. So that people wol't need to decide to change their main ini file, or load the mod at each start up. They can simply click on the desktop shortcut it creates to launch your mod. The Icon Script includes scripting so that you can make your setup installer have a unique icon, the shortcuts that lauch the mod will also use the icon (looks professional :)). In addition to these functions the Optional Add On script includes scripting so that you may include optional Add Ons along with the installation of your mod.

The install scripts include Uninstall scripting, so that when you update to a full new version, the previous version of your mod is automatically uninstalled before installation. This is to remove old files that may conflict, as happens when mods are updated on occasion. Also just makes things neat and tidy. If this is the first time you use one of these installers, have your users install twice to remove the old version (it triggers off of the regkey the installer writes, and uses the uninstaller it creates, if you haven't used the script before, neither of these exist yet, they are created on the first install. --On the second install everything in the mod folder will be removed as per the uninstall script, removing any left over files from previous versions). After the uninstaller finishes removing old files, the installation procedes to install the mod.

The patch script is set up to simply patch a mod to a higher version.

Instructions:

-Download the script you would like to use. Read the script's directions on the download page.
-Download & Install NSIS installer program (free program)
-Follow the instructions for the script
-Load the script in NSIS, and run it

These have been updated and are now well commented as of the 4th of July 2009. The 4th of July updates to the scripting code streamline and improve the uninstaller, especially for icons, where the original scripting did not link the icons correctly to shortcuts. So if you are using prior versions of the script it is recommended you update.

You will need no knowledge of coding to use these, anyone that is computer proficient enough to make a mod for Civ4, even a simple XML mod, should be able to follow the directions and use these scripts with ease. Well the optional Add On script is slightly more complex, you might need rudimentary coding knowledge to use it or at the very least good common sense.

Thanks to John Elcard for supplying the original template script, and Snarko for helping me on IRC to get this thing working way back in the day, when this was confusing stuff to me. Also thanks to NikNaks for updating the script with more functionality (Optional Add ons and icon scripting, though I had to clean up some of his code ;))

JEELEN
Sep 30, 2008, 02:16 PM
Sounds interesting. May use it for the next MOO2Civ patch.;)

phungus420
Mar 06, 2009, 10:40 PM
Updated to new version. Now includes uninstaller scripting, and will automatically remove old versions (provided it has already installed once with the uninstall information--If you start using this and want it to uninstall a previous version for your users before this script was used, just have them install it twice).

When it's done compiling, NSIS gives a warning, something about MUI header text. I can't find any error in the code though, and all the text and fuctions work fine (used this script and checked it 3 times now). So I have no idea what the warning is about, but the script still works with no problems.

phungus420
Mar 30, 2009, 05:35 PM
Added patching script so that modmakers who use this script can release patches that easy install, without triggering the Uninstaller that is in the main Mod installer script.

Also has anyone used either of these?

The_J
Mar 31, 2009, 12:07 PM
I wanted to use the installer, but i can't :(.

There's a hard-coded folder "program files" in it, so it can't really be used for windows versions in other languages :(.

phungus420
Mar 31, 2009, 01:11 PM
Yeah, I can't use the BTS registry key to find the files for compression. I tried using the BTSREGKEY, and various ways the script uses this to install to the correct path when the installer runs to install. But when the script is compiling, and looking for the files to compress, I can't use this. So for you, and other modmakers that have a different path (foriegn language/vista etc.) in which your mod is in, you need to adjust this, along with the name of your mod:

!define NAME "MYMODNAME"
!define VERSION "X.X.X"
!define MOD_NAME "MYMODNAME" ;Example for WolfRevolution this is the same, so I use ${NAME} here, but if you call your mod something different then the name of the folder, note this here.

!define BTSREGKEY "SOFTWARE\Firaxis Games\Sid Meier's Civilization 4 - Beyond the Sword"

!define MYBTSDIR "C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword"
!define MYCLSDIR "C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\${MOD_NAME}"

Just change the bolded part of the script to the path that your mod is found in, and it should work. Let me know if it doesn't work, it should, I can't see how it wouldn't.

The_J
Mar 31, 2009, 02:37 PM
But the problem is, it has to work with english, german and more languages, not only one :(.

phungus420
Mar 31, 2009, 03:53 PM
Ah, I see, you want the Text displayed to be printed in german as well as english? Yeah, I don't know how to do that. Sorry. I bet it's pretty simple though, I know NSIS supports multiple languages, you'd have to browse the NSIS installer information pages, I had to do alot of that to get this script working, lol. But yeah, I'd like to support other languages, but it's not at the top of my list of things to do.... That said if you do get another language supported on this script, please release it, I'd update this one with the bilingual functionality.

The_J
Apr 01, 2009, 03:43 PM
No, that's not the problem, atm my installer text is in english.

The problem is, that i would need 1 installer, which would install the mod on english windows versions in the C:\program files\...path, but on german computers in the C:\Programme\...path, and it seems, that it can't be done with this script :(.

phungus420
Apr 01, 2009, 04:43 PM
Are you sure? The installation should follow the registry on the machine it installs on, it should install wherever BtS has been assigned to, regardless of language or operating system. So long as BTS has signed itself on the Registry key, the installation should follow that path, weather it be program or programme. I see nothing in the script that should limit it. The install directory is defined here:

;Default installation folder
InstallDir ""

;Get installation folder from registry if available
InstallDirRegKey HKLM "${BTSREGKEY}" "INSTALLDIR"

I tried to use this to locate the files to compress though, but it wouldn't let me, the MYCLSDIR & MYBTSDIR have to be set manually if they are different.

Anyway, I've never had anyone say the installation failed, and I'm pretty sure there have been a few foriegn users of it with the WolfRevolution that would have let me know if the installation failed.

The_J
Apr 02, 2009, 01:03 PM
Oh, didn't see that.
I've opened the file, saw the "program files", and just thought "damn".
I'll try it next time :).

The_J
Apr 04, 2009, 07:00 PM
Okay, i've tested it now, it works.
Compressionrate is like with WinZip :).

My problem was, that i didn't change MYBTSDIR and MYCLSDIR :blush:.

I'll use it, when i upload the next version of my mod :).

I wonder, if it could also be used for patchs. Do you use it for patchs, or do you think, that it can be used?

phungus420
Apr 04, 2009, 07:05 PM
There are two scripts there. One is for patching, the other is for full versions. The full version one signs the mod to the registry and creates an uninstaller. It also is set up so that when the mod is reinstalled, ie you up the version#, it automatically uninstalls the previous version. The patch version does niether of these things, and simple adds/overwrites files from a previous version. You need to move your full mod from it's folder, and put the patching files in the folder where your mod usually is (following the same pathing structure as your main mod) when compiling the patch script, as it basically uses the same script as the full install version and thus finds and compresses the mod and it's files from it's normal folder (the only difference is that the patching version does not trigger or create an uninstall)

The_J
Apr 04, 2009, 07:11 PM
I'm such an idiot, i should have looked at the starting post again :wallbash:.

Thanks for the answer :), i'll also give this a try.

phungus420
Apr 04, 2009, 07:37 PM
Hey no problem, thanks for bringing up the issue that the script doesn't follow the regkey when searching for the files to compress when it compiles, I didn't realize this until you brought it up, so hopefully that makes this script useable for more folks, as now they know to change the MYBTSDIR and MYCLSDIR paths when using this script.

NikNaks
Apr 05, 2009, 08:29 AM
Ok, I'm trying to use this for my Native America add-on for VD, but it throws out an error at line 64 (the uninstall part) when I try to compile:
MakeNSIS v2.44 - Copyright 1995-2009 Contributors
See the file COPYING for license details.
Credits can be found in the Users Manual.

Processing config:
Processing plugin dlls: "C:\Program Files\NSIS\Plugins\*.dll"
- AdvSplash::show
- Banner::destroy
- Banner::getWindow
- Banner::show
- BgImage::AddImage
- BgImage::AddText
- BgImage::Clear
- BgImage::Destroy
- BgImage::Redraw
- BgImage::SetBg
- BgImage::SetReturn
- BgImage::Sound
- Dialer::AttemptConnect
- Dialer::AutodialHangup
- Dialer::AutodialOnline
- Dialer::AutodialUnattended
- Dialer::GetConnectedState
- InstallOptions::dialog
- InstallOptions::initDialog
- InstallOptions::show
- LangDLL::LangDialog
- Math::Script
- NSISdl::download
- NSISdl::download_quiet
- Splash::show
- StartMenu::Init
- StartMenu::Select
- StartMenu::Show
- System::Alloc
- System::Call
- System::Copy
- System::Free
- System::Get
- System::Int64Op
- System::Store
- TypeLib::GetLibVersion
- TypeLib::Register
- TypeLib::UnRegister
- UserInfo::GetAccountType
- UserInfo::GetName
- UserInfo::GetOriginalAccountType
- VPatch::GetFileCRC32
- VPatch::GetFileMD5
- VPatch::vpatchfile
- nsDialogs::Create
- nsDialogs::CreateControl
- nsDialogs::CreateItem
- nsDialogs::CreateTimer
- nsDialogs::GetUserData
- nsDialogs::KillTimer
- nsDialogs::OnBack
- nsDialogs::OnChange
- nsDialogs::OnClick
- nsDialogs::OnNotify
- nsDialogs::SelectFileDialog
- nsDialogs::SelectFolderDialog
- nsDialogs::SetRTL
- nsDialogs::SetUserData
- nsDialogs::Show
- nsExec::Exec
- nsExec::ExecToLog
- nsExec::ExecToStack

!define: "MUI_INSERT_NSISCONF"=""

Changing directory to: "C:\Coding\Civ\New Civs\Native America"

Processing script file: "C:\Coding\Civ\New Civs\Native America\BtSModInstallScript.nsi"
!include: "C:\Program Files\NSIS\Include\MUI2.nsh"
!include: "C:\Program Files\NSIS\Contrib\Modern UI 2\MUI2.nsh"
NSIS Modern User Interface version 2.0 - Copyright 2002-2009 Joost Verburg (C:\Program Files\NSIS\Contrib\Modern UI 2\MUI2.nsh:8)
!define: "MUI_INCLUDED"=""
!define: "MUI_SYSVERSION"="2.0"
!define: "MUI_VERBOSE"="3"
!include: closed: "C:\Program Files\NSIS\Contrib\Modern UI 2\MUI2.nsh"
!include: closed: "C:\Program Files\NSIS\Include\MUI2.nsh"
!define: "NAME"="Native America Expanded for VD 5.1"
!define: "VERSION"="2.0"
!define: "MOD_NAME"="Varietas Delectat"
!define: "MOD_LOC"="Native America"
!define: "BTSREGKEY"="SOFTWARE\Firaxis Games\Sid Meier's Civilization 4 - Beyond the Sword"
!define: "MYBTSDIR"="C:\Games\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword"
!define: "MYCLSDIR"="C:\Games\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Native America"
Name: "Varietas Delectat"
OutFile: "Native America Expanded for VD 5.1 v2.0.exe"
InstallDir: ""
InstallRegKey: "HKLM\SOFTWARE\Firaxis Games\Sid Meier's Civilization 4 - Beyond the Sword\INSTALLDIR"
Var: "INSTDIR1"
Var: "CurrentPage"
Function: ".onInit"
ReadRegStr $R0 HKLM\Software\Microsoft\Windows\CurrentVersion\Uni nstall\Varietas Delectat\UninstallString
StrCmp "$R0" "" equal=done, nonequal=
MessageBox: 49: "Native America Expanded for VD 5.1 is already installed.

Click `OK` to remove the previous version or `Cancel` to cancel this upgrade." (on IDOK goto uninst)
Abort: ""
ClearErrors
Exec expects 1 parameters, got 2.
Usage: Exec command_line
Error in script "C:\Coding\Civ\New Civs\Native America\BtSModInstallScript.nsi" on line 64 -- aborting creation process
No clue why. I've happily changed my BtS location to where it is and my files are where the script says they should be (although I have defined it to be somewhere slightly different), and yet I get this error. Have you seen this before?

phungus420
Apr 05, 2009, 11:55 AM
I just :dunno: I just tested it again, and can't replicate the error. Since you said you defined things slightly differently, I tried having the script run by compiling the mod if I place it on the desktop and it fails, not sure why, but it does... But it throws an error in a different part. Btw, that's a really odd spot to get an error, as line 64 is a blank line:

;Run the uninstaller
uninst:
ClearErrors
Exec $INSTDIR\Mods\${MOD_NAME}\uninstall.exe
;This is where line 64 is
done:

FunctionEnd

NikNaks
Apr 05, 2009, 12:02 PM
Yeah, I thought it looked odd. However, I added another variable to the top, so my 64 will be 63 (the Exec $INST... line). Do you think where the script itself is run from has anything to do with it? I have it in a folder a way away from where the mod itself is.

phungus420
Apr 05, 2009, 12:09 PM
No, i run the script from the desktop. That's a pretty simple line too, you can probably read it as well as I can, all it's saying is "Run the the Uninstaller.exe in the folder, if you find one" ie, uninstall old version, it's pretty straightforward. The only thing I think could be causing an error is if you've moved the mod outside of it's expected path and are compiling from there (ie you've moved it from ...program files/.../mods/ ) This uninstall part of the script is being told to apply to a spot it's not expecting to fire from and so you get an error, this part of the script is definatly following the reg key though, so it shouldn't be machine specific, and I can't see why it would fail at all, so long as the compiler detects a BTSRegKey on your computer. Other then that, I can't think of anything that could cause an error on that line. I suppose it's possible that your NSIS version is missing a key definition or something, maybe it doesn't understand the uninstall execute command? I don't know why that would be the case, I use the same NSIS version that's found on sourceforge as anyone else, and I'd assume you are as well.

NikNaks
Apr 05, 2009, 01:59 PM
Aha! It was a simple matter of placing quotation marks around the folder after "exec". Perhaps they've changed the syntax in a more recent version. Everything else is working perfectly, so thanks! :goodjob:

I have a few questions, too. I'm not too worried if you don't know the answers, but it'd but the icing on the proverbial cake for my little installer. If there are some reference guides for NSIS, I'd love to see those, too.
Can you set up a custom icon for the desktop shortcut? Is there a way to split the mod into two parts, one of which is required by default, with the other being an optional add-on? (This is the toughest one) Can the installer be made to detect a pre-existing mod and abort if it's not found? My mod is for VD 5.1, so if it isn't there, I don't want people to install it and not understand why it doesn't work. If there's no way of doing this, could I put a text warning in somehow?

phungus420
Apr 05, 2009, 04:04 PM
Yeah, you can do all of those things. The optional add on is something I actually removed from the template script I used from Jean Elcard, so it should be trivial to set it up, as the script is already written with optional install options in mind (just none of them exist in current form). The icon one is something I will add to this script eventually (and also make it so that the shortcut will use that icon). I'm not exactly sure how to do it, it's in the tutorials guide though. If you do add this effect, please share the improved script, and I'll update this one so that the script does it, basically just add a third script that uses an icon to the download database.

Icon example shortcut (http://nsis.sourceforge.net/Many_Icons_Many_shortcuts)
The above link also takes you to the main reference link for NSIS scripting, so you can browse that to figure out how to do the the other things.

Again though, if you do add these functions please share them, in a way that is easily understandable, so I can update these for other modmakers (and use the icon making one myself, as it's one of the tools I plan to add to my script anyway).

NikNaks
Apr 06, 2009, 09:19 AM
Okay, I've been messing around with it today, and have added the following features:
Optional start menu shortcut that will install in the same folder as the BtS ones (but if you've moved it from its original location, it doesn't work - could definitely work better) Optional quick launch shortcut Use your own icon simply by putting it inside your mod folder with the same name as your mod (looks poor if none included - is there a way to avoid this?) The core of the mod is now always installed (cannot be turned off) "Short name" variable that is used as the main title in case the mod name is too long (defined as the mod name by default) Extra version for use if mod has multiple parts to it (example also included)
This does require your mod to be split into two folders in the correct directory, which may look odd if you're doing it inside the Mods folder, as it won't work if you try to play it as a modI think that's all. My version is a little more complicated, but so long as you don't mess with anything, there shouldn't be a problem. I've included my sample script for the Native America Expanded mod so that you can see how to edit it if necessary.

Download here (http://forums.civfanatics.com/downloads.php?do=file&id=12104)

I'm pretty pleased with how it's looking, although there are always ways to improve it

NikNaks
Apr 11, 2009, 08:27 AM
Has anyone tried out the updated version? Any comments?

The_J
Apr 11, 2009, 10:23 AM
Not yet, but i'll sure use it :).

NikNaks
Apr 17, 2009, 10:05 AM
Phungus, do you have any comments? This is really your script, so I'm waiting to see what you think before making more additions. I already have a new edit in the works which moves the shortcut creation to different screens, and allows you to pick your own start menu folder.

phungus420
Apr 17, 2009, 11:59 AM
Hmmm, I need an icon for Bronze Steam and Tears to test it... Sorry I haven't responded earlier, I've been aware of your improvements to the script for some time, just haven't had a real means to test it, and was thus procrastinating. I'll work in using this later today, or early tomarrow. Also don't hold back a new and superior version just because I'm procrastinating.

avain
Apr 17, 2009, 01:08 PM
Has anyone tried out the updated version? Any comments?

I just tried it out and I like it. I needed to change some minor things, but it works like charm. The only issue might be that it generates a bit bigger file than a mere 7zip. But it's sure nice!
Thank you!:goodjob:

NikNaks
Apr 18, 2009, 01:50 AM
Great! :goodjob: Out of interest, what did you change?

The_J
Apr 19, 2009, 02:49 PM
I'm using the patch script for my current patch :).

avain
Apr 20, 2009, 02:23 AM
Great! :goodjob: Out of interest, what did you change?

Just customizing, as it turns out.;)

phungus420
Apr 20, 2009, 04:34 PM
Finally getting around to using the improved version. Seems to work OK, it's a little overly complex I think with all the variables at the begging of the script, otherwise seems good.

One thing though, How can I get it so that the installer uses the icon for the shortcut and stuff for the installer itself? The installer still uses the NSIS icon, but I know it's possible to have it use your shortcut icon for the main installer, and would probably look best like that.

phungus420
Apr 22, 2009, 05:47 AM
Updated OP. New scripts included. Also all the scripts have been cleaned up and added some comments to the scripts to make them very user friendly. You should be able to use these scripts even if you have no knowledge of programming, the comments should direct you on what to do, and there are only a couple entries that need to be changed so that the script will apply to a specific mod. The optional add on script is a little more complex though, you might need a rudimentary knowledge of code, or at least have good common sense to use it.

Another note, cleaned up some of the code of the script, and added delay function on uninstaller. The uninstaller now must finish before proceeding to the installation if the full install is being updated to a new version.

phungus420
Apr 23, 2009, 08:08 AM
Some technical details. The scripts all work well, but I have a nitpicky thing I'm trying to solve. NikNaks or anyone else who's good with scripting language:
I haven't been able to get the Start Menu shortcut to work unless I don't put it in a path. If I just use
"$SMPROGRAMS\${NAME}.lnk"
It works fine, however if when I try to get it to post the shortcut in a group (I'd like it to be with the main Civ4 launch icon), it doesn't work. I've tried everything, anything like this just fails:
"$SMPROGRAMS\AnyGroupName\${NAME}.lnk"
I can't figure it out. This is why I removed that information from your scripting NikNaks, the start menu shortcut never apeared, so I had to cut it back to the bear minimum path to make it show up. Is this a problem with my computer or something? I've tried updating my NSIS installer to the most recent version, and looked around on the internet, but according to all the scripting examples, I'm defining the path correctly, it's just not working :dunno:

NikNaks
Apr 23, 2009, 02:12 PM
Well the new script has a different way of creating those shortcuts so it should be fine :)

phungus420
Apr 23, 2009, 07:44 PM
What I'm saying is:

Section "Start Menu Shortcut" Section4
CreateShortCut "$SMPROGRAMS\Firaxis Games\Sid Meier's Civilization 4 - Beyond the Sword\${NAME}.lnk" "$INSTDIR1\Civ4BeyondSword.exe" "mod=\${MOD_LOC}" "${MYCLSDIR}\${NAME}.ico" 0
SectionEnd
Doesn't work for me, the shortcut never gets created in the start menu.

However:
Section "Start Menu Shortcut" Section4
CreateShortCut "$SMPROGRAMS\${NAME}.lnk" "$INSTDIR1\Civ4BeyondSword.exe" "mod=\${MOD_LOC}" "${MYCLSDIR}\${NAME}.ico" 0
SectionEnd
Works. It's just the shortcut gets printed on the base program menu, but I'd like it to be grouped with the Beyond the Sword shortcut. This is why in my new uploaded scripts based off of yours, I've shortened the start menu path to the above. I don't understand why putting it in a path doesn't work, but if I put it off the main path with anything it fails, for instance this fails:
Section "Start Menu Shortcut" Section4
CreateShortCut "$SMPROGRAMS\Games\${NAME}.lnk" "$INSTDIR1\Civ4BeyondSword.exe" "mod=\${MOD_LOC}" "${MYCLSDIR}\${NAME}.ico" 0
SectionEnd
As does this:
Section "Start Menu Shortcut" Section4
CreateShortCut "$SMPROGRAMS\Test\${NAME}.lnk" "$INSTDIR1\Civ4BeyondSword.exe" "mod=\${MOD_LOC}" "${MYCLSDIR}\${NAME}.ico" 0
SectionEnd

ZachScape
Apr 25, 2009, 02:54 PM
Phungus, remember the problem I had calling up WolfRev and BST? Well do you think if I dl someone else's mod with this program that we may find out if it is your mod that is not working for my computer or if this program is not working for my computer?
I can't imagine what's wrong with my PC that I am the only one who is getting this error. It's not fair!:cringe:

phungus420
Apr 25, 2009, 04:50 PM
It's impossible for this script to mess up, unless you intentionally hacked your own computer and messed with the Registry key for Civ4.

avain
May 22, 2009, 07:12 AM
Hi,
currently if the installer cannot find the path/Civ is not installed, it won't allow to install anyway even if you enter the path manually (the <next> is greyed out )
How can this be corrected?

phungus420
May 22, 2009, 11:08 AM
Yes, if it can't locate the Civ4BeyondtheSword.exe in the parent folder, it will not install. This is by design, as if the auto detection fails, it forces the user to locate the correct path to install to. It wol't install because if it were to install to a directory mods, in which the parent directory didn't have the BeyondtheSword.exe the mod would fail to work.

If you do want to remove this, I'm pretty sure it's controlled here:

Function .onVerifyInstDir
StrCmp $CurrentPage "DirectoryPage1" check1 valid
check1:
IfFileExists "$INSTDIR1\Civ4BeyondSword.exe" valid invalid
valid:
Return
invalid:
Abort
FunctionEnd

Removing this block of code should allow it to install wherever it pleases. If doing that doesn't work, let me know and I'll look, through the script again, and see if there is any other part of code that is part of the verify function.

avain
May 24, 2009, 12:43 PM
Thanks, I'll try out.

phungus420
May 27, 2009, 12:05 AM
NikNaks I'm noticing a few users are using your Install Script instead of the ones in the OP. Which is fine, but yours hasn't been updated.

Could you change this:
;Run the uninstaller
uninst:
ClearErrors
Exec $INSTDIR\Mods\${MOD_LOC}\uninstall.exe

done:

FunctionEnd
To this:
;Run the uninstaller
uninst:
ClearErrors
ExecWait '"$INSTDIR\Mods\${MOD_LOC}\Uninstall.exe" _?=$INSTDIR'

done:

FunctionEnd
This will make it so that the installer will wait for the uninstaller to finish. also you may consider adding this part of the icon scripting to it:
!define ICON "${MYCLSDIR}\someicon.ico" ;place your icon in your mod folder change someicon to the icon's name
!define MUI_ICON "${ICON}"
This makes the Installer setup have the Mod's Icon instead of using the default Nullsoft installer icon.

Anyway those are the two main improvements in the scripts in the OP, but since your script comes later I think people believe it is a more recent version.

NikNaks
May 28, 2009, 05:19 AM
Sure, I'll update it ASAP.

Maniac
Jun 02, 2009, 09:39 AM
May I ask what this Code(r)writer's notepad is you mention in your instructions? Where can this be downloaded? Google doesn't know what you are talking about. Is this Notepad++ or something?

phungus420
Jun 02, 2009, 04:14 PM
I think it's notepad++

To be honest I just googled "Code Text Editor" way back in the day, and downloaded and installed the first free thing I found, It said "CodeWriter's Notepad" I believe it's from Microsoft, so I think it's notepad++

Also any text editor that can be used to edit code will work for NSIS install scripts, it's just regular old notepad wouldn't work, it converted the scritps to .txt documents (which the Nullsoft Install Compiler doesn't understand), and had bizarre characters appear in the script when editing.

Maniac
Jun 03, 2009, 09:08 AM
Thanks! :)

The_J
Jun 24, 2009, 02:54 PM
I've looked into the script because of this thread (http://forums.civfanatics.com/showthread.php?t=325471), so i have now a question:
Could the script also search for the registry key of civ complete?
I only see the key for normal BtS.

phungus420
Jun 24, 2009, 03:31 PM
Complete installs a BtS regkey. This script works with complete.

CivIVMonger is an idiot. Witness his spamming of useless questions.

The_J
Jun 25, 2009, 01:01 PM
Don't think, that i built my question only on this thread ;).

I thought, that Complete doesn't use the normal registry keys :confused:, are you really sure?

phungus420
Jun 25, 2009, 03:41 PM
Well, I've never seen any reports of this script failing. Other then 1 from CivIVMonger. I suppose we could use someone to check this though. If there really is a RegKey change in complete, we could certainly add in a second check for the new RegKey, but we would need to know what the new RegKey is for complete.

Lord Tirian
Jun 25, 2009, 05:26 PM
Well, I've never seen any reports of this script failing. Other then 1 from CivIVMonger.A while back, I caught a short conversation about that in the HitM-thread - here are the relevant posts: 1 (http://forums.civfanatics.com/showpost.php?p=6367135&postcount=787) 2 (http://forums.civfanatics.com/showpost.php?p=6362984&postcount=768) 3 (http://forums.civfanatics.com/showpost.php?p=6363010&postcount=769); also this might be of interest (http://forums.civfanatics.com/showthread.php?t=200145&page=2), I think.

Cheers, LT.

phungus420
Jun 25, 2009, 05:49 PM
Hmmm, well if this is true, the simplest way to get it fixed and included in the script update would be to ask the BUG guys how they have it set up. Will make a post over there.

Maniac
Jun 26, 2009, 09:36 AM
You should probably update this script to say 3.19 is required. :D

And thanks again for the script - finally no more problems with people not knowing how to install the mod properly!

phungus420
Jun 27, 2009, 03:40 AM
http://forums.civfanatics.com/showthread.php?t=325670

OK, we got it now. We can call the main parent CIV folder, and use this install scrip. It'll take a bit of re writing. I'm posting this here on the off chance one of you will do it and finish it before me :mischief:

phungus420
Jun 29, 2009, 01:13 AM
Well I just found out the icon scripting doesn't work correctly. It uses the icon that is defined from your computer's path, woops. This has been out a while, and I was just notified about this. I'll have the scripts updated in a few days with the icon scripting working (will use the install directory path, instead of the person that compiled the scripts path), and will set it up so that detection works without a BtS reg key, per the BUG install script code. It will take me a few days to do this though. But figured I'd let everyone know what was up, and also about the recently found bug in the script.

The_J
Jun 29, 2009, 12:53 PM
For the icon...where's the problem?
I've gone the stupid way: I replace the standard icon with the one i want to. Works perfect.

phungus420
Jun 29, 2009, 03:29 PM
For the icon...where's the problem?
I've gone the stupid way: I replace the standard icon with the one i want to. Works perfect.

You think it does, and it does for anyone that has the same install path as you, but it breaks on machines that use a different path :crazyeye: Most people don't notice, or care, Keep in mind this script has been in use for a couple months now, and was just recently reported. I will get around to fixing this soon.

phungus420
Jul 02, 2009, 06:19 AM
I'm still working on this:

http://forums.civfanatics.com/showthread.php?t=325642

Basically got it working, but I've ran into a snag with the Start Menu Shortcut refusing to unistall. If I can't get this fixed in the next couple of days, I'll just release an updated script without the Superior BUG install for the Start Menu Shortcut, and keep it the same as it functions now.

phungus420
Jul 04, 2009, 06:20 AM
All the Install Scripts have been updated. This took so much work it's not even funny. The patch script has stayed the same, No need to change it, it worked great and still does. But there were errors in the old install scripts, particularly with icons that needed to be fixed.

Changelog:


Fixed error in icon scripting code. The icon will now link properly with created shortcuts. In the old scripts they would only have linked right for users that had the same mod path as the person who compiled the script.
Added multiple registry search paths. The script will now succefully locate the proper install path for users with Complete and Gold. In fact only really bizzar install paths will be missed (there are now 4 independent checks). Like before in the rare instance the installer can't find the Civ4 registry, they can manually browse to it and set it.
Improved Start Menu Shortcut creation. If a user selects the option to create a start menu shortcut, they now are taken to a list of available Start Menu folders, so that they can put the shortcut where they want. Also the Start Menu will link the uninstaller.
Updated language in Script to say that BtS 3.19 is required, instead of 3.17.
Lots of comments and general cleaning up of the code so that it is easier to read for modders that use these scripts.

The_J
Jul 04, 2009, 06:23 AM
Downloaded :).

phungus420
Jul 04, 2009, 06:01 PM
Actually I just ended up updating the patch script as well. Forgot I needed to add the aditional registry checks (mainly for complete and gold). Other then that the patch script is pretty much unchanged, as unlike the icon scripting installer, I didn't need to fix the icon scripting, or improve the start menus scripting, as both these are absent from the patching script anyway.

phungus420
Jul 04, 2009, 06:08 PM
Something I just noticed when uploading these was the optional add on script has 72 downloads itself, but I have yet to see a mod use it (Does anyone even use this script?). Overall these 4 scripts have around 200 downloads, yet I doubt more then a dozen mods use these scritps. So who exactly is doing the majority of the downloads, and why? Not that I mind, I like seeing my work used, but I'm just curious, because the download volume just doesn't make sense.

The_J
Jul 05, 2009, 12:53 PM
Like said, i use it :).
I'm currently uploading my next patch, and i've used the latest patchscript.

The_J
Jul 07, 2009, 01:38 PM
A small "problem":
In "!define MYCLSDIR" ${MOD_NAME} is mentioned at the end, but you've changed the variable to ${MOD_LOC}.

phungus420
Jul 07, 2009, 01:48 PM
NAME and MOD_LOC are two different things. This is so the text works out, especially in the patching script. There are three references to the mod. MOD_LOC is the name of the folder the mod is in. NAME is the full name of your mod. SHORT_NAME is the shorthand/nick name of your mod. This is so that the text in in the installer pages sounds correctly. For functionalitie's sake, all you need to have be right is MOD_LOC, as it's the only constant used in the script functions. NAME and SHORT_NAME are only referenced in the text of the script itself. I commented the begining of the script pretty thouroughly, it should be clear:

;--------------------------------
;Constants
;These are the variables you need to define for your mod

!define NAME "MY_MOD_NAME" ;Full Name of Mod
!define VERSION "X.X.X" ;Mod Version Number

!define MOD_LOC "MOD_FOLDER" ;Name of Mod Folder
!define SHORT_NAME "MOD_NICK" ;Shorthand/nick of your mod

!define MYBTSDIR "C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword" ;Path where your Beyond the Sword .exe is
!define MYCLSDIR "C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\${MOD_LOC}" ;Path where your mod is (Leave ${MOD_LOC} on the end of the path)

!define RAW_ICON "someicon.ico" ;place your icon in your mod folder change someicon to the icon's name

;You should not need to change anything below this line

!define ICON "${MYCLSDIR}\${RAW_ICON}"
!define MUI_ICON "${ICON}"

!define FIRAXIS_REG_ROOT "HKLM"
!define FIRAXIS_REG_KEY "Software\Firaxis Games"
!define BTSREGKEY "SOFTWARE\Firaxis Games\Sid Meier's Civilization 4 - Beyond the Sword"

;--------------------------------

If you're in serious doubt though, or are wondering how to improve things, just browse through the script, three are comments all through it, every section is clearly labeled with a comment saying what it does.

The_J
Jul 07, 2009, 02:08 PM
:blush: sorry, i guess, i've copied the path from the old script to the new script, and forgot to change the variable :blush:.
Sorry :blush:.

PieceOfMind
Jul 11, 2009, 10:21 AM
Something I just noticed when uploading these was the optional add on script has 72 downloads itself, but I have yet to see a mod use it (Does anyone even use this script?). Overall these 4 scripts have around 200 downloads, yet I doubt more then a dozen mods use these scritps. So who exactly is doing the majority of the downloads, and why? Not that I mind, I like seeing my work used, but I'm just curious, because the download volume just doesn't make sense.
Lots of possible reasons.
-Single users can contribute to the count several times by downloading several times IIUC.
-Downloading one of the scripts, you could very well download the others. They are small downloads after all. I downloaded the one with addons before I realised it was the simpler one I should have downloaded.
-Some people download it and then can't get it to work? It does require using NSIS.

phungus420
Jul 16, 2009, 11:19 PM
Well I guess the lack of comments means the new scripts are working perfectly :)

What mods use installers now anyway?

I know Legends of Revolution, Mars Now, History of the Three Kingdoms, ACO, and BUG and FFH2 do (though BUG and FFH2 don't use these scripts). Anyone else have their mods set up with an easy to use installer? I'm kind of interested in compiling a list of easy to install mods.

Lord Tirian
Jul 17, 2009, 01:34 AM
Anyone else have their mods set up with an easy to use installer?
Not my mod... but Planetfall uses your script as well.

Cheers, LT.

The_J
Jul 17, 2009, 01:52 PM
Dune Wars uses a type of installer.

avain
Jul 24, 2009, 02:11 AM
I use this script with VD and QC. There were some modifications needed with the version I downloaded (most probably you corrected it here, too - e.g. icon handling)

phungus420
Jul 24, 2009, 09:47 AM
Yeah, Icon use for shortcuts has been fixed. In the old version it only worked for users that had the same install path as the person that compiled the script. The new version also has 4 seperate checks for the BtS registry so thta it works for complete and gold, you might want to take a look at the new scripts. Also it fixes the start menu shortcut creation, so that users can pick and choose where tehy want the start menu shortcut to be placed.

TC01
Aug 09, 2009, 12:19 PM
If I wanted to adopt one of these installers for a Civilization IV Colonization mod, what would I need to do? Or can I do it in the first place?

phungus420
Aug 09, 2009, 10:54 PM
You would need to change the registry check, and install directory, and the check for the BtS exe. It would be pretty straightforward, but you'd need some knowledge of coding to do it. The script is well commented though, so it would be relatively simple and obvious how to do it if you have a little coding knowledge.

stmartin
Aug 14, 2009, 09:16 PM
Hi phungus,

is it possible to enable user to choose language for the installer? I want to make one installer that has both English and Chinese.

phungus420
Aug 17, 2009, 02:40 AM
Yeah, it's definatly possible. I didn't set up multiple languages in it, but NSIS is designed to support others, all it would take is a little copy and pasting, and adding the !include for language support. I'm not positive Chinese is supported by NSIS, but I'd assume so, almost as many people speak Mandarin on the planet as speak english. I'm not entirely sure how to set that up though, I'd ask in the BUG forums because they include mulitple languages there, and since you'd be the one translating, all they need to do is point you toward the macros you insert to do it. You can also check in the NSIS forums, I'm sure there is an example code section for languages (there are for everything else). I'd really like to set up this script with mulitple language support, and if you set up the format I'll definatly add a Spanish section to the general script. Unfortunately right now I'm stopping work on any projects here, so I wol't be able to code it in myself. I'm sure though the BUG team can show you how to do it with this script (and you might be able to figure it out yourself browsing through the NSIS example code website).

TC01
Aug 21, 2009, 10:04 AM
I think I changed everything to convert to Col. I'm assuming the registry keys are found in the Software\[Program Files Path]? So Colonization, which has a default directory of 2K Games\Firaxis Games, would be Software\2K Games\Firaxis Games?

!define FIRAXIS_REG_ROOT "HKLM"
!define FIRAXIS_REG_KEY "Software\2K Games\Firaxis Games"
!define BTSREGKEY "SOFTWARE\2K Games\Firaxis Games\Firaxis Games\Sid Meier's Civilization 4 Colonization"

I changed all the "Civ4BeyondSword.exe" to "Colonization.exe", and then altered the "find INSTDIR1" function to look like this:

Function findINSTDIR1

Push $0

#Quick BTS registry Check
ReadRegStr $0 ${FIRAXIS_REG_ROOT} "${BTSREGKEY}" 'INSTALLDIR'
${If} ${FileExists} $0
StrCpy $INSTDIR1 $0
Goto done
${EndIf}

#If fails look for other possible Registry Keys to Find the BtS folder
# standard Civ4:BTS
ReadRegStr $0 ${FIRAXIS_REG_ROOT} "${FIRAXIS_REG_KEY}\Sid Meier's Civilization 4 Colonization" 'INSTALLDIR'
${If} ${FileExists} $0
StrCpy $INSTDIR1 $0
Goto done
${EndIf}


# Civ4 Complete
ReadRegStr $0 ${FIRAXIS_REG_ROOT} "${FIRAXIS_REG_KEY}\Sid Meier's Civilization 4 Complete" 'INSTALLDIR'
${If} ${FileExists} $0
StrCpy $0 "$0\Colonization"
${If} ${FileExists} $0
StrCpy $INSTDIR1 $0
Goto done
${EndIf}
${EndIf}

done:
Pop $0

I'm assuming this is correct? I'm not entirely sure of the Col registry stuff.

phungus420
Aug 23, 2009, 01:49 PM
Assuming that is correct for Col's registry key, that should be it, yes, but I doubt the reg key is correct:
!define BTSREGKEY "SOFTWARE\2K Games\Firaxis Games\Firaxis Games\Sid Meier's Civilization 4 Colonization"
You should ask Dale or someone that knows what the registry key is for colonization, someone knows. Also if I were you, I'd change the name of the constant BTSREGKEY to COLREGKEY, so it's consistent, and doesn't confuse other users (or yourself).

phungus420
Aug 24, 2009, 11:49 PM
@stmartin

Did you ever look into adding multiple language support? If you have I'd like to add it to the main script.

stmartin
Aug 25, 2009, 12:03 AM
@phungus

No, I haven't, not enough time to do that while busy fixing bugs for HoTK.

phungus420
Aug 28, 2009, 06:45 AM
OK, well if you ever decide to tackle this let me know, and I'll definatly include it, might even try to work on it as well. Best bet is to ask in the BUG forums, as BUG uses the languages, and I'll jump in and do what I can to help make this work if you start to decide to work on this. I still think it'd be pretty easy, but I myself am not prepared to make the first steps, as it were.

cool3a2
Sep 09, 2009, 08:34 AM
Haven't checked the whole thread for this, so sorry if I am asking something that has been asked before. I used to provide a 'white flag fix' for my mods. It's nothing else then an alternative version of the flag for the case the default flag appears white in the game (actually wellknown problem...). Now that I am starting to use your superb install script, I am wondering whether it is possible to have an installer for the fix as well. I mean, I could provide a second version of the mod with installer that contains the alternative flag, but this would be uncomfortable for both, me and the downloader as I have to spend more webspace and the user has to download the mod twice (if he has problems with the flag). Of course I could provide the flag as a separate file, but that's less comfortable then having an installer.
As the directory of the flag doesn't change, it could be independent from the main mods version. Also, it might be a good idea to 'hide' the patch. That means that it would be good to not have a separate uninstaller, but have it uninstalled with the mod (just for the case someone is that foolish to uninstall the mod ;)).

So, would somebody tell me please whether there already is a possibility for this or whether someone could set up another script?

phungus420
Sep 09, 2009, 09:49 AM
You could use the optional add on script and set it up as an add on. Or am I not understanding what you want exactly?

cool3a2
Sep 09, 2009, 03:10 PM
Well, I am not sure whether the addon feature would work. From what I understand the addon would add additional files, right? But I'd like to replace a file (simply a dds file) of the main mod... Hmm... I might take a closer look at the addon thing.

phungus420
Sep 09, 2009, 03:25 PM
The add on extracts it's contents to where it's told to install to, so it will copy over files, just like normal extracting does. The add ons are applied after the main install, so it'll copy over files in the main install; for example I have LoR set up so that the LSystem files are replaced by the add on LSystem files if the enhanced graphics add on is selected.

cool3a2
Sep 09, 2009, 05:38 PM
Cool. And is it possible to have the 'addon' installed later separately? I mean, only users that have problems with the default flag need and should update. To figure out whether they do, they have to give it a go first. If necessary they should be able to install the addon now, preferably without reinstalling the mod completely.

phungus420
Sep 09, 2009, 05:53 PM
You could use the patch script for that.

cool3a2
Sep 10, 2009, 03:13 AM
Uh... sorry, totally missed that script. Thanks for your help!

The_J
Sep 15, 2009, 06:15 PM
One of the last responses in my thread:

Since a recent update Avira has decided that the Mars, Now files (and the Planetfall files as well) are mallware. I tried reporting a false positive report to Avira yesterday and got a response today:

==================================
Thank you for your email to Avira's virus lab.
Tracking number: INC00368612.
A listing of files alongside their results can be found below:
File ID Filename Size (Byte) Result
25451788 Mars__Now_v03_-_M..._L.exe 52.5 KB MALWARE

Please find a detailed report concerning each individual sample below:
Filename Result
Mars__Now_v03_-_M..._L.exe MALWARE

The file 'Mars__Now_v03_-_Mars__Jetzt_v03_-_Patch_L.exe' has been determined to be 'MALWARE'. Our analysts named the threat W32/Stanit. The term "W32/" denotes a file virus or malware that runs on 32 Bit Windows systems (Windows 95 and higher) only.Detection is added to our virus definition file (VDF) starting with version 6.31.00.202. Please note that Avira's proactive heuristic detection module AHeAD detected this threat up front without the latest VDF update as: HEUR/Malware.
===============================

Quite annoying, and I get the feeling they didn't exactly put much effort into actually checking the file before branding it "Malware"

Somehow interesting...
I guess, it's the combination of an executable, interaction with the OS, overwriting files, and scripts in it.

Just wanted to show that here, so that nobody is suprised, when somebody else reports that.

cool3a2
Sep 18, 2009, 07:28 AM
@phungus420: You mentioned that you like to try out the mods that use your installer scripts. You might then check the Magyar Mods latest beta. Check the mods thread, see last few posts there to find out how to download it. Sorry, it's a bit hidden, but it is only a beta yet... Now, I finished my advertisement :goodjob:

JEELEN
Sep 18, 2009, 09:43 AM
Only noticed this thread now, so I just want to say: nice one, phungus!:goodjob:

(Although I'm not sure I'll use it instead of the Auto-installer.) ;)

phungus420
Sep 13, 2010, 09:14 PM
For those interested there is a significantly improved version of the script available in RevDCM and Better Bug AI mods, you can find the script in the RevDCM source code add on. The scripts are designed for mods that use the BUG mod though, as they are specifically designed to handle the UserSettings folder for BUG.

Red Key
Nov 01, 2011, 08:54 AM
I noticed the last post in this thread was over a year ago. Are these still good scripts to use? Are there some better ones I should get instead? phungus mentioned better scripts in RevDCM and BBAI, but seemed to indicate they were for mods that use BUG and mine does not.

I tried out the "BtS Mod Install Script" but it had an error, so I just gave up and released my mod without an installer. I'll post the details of the error later. :badcomp:

The_J
Nov 01, 2011, 09:18 AM
Don't know what you'd define as "better", but the script here works pretty well, doesn't mostly cause any problems with the users, and it's easy to set up if you once figured it out.
You should definitely try to get it running, it's worth it :yup:.

PieceOfMind
Nov 02, 2011, 01:42 AM
Once I got it working I found it really useful. Making things as easy as possible for the end-user is a good objective IMO.

vincentz
Mar 16, 2013, 01:15 AM
I used this for my Vincentz Infinite Projects.
I have always been "scared" of using an installer, coz I thought it was really hard to make, but this template/script made it so much easier.

Thanks :D

tonyt25
Mar 22, 2013, 05:05 AM
Hi...

Can someone help me?

I want to edit unit capabilities, how can I do this? You can't do this in world builder....

Particularly, I want to create a transport plane.

Any help is appreciated.

thanks