Scripts / Race timer

Author
Message
Honkeyboy
3D Media Maker
9
Years of Service
User Offline
Joined: 16th Sep 2015
Location: Doesnt know half the time ;)
Posted: 12th Apr 2016 18:59 Edited at: 12th Apr 2016 19:43
Hi all, has anyone got a timer script from point a to point b I can adapt? I have just about completed the speeder race level ive been making and am trying to get a timer script in place where you can race the map from point a to point b and if completed within a certain time the player receives 5x 10x what they paid for the race. (this part I have managed to make a script for) but my brain seems to stop on timers and so my script just doesn't work. Anyways I thought i'd post it up see what you guys might have. Thanks heres my first attempt at the timer part which gives an error at line 30 (looking for a number?)

smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 12th Apr 2016 20:52
you need to add the .. to both sides of a variable if it isn't at the end of the prompt, i.e.
Text(10,10,1,"Time:"..hour..":"..minute..":"..second)
also your timer[1] is set to 0 initially so it wont equal "nil" and therefore 1 second will instantly have passed in your conditions (minor but might be worth correcting - just change timer[1] = 0 to timer[1] = nil)
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Honkeyboy
3D Media Maker
9
Years of Service
User Offline
Joined: 16th Sep 2015
Location: Doesnt know half the time ;)
Posted: 12th Apr 2016 20:58 Edited at: 14th Apr 2016 19:20
thanks smallg Edit: ok that's now showing correctly problem is that if I set it to a trigger there is no option for always active, if I set it to an entity it starts too early so I presume this is where i'll need getplayerdistance yes? Edit: hmm that's kinda odd I added



and all hell broke loose lol HEEEEEEELP!!!!!!! :/
Honkeyboy
3D Media Maker
9
Years of Service
User Offline
Joined: 16th Sep 2015
Location: Doesnt know half the time ;)
Posted: 14th Apr 2016 19:22
Has anybody actually done a race timer? where the timer starts when you pass a point and ends when you pass the last point and records it for prizes or am I asking the impossible?
Pirate Myke
Forum Support
14
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 15th Apr 2016 01:15
What you ask should be able to be scripted.

You will need to have some always active objects to detect where the player is and start and stop the timers when the player gets near and passes the point.

Scripts are available to tell the program which side of an object they are on, scripts that detect the range of the player from a specific object, scripts to collect the info for score purposes, scripts for timers.

So it would be a matter of combining the use of these scripts into a Routine like the coin collecting in the cartoon demo map.

I would start with that and apply the timer functions in there, collecting times and resetting timers and performing some option (restart level, goto other level, start the next range of objectives, spawn objects.) Based on the times that you define.

Sometime it is easier to write down what you want to do in steps on paper and then build your script around that.

Player start, Start timer heat 1
Objective, Get to the flag A
Obstacles: 6 solders spawned at start.
Time allowed: 3 minutes:
If make it: advance to heat 2:
If not: end level and restart.

Keep working your way through what you want till you get a solid plan. Then all you need to do is piece together the scripts as you need.



Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit, Screen resolution 1680 x 1050.

Honkeyboy
3D Media Maker
9
Years of Service
User Offline
Joined: 16th Sep 2015
Location: Doesnt know half the time ;)
Posted: 15th Apr 2016 10:02 Edited at: 15th Apr 2016 10:55
OK Myke i'll have a look at those scripts see if they spark the grey matter into working lol and thx Edit: OMG didn't even know they were in there never looked lol :/ AAAAHHHH I got the timer to start correctly yay what it was, my lua editor kept asking for an (eof) at line 10 which didn't make any sense as the script main start is on that line, so I put it at the end and it now works lol do'h. But now I have to get the clock to stay on screen as I have it check the player distance to start it disappears after the said distance :/
Honkeyboy
3D Media Maker
9
Years of Service
User Offline
Joined: 16th Sep 2015
Location: Doesnt know half the time ;)
Posted: 15th Apr 2016 13:08
OK ive had another go and split this into 2 scripts 1 calling on the other to run

script 1



And Script 2



Whats happens is the race timer text displays as you get nearer as if its doing a distance check and disappears same distance the other side :/ so I'm abit lost again as usual lol

Login to post a reply

Server time is: 2024-12-22 15:31:03
Your offset time is: 2024-12-22 15:31:03