Author Topic: Horn is almost complete  (Read 2114 times)

My horn is almost COMPLETE. There is just a problem, it doesn't seem to play hornMiddle or End. Also, the delay of 500MS is because the hornBegin is 500MS long.

1820 is the total amount of time it takes to do one full horn cycle.

Code: (Torque) [Select]
-snip-
Code: (Torque) [Select]
-snip-
Code: (Torque) [Select]
-snip-
Yes it works considering it plays only the hornBegin
« Last Edit: April 02, 2009, 08:38:53 PM by Kalphiter »

1) Why are you comparing numeric values with a string comparison operator? Don't use if(%triggerVal $= 1), instead use if(%triggerVal == 1).

2) In order to make sure they're clicking the horn, you'll need to check if the %triggerNum argument (what you called it) is equal to 0, which is the fire weapon (left click by default) button, I believe.

3) The schedule method of objects doesn't require the second argument present in the schedule function. So, you just need %obj.schedule(500,playaudio,2,hornMiddle);, assuming those are the right argument values.

1) Why are you comparing numeric values with a string comparison operator? Don't use if(%triggerVal $= 1), instead use if(%triggerVal == 1).
:cookieMonster:

Code: (Torque) [Select]
function blowHorn(%obj)
{
    %obj.playAudio(2, hornBegin);
    %obj.schedule(500,0,"playAudio", 2, hornMiddle);
}
The 0 needs to be taken out of this, as it is an object schedule.

Code: (Torque) [Select]
    if(%mount.getDataBlock() == %DataBlockName && %triggerVal) <-----------
    {
%client = %obj.client;
if(isObject(%client) && !%client.player.getMountedImage(0))
{

    if(getSimTime() - %obj.lastHornBlow < 1820)
return;

    if(%triggerVal $= 1)           
        blowHorn(%obj);


    else if(%triggerVal $= 0)  <----------
    {
        %obj.lastHornBlow = getSimTime();
stopHorn(%obj);
    }

Note where the arrows are.
That if statment wants %triggerVal to be 1, but there's an if statement inside of there that wants %triggerVal to be 0.
I think in the first one, you wannted %triggerNum to be 1.

Note where the arrows are.
That if statment wants %triggerVal to be 1, but there's an if statement inside of there that wants %triggerVal to be 0.
I think in the first one, you wannted %triggerNum to be 1.

Good catch, that's the whole entire problem. Will remain open for any other mistakes...

The %triggerVal problem is stopping hornEnd from working, the 0 in the schedule is what is stopping hornMiddle.

You can do this entirely using the image state system and it'd be much easier and more effective.

You can do this entirely using the image state system and it'd be much easier and more effective.
Care to explain?

Also, horn is successfully working. Just some audio errors(bad file to loop on)


And... I'm not sure how to make sure the driver is horning.
getControllingClient()
« Last Edit: March 30, 2009, 09:23:56 PM by Kalphiter »

No, the state system is well documented in plenty of places including the garagegames website. Its also not that hard to work out just by looking at the way other things use it. So once again, stop being lazy and go figure it out for yourself.

I'll help you once you've tried and failed.

No, the state system is well documented in plenty of places including the garagegames website. Its also not that hard to work out just by looking at the way other things use it. So once again, stop being lazy and go figure it out for yourself.

I'll help you once you've tried and failed.
Mind a link?

So once again, stop being lazy and go figure it out for yourself.

If I didn't know you better, I'd swear you were trying to make a joke.

If I didn't know you better, I'd swear you were trying to make a joke.
Yes, but it would help if I had a name that is more easily searchable.

Also, what is velocity measured in in Torque?(something to do with units, just how many units/s)
« Last Edit: March 30, 2009, 09:29:42 PM by Kalphiter »

I'm assuming m/s, but I could be wrong.

I believe it's one unit per second. As in, if your velocity is 0 0 200, and your position is 38 16 56, in two second your position will be 38 16 -344, assuming you don't slow down. (200 per second would be 400 travel over two seconds.)

Edit:
By units I mean Torque units, which is the width of a single stud in Blockland.

Edit:
By units I mean Torque units, which is the width of a single stud in Blockland.
One Torque unit is two horizontal studs, and 0.6 Torque units is one brick standard height.