Page 1 of 1

Start- and Endpoint, Gametime

Posted: July 20th, 2012, 1:52 am
by schoenbt
Hello!
I'm working with sandbox a few days and it is getting better and better. But there are still a few questions left open:

1. How can i set an Endpoint as Level goal? (There should be a Startpoint (spawning) and an Endpoint (goal)). :?:
2. Is it possiple to get something like an output of the gametime/ playtime (time from start to endpoint) :?:

Greetings from cologne, germany! 8-)
Torsten

Re: Start- and Endpoint, Gametime

Posted: July 20th, 2012, 4:16 pm
by chocolatepie33
First things first: what mode are you using, along with what version of Sandbox?
schoenbt wrote:1. How can i set an Endpoint as Level goal? (There should be a Startpoint (spawning) and an Endpoint (goal)).
Depends on what you want to happen when you reach the goal.
schoenbt wrote:2. Is it possiple to get something like an output of the gametime/ playtime (time from start to endpoint)
You can edit the .bat of the mode you're using, use the -g command to specify an output .txt file (example: -goutput.txt), and you could use programming to implement a loop that counts out time, then record that into the txt file. I don't know what you could do for multiple text files, however.

Re: Start- and Endpoint, Gametime

Posted: July 25th, 2012, 2:31 am
by schoenbt
Thank you for your reply, chocolatepie33!
I'm currently using Sandbox Beta 2.2 (1.3) in singleplayer mode.

schoenbt wrote:1. How can i set an Endpoint as Level goal? (There should be a Startpoint (spawning) and an Endpoint (goal)).

chocolatepie33 wrote: Depends on what you want to happen when you reach the goal.
If the player reaches the goal the game should end and the playtime should be stopped (like a maze).
schoenbt wrote:2. Is it possiple to get something like an output of the gametime/ playtime (time from start to endpoint)

chocolatepie33 wrote:You can edit the .bat of the mode you're using, use the -g command to specify an output .txt file (example: -goutput.txt), and you could use programming to implement a loop that counts out time, then record that into the txt file. I don't know what you could do for multiple text files, however.
Ah, ok - that could be an option but currently i'm using OSX and i'm not sure if it's possible to write a batch-file or to start sandbox with the "-g"-command (do you/ or anyone tried it out ?).

Greetings from cologne, germany! 8-)
Torsten

Re: Start- and Endpoint, Gametime

Posted: July 25th, 2012, 3:59 pm
by chocolatepie33
schoenbt wrote:currently i'm using OSX
Oh no... Macs are such pains when it comes to Sandbox...

Since you're using such an old version, I'll assume that you're using FPS mode. Basically, what would happen is that you would have a numeric variable called "time" in your map. Once the player crosses the start line, a loop is triggered making "time" increase. Once the player crosses the finish line, a boolean (true/false) value, representing "map finished" (or something similar) would be switched to 1 (true), therefore stopping the loop, which is on if the boolean variable is not 1. From there, you can use the echo command to output the result to the output file.

As for editing the .bat file, I don't know much else on editing it, I don't even know what you use to launch Sandbox from a mac.

Re: Start- and Endpoint, Gametime

Posted: July 26th, 2012, 2:56 pm
by kddekadenz
schoenbt wrote: 1. How can i set an Endpoint as Level goal? (There should be a Startpoint (spawning) and an Endpoint (goal)). :?:
2. Is it possiple to get something like an output of the gametime/ playtime (time from start to endpoint) :?:
Here is the scriptlib of RJ. I'm too lazy to break it up for you. It includes answers for both questions.

Code: Select all

//enable sp

a = 0
sleep 0 [sp_on]

sp_on = [
    if (= $a 0) [
        sp;
        a = 1;
    ]
]


//settings

movespeed 100
jumpvel 100


//variables

//timer
	timer = [
		time = (format "%1 Seconds" $seconds)
 		seconds = (+ $seconds 1)
  		sleep 1000 [timer]
	]

	seconds = 0
	timer


//scoring

	collect_coin = [
 		coins = (+ $coins 1)
		coins = (format "%1 coins" $coins)
	]

coins = 0


//trigger

level_trigger_1 = [showgui win]

level_trigger_2 = [collect_coin; sound $coinsound]



newgui win [
	guitext (format "Congratulations %1, you made it!" (getname))
	guitext (format "You needed %1 seconds." (time))
	guitext (format "You collected %1 coins." (coins))
	guibar
	guilist [
		guibutton "[Next map]" "sp $nextmap"
		guibar
		guibutton "[Restart]" "restart"
		guibar
		guibutton "[Quit game]" "quit" 
	]
]


//cheats
toorich = 	[coins = (+ $coins 999)
		 coins = (format "%1 coins" $coins)
		echo "toorich - cheat was activated"
		]


//make common operations shorter - this saves a lot of time

restart = "sp"	//not really shorter, but logical

next = "sp $nextmap"

c_coin = "newent mapmodel 1 12 2"

c_apple = "newent mapmodel 3 12 2"

c_fin = "newent mapmodel -1 7 1"

c_tele = "newent teleport 0 2"

c_jump = "newent mapmodel 0"


//debugging

d_score = [echo (format "You have %1 coins." (coins))]

d_time = [echo (format "%1 seconds" (time))]


//sounds

coinsound = (registersound rj/coin 255)


//textures

exec "packages/rj/textures.cfg"


//models

exec "packages/rj/models.cfg"


//music

playasong = [ music (concatword "autotracker/music" (+ 1 (rnd 8)) ".ogg") playasong ]
playasong

Re: Start- and Endpoint, Gametime

Posted: December 1st, 2012, 12:59 pm
by rydion_dev
Can "Gametime" be implemented into a track racing game with multiple laps? If so, how? If not, what is the best alternative?

Re: Start- and Endpoint, Gametime

Posted: December 3rd, 2012, 1:17 pm
by kddekadenz
I think so. I'm not sure about the KRS scripting stuff, but I think it is similar to the old FPS mode.

Re: Start- and Endpoint, Gametime

Posted: December 3rd, 2012, 6:56 pm
by chocolatepie33
Last I checked, there wasn't scripting for krs.