Game Development Community

Stuck

by Tsuki Nomisai · in Torque Game Engine · 04/07/2014 (2:23 pm) · 11 replies

Ok, I've been at a code for almost days. I've been using GarageGames and scripts for referencing what I'm trying to do. I'm making a addon for a game that uses torque. I'm just trying to toggle a observe the player itself while someone issued a command. I'm also stuck on a client-sided timer, all the scripts that I looked at gives errors, or I couldn't figure out what the error was. The script I currently made up without the timer, works like a charm. There's no errors.


#1
04/08/2014 (6:10 am)
Could you elaborate a bit?
I'm unsure what you need help with and what you are trying to accomplish..
Could you paste the script you want to have working? Also write why it isn't working and what you want it to do.
#2
04/09/2014 (2:28 pm)
Sorry for a late reply.

Here is the code:

package TimeControl_Pause
{
function onPauseActivated(%client)
{
%client.camera.setVelocity("0 0 0");

%client.camera.controlMode = %cameraMode;

%client.setControlObject(%client.camera);
}
function onPauseDeactivated(%client)<-----------Doesn't work
{
return;
}
};
activatepackage(TimeControl_Pause);

I added some of my notes in there as well. In the past, I've looked at some scripts, but I couldn't figure the timer itself. What I was looking at, I don't know if it was in milaseconds, or seconds. I need it to countdown from 00:12.40. I had some thoughts about creating a tick-rate different from the game itself currently has. The game has a tick rate in milaseconds. I don't know what to do for that. Will I need a client.cs for what I'm trying to do?
#3
04/09/2014 (11:20 pm)
So you'd like a function to get called every second for 12 minutes and 40 seconds?
#4
04/11/2014 (2:15 pm)
I would like something to modify the existing tick rate to 00:12.40. The max tick rate is 3 seconds.Thats why I think for the timer needs to have its own tick rate. It doesn't need to be exact, but very close to it. It could be a average of 12 seconds.

If you mean by;

Tim: /pause

Tim sees himself in camera view*

00:12.40 pasted, the player can move again.
#5
04/12/2014 (8:13 am)
Add a schedule for your timer.

%this.schedule(0, "delete"); (taken from ai.cs)

What you would do is add a schedule to your code
Schedule's work in milliseconds.
In the above code, I believe the "0" is the number of milliseconds to wait, then the function to activate when that time has elapsed.
#6
04/14/2014 (10:23 am)
@Tsuki.. Wait you want to modify the actual tick rate? I have no idea what that would do to the engine, I'd imagine it would completely wreck everything.
If it's because you want to make a pause function, then it sounds like you'd want to look at this thread.
#7
04/15/2014 (9:22 pm)
@Lukas YES!!!!! Thanks for point me in the right direction.

So for the schedule, it would be:

%this.schedule(12040, "create");

What could I use when it pasts 00:12.40?

EDIT: I put it in the code the $timescale = 0;, and in the console it gives me a number.

103

I did try to put in some kind of indication that the pause command was issued. I used the good ol' fashion echo command. Is this a error number, or something?
#8
04/16/2014 (12:10 am)
I tried writing $timescale = 0; in the console, and it returned 0 as it was supposed to.

What it returns should be the value of $timescale. I don't know why it would return 103 maybe a syntax error.

What you want is something like this:

pause(12040);

function pause(%time) {
   schedule(%time, 0, "unpause");
   $timeScale = 0;
}
function unpause() {
   $timeScale = 1;
}
#9
04/27/2014 (7:12 pm)
No change. Still a 103 error... :/

Don't worry about it. I just won't add it to my addon. I wish to add sound to my addon using SFX. Now, I need it looping, but I looked over the reference on it, and it was very overwhelming. Can you put it it into a example so I can get a better idea on how to go about my mary way?
#10
06/06/2014 (7:12 pm)
I've got a idea for the sfx source. Is it possible to play the sound by using background music?
#11
06/15/2014 (4:30 pm)
That should work - just change the background music filename to the new sound file, I think....