iNTRODUCTiON

This article is designed to explain a small and simple technique that should hopefully add to the professionalism of your creations.

As you may know, lots of people on this site prefer to run games straight from the zip file, instead of installing or extracting them.

If, like me, you prefer to make your projects in a self-contained exe file (perhaps, like me, building all external files into the Project), then people are more likely just to run it from the zip. If they see nothing but an exe and a readme, they won't instinctively realise that it needs its own folder, and they probably won't read the readme.

What's the problem?

The problem is that even if your game is designed to use as few external files as possible, it's most probably still going to want to have one of these features:

- Gamesaves
- Progress Saves
- A local High Score table (not an online one)
- Saved Configuration settings (so the app remembers your settings)

Normally, we would build our app so that it saves these in its root folder. This means that when the player wants to delete our game (along with all its settings and saves), they need only delete one folder.

The problem is that when programs like WinRar, WinZip, WinAce and even Windows run a file in a file archive like zip, they save it in the temp folder and run it from there.

This means the game will save all the settings in the Temp folder!

You quit the game, it saves its settings, then Winzip deletes the Temp folder and all your settings go with it.

Do you see what I mean? Now our attempts to make the app intuitive and simple have actually come back to bite us.

Is it that much of a problem?

This depends. Some extensions will go nuts when they look for files or data that aren't there (String Parser 2 can be a nightmare). More frequently though, it's just a pain.

Imagine playing a game that looks like it should run fine straight from the zip, and it does run fine. You play for over two hours, get a nice wopping high score, and the game won't save it.

How much of a problem this is really depends on the app you're building - but it's a problem best avoided.

How do we avoid it?

Simple. We get MMF to check whether the game's running from the temp folder. We can do this using the AppPath$ expression and String Parser 2 (delimit using "\")

The trick is to run a couple of checks. First, check if the first 16 characters of the path are this:

C:\Windows\Temp\
(note: You may want to use expressions to retrieve the drive letter, like AppDrive$)

That should work if users are running Win98.

To check WinXP is a little trickier.

Use StringParser to search for elements exactly matching "Local Settings".

If the result is greater than 0, then check the element after it to see if it says "Temp".

For example, perhaps the path is:
C:\Documents and Settings\Fred\Local Settings\Temp\Temporary Directory 1 for Game.zip\Game.exe

A search for 'Local Settings' will return '4'
So we check if element 5 = "Temp"

In this case it does. So we know this file is definitely in the temp folder.



Now we've checked that the game's running from the temp folder, we just make a small notice pop up for the user. I would probably make a discreet screen appear as the game starts that says:

"Please note: This game is running from the Temp folder. You may have tried executing the game from within a zip file. While the game will run, certain features will be disabled. To use all features, such as game saves and the high score table, please extract the game to a folder and run from there"

Then a couple of 'OK' and 'Exit' buttons will suffice. If you really wanna be kind, maybe include a 'Do it for me' button which will create the folder and move the files for them.



Then we do what we said we'd do. We disable the features that might screw up if we ran the game from a zip. Maybe we fade the 'Game Saves' button a bit. This prevents people trying to use those features and getting frustrated when they don't work. At the same time, it makes them painfully aware that they are limiting their enjoyment of the game.

And it's just so much slicker.

That's it

Yep. I hope at least someone bothers to do this