Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, The_Judge, Grant), 898 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Event driven reload never works :( #87371
08/24/06 13:26
08/24/06 13:26
Joined: Jan 2006
Posts: 20
C
carcorde Offline OP
Newbie
carcorde  Offline OP
Newbie
C

Joined: Jan 2006
Posts: 20
I´m trying to make my game reload as soon as the player receives a predefined number of impacts, but no matter what I try, the script never seems to work, I must be making some kind of very basic mistake. I was capable of making the game reload after a countdown and after pressing a key, and also of making a scale that responds to the number of impacts, but cound not make the reload function work getting values from the var where the number of impacts is stored.
I first declared a variable (I´m using the car template):

var cracking = 0;

After that, I included an function to increase its value at each impact:

function crash_event()
{
while(1)
{
if (EVENT_TYPE == Event_impact)
// {
// if (glass_health < 6)/// this was to limit the number of impacts///for testing purposes
{
ENT_playSOUND(MY,wham_wav,80);
glass_health = glass_health + 0.04;
glass_stats = glass_stats + 1;
cracking = cracking + 0.04;
}
wait (1);

}
}



And, at the end, I use its value as follows:


function cracked()
{
while (1)
{
if (cracking == 6)
{
main_restart_game();
}
{

wait (1);
}
}


And, of course, it never works. I put a debugging digits window in my game interface to follow what is happening, and the var value increases at each impact, but the game never reloads. Won´t give me any error message either.

Could someone point to me what lowly and feeble minded mistake I´m doing?

thanks.

Re: Event driven reload never works :( [Re: carcorde] #87372
08/24/06 14:57
08/24/06 14:57
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline
User
demiGod  Offline
User

Joined: Mar 2006
Posts: 752
Portugal
Try using cracking += 1; in the crash_event function to increase the impact 1 by one, and then in the cracked function try if(cracking > 5). This way, when the car impacts reaches 6, the game should restart...

Re: Event driven reload never works :( [Re: demiGod] #87373
08/25/06 22:06
08/25/06 22:06
Joined: Jan 2006
Posts: 20
C
carcorde Offline OP
Newbie
carcorde  Offline OP
Newbie
C

Joined: Jan 2006
Posts: 20
Demigod, thanks for the tip, but the script still won´t work, even with your modifications. I´ve tried everything I could think of. The funny thing is I can do anything I want with the "cracking" var, drive windows, digits, move entities, except restart the game. I`m stuck.

Sorry for the late answer, but I was cought up in another project for some days.

thanks again.

Re: Event driven reload never works :( [Re: carcorde] #87374
08/25/06 22:44
08/25/06 22:44
Joined: Apr 2002
Posts: 224
Twickenham,England
kiamonster Offline
Member
kiamonster  Offline
Member

Joined: Apr 2002
Posts: 224
Twickenham,England
Are you sure you wrote an appropriat action to call the function and assigned it to the player?

Re: Event driven reload never works :( [Re: kiamonster] #87375
08/25/06 22:55
08/25/06 22:55
Joined: Sep 2003
Posts: 4,959
US
G
Grimber Offline
Expert
Grimber  Offline
Expert
G

Joined: Sep 2003
Posts: 4,959
US
try a my = null; 'right before' your line to restart the game

Re: Event driven reload never works :( [Re: Grimber] #87376
08/26/06 22:31
08/26/06 22:31
Joined: Jan 2006
Posts: 20
C
carcorde Offline OP
Newbie
carcorde  Offline OP
Newbie
C

Joined: Jan 2006
Posts: 20
Kiamonster: Well, I think the action is valid. It works for everything else, only fails when I try to reload the game with it.

Grimber: I'll sure try that ASAP.Thanks.

Re: Event driven reload never works :( [Re: carcorde] #87377
08/27/06 17:04
08/27/06 17:04
Joined: Sep 2002
Posts: 8,177
Netherlands
PHeMoX Offline
Senior Expert
PHeMoX  Offline
Senior Expert

Joined: Sep 2002
Posts: 8,177
Netherlands
I think I've found the solution to your problem, did you actually called the 'cracked()' function in your main function? If you didn't, then simply add " cracked(); " in your main function and then it probably will work, the coding seems to be okey, so I guess the function itself doesn't get started at all?

Cheers


PHeMoX, Innervision Software (c) 1995-2008

For more info visit: Innervision Software
Re: Event driven reload never works :( [Re: PHeMoX] #87378
08/28/06 13:44
08/28/06 13:44
Joined: Jan 2006
Posts: 20
C
carcorde Offline OP
Newbie
carcorde  Offline OP
Newbie
C

Joined: Jan 2006
Posts: 20
PheMox: hahahaha, yes, you were right, of course. I did not call it. Stupid me

It is working now, as it should. Sometimes the obvious is absolutely invisible, isn´t? Till someone points it out, then it jumps at you...

Thanks to all you guys for the help. I really appreciated it.


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1