Hi phreaky,
It's great to have another person making "Virtual Date" games. I'm a big fan. I'm going to recycle some advice I gave to Chaotic about the Javascrïpt and cookies he and you both use. I don't think Chaotic ever listened to this advice, but if you do, it'll save you a lot of time and headaches in the future.
I've uploaded a set of examples for you to
http://rapidshare.com/files/375671632/c ... v.zip.html (Rapidshare says that this will be deleted after 10 downloads, so if anyone else is interested in this, please wait until phreaky has grabbed it. It’s just some example html, not a game.)
The cookies have been the main cause of trouble with Chaotic's games. There's nothing wrong with cookies. We just need to tweak how they're used. Most of the pain comes from basing decisions on whether or not a cookie exists. Your life will become much easier if you stop basing decisions on the EXISTENCE of the cookie and instead base them on the VALUE of the cookie.
All cookies have a value that you can set at will. And, I believe, all browsers use the same code to set and read that value. So, where before you would do one thing if a cookie didn’t exist and another if it did, now you’ll do the first thing if the cookie is set to 0, and another if it’s set to 1. When you start the game, you just need to set all the cookies to 0.
To make cookienav, I started with some files from Chaotic's VDG and tried to change them as little as possible. I want the examples to be similar to what you’re used to and easy for you to follow. I’ve provided a few new jscrïpt functions for you, the most important of which is “readCookie.” This function reads the value of the cookie you give it and returns it as a number. If the cookie doesn’t exist, it returns 0. So you don’t have to worry about treating “invalid” cookies differently than cookies that are set to the default.
Using numbers allows you to do some nice things. For instance, you can now tell the difference between a cookie being 0, 1, 2, or 3. You no longer need 3 influence cookies. Now you just need one that you add to whenever the user does something good. You also now have the ability to take influence points away when the user does something bad. To help with this, I provided two other functions: incrementCookie and decrementCookie. The first adds 1 to the value of the cookie and the second subtracts 1 (with a minimum value of 0).
I also gave you some examples of how to call jscrïpt functions from hyperlinks and areas. You no longer need to put buttons in when the user gets influence. You can add and subtract values in cookies from links people click or from areas on the screen.
Finally, I gave a few examples of setting cookie values when you go to a page. You might want to do that for the situations where you only want to go to a place once, so you set a cookie when you get there.
To try out the example, start at teststart.html and click links from there. Ignore the missing pictures. I just used Chaotic's files and didn’t try to match them with images. You’ll see that I still use a “check” page the way Chaotic did, but now a single check chooses between multiple places based on the cookie value. In the example we go one place if the cookie is 0, another if it’s 1, and another if it’s > 1. You could just as easily go to 7 different places with 7 different values, or go to various places based on ranges, etc.
The page that shows how to increment and decrement cookies from links is test5.html. test4.html (and teststart.html) show you how to set cookies to predefined values when the page loads. You could also set to a predefined value from a link, or increment on page load, etc.
If you have any questions about how any of this works, don’t hesitate to ask.
Tlaero