Fixed Race Script

A secret forum for people who preorder Overgrowth!
Post Reply
User avatar
Polkm
Posts: 14
Joined: Fri Jul 17, 2009 9:43 pm

Fixed Race Script

Post by Polkm » Thu Jul 23, 2009 2:05 pm

I fixed the race script today. It had some issues with it that made it not usable, so i fixed the ones i could.


=How to use=
First you need to download the file (attached).
Next you drag and drop the file into your data\scripts folder.
Then you go into the .xml level file you want this script to be in and change what it has for the javascript entry with this.

Code: Select all

    <Javascript>
        <LevelScript>Data/Scripts/level_race_script.js</LevelScript>
    </Javascript>
Now its installed, and when hot spots are working again (><), you will be able to properly use the race script on that level.

Note: If you want to test the effect out you can by going into your console (press `), and typing "race.start(how long the race should be)" and to end it "race.stop()" or you can add time with race.AddTime(how much).

Second Note: The text is draw a bit funky.

Download: http://www.mediafire.com/download.php?gtmmuwwztgu

For those whom cant download it from media fire

Code: Select all

var race = {};

(function() {
	/*Race Script*/
	var raceTime = 0;
	var timeToClearRaceText = 5000;
	var interval;
	var intervalClear;
	var textMade = false;
	
	/*Graphics.setPostEffects(false);*/
	function decrTimer() {
		Text.setValue("timerText",String(raceTime));
		raceTime--;
		if (raceTime < 0) {
			race.stop();
		}
	}
	
	function clearRaceText() {
		Text.setValue("raceText","...");
		clearInterval(intervalClear);
		if (raceTime <= 0) {
			Text.setValue("timerText","");
			Text.setValue("raceText","");
		}
	}

	race.start = function(limit) {
		raceTime = limit;
		interval = setInterval(decrTimer,1000);
		if (!textMade) {
			Text.createText("timerText","TopCenter");
			Text.createText("raceText","BottomCenter");
			textMade = true;
		}
		Text.setValue("timerText",String(raceTime));
		Text.setValue("raceText","Race started!");
		intervalClear = setInterval(clearRaceText,timeToClearRaceText);
		/*Graphics.setPostEffects(true);*/
	};

	race.addTime = function(amount) {
		raceTime += amount;
		Text.setValue("raceText","Checkpoint!");
		intervalClear = setInterval(clearRaceText,timeToClearRaceText);
	};

	race.stop = function() {
		Graphics.setPostEffects(false);
		clearInterval(interval);
		if (raceTime > 0) Text.setValue("raceText","You win!");
		else Text.setValue("raceText","You lose.");
		intervalClear = setInterval(clearRaceText,timeToClearRaceText);
		raceTime = 0;
	};

})();

Enjoy, :D

Post Reply