Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, bigsmack, 1 invisible), 1,341 guests, and 14 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19057 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
same counter in al levels back and forth? #125018
04/19/07 12:51
04/19/07 12:51
Joined: May 2006
Posts: 132
Norway
Fiskekona Offline OP
Member
Fiskekona  Offline OP
Member

Joined: May 2006
Posts: 132
Norway
I have a counter that is in the script where the menu is.
It starts when I start the game from the menu.
in the game the player can find a "secret" level and I wanted the counter to "follow" the player to the secret level. I did manage that , but when I tried to make a function that brings the player back again when there is only 3 seconds left. I dont get the reaction I want. The counter only counts down and goes back to the menu.

Here is the levels I have:

string level_str = <NyTestMenu.WMB>; // menu
string startspill_wmb = <bonustest.WMB>;//main level
string testSpill_wmb =<testSpill.WMB>; //secret level

Here is the function I wrote.I have it in the secret level(testSpill.wmb). I wanted that the player shall return to main game and continue with an extra 40 seconds since they found the secret level.But nothing happends. The counter counts down to 0 and go back to menu.... so what am I doing wrong?

Code:
 function go_back_to_game_startup()
{
while(seconds > 3){


if(seconds == 3)
{


level_load(startspill_wmb);
seconds = 40;
wait(3);

}
}
}



the counter is in the menu script (NyTestMenu.WMB);
Code:
  function count_down() 
{

while(seconds > 0)
{

sleep (1);
seconds -= 1;

if (seconds == 0)
{
display_score.visible = on;
display_back_score.visible = on;
freeze_mode = 1;
sleep (4);
display_score.visible = off;
display_back_score.visible = off;
chart_highscores(hits_of_the_player,pl_name);
savescore();
savescore2();
show_the_highscores();
//
level_load(level_str);
wait(3);
//fps_max = 60;
freeze_mode = 0;


score_gesamt.visible = on;
titel_pan_menue.visible = on;
exit_pan.visible = on;
plname_pan.visible = off;
clear_pan.visible = on;
credits_button.visible =off;
newgame_pan_menue.visible = off;
time_panel.visible = off;
shoots_panel.visible = off;
display_reload.visible = off;
first_pan.visible = off;
display_pan.visible = off;
time_slow_panel.visible = off;


hits_of_the_player = 0;
shoots = 100000;
extra_slow =0;
extra_slow_time = 0;
time_factor = 1;

}

}

}



What am I doing wrong?
and where am I supposed to put the go_back_to_game_startup()?
If I put it in the menu script, it will only effect the main game dont it?
I am so confused rigfht now...that I dont see anything....
Maybee someone elses eyes can see what I am dong wrong....thanks in advance!


Programmer in training... Own GameStudio Commerical 6.50
Re: same counter in al levels back and forth? [Re: Fiskekona] #125019
04/19/07 14:00
04/19/07 14:00
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
You have to start the function go_back_to_game_startup when the secret level is loaded. Something like:

level_load(testspill_wmb);
go_back_to_game();

Be sure to have the _startup removed in the function declaration and the function call, if you don't want to run the function at the very beginning of your game.


Always learn from history, to be sure you make the same mistakes again...
Re: same counter in al levels back and forth? [Re: Uhrwerk] #125020
04/19/07 15:03
04/19/07 15:03
Joined: May 2006
Posts: 132
Norway
Fiskekona Offline OP
Member
Fiskekona  Offline OP
Member

Joined: May 2006
Posts: 132
Norway
no reaction:....

It seems like it cant find or read the function I made.....


Programmer in training... Own GameStudio Commerical 6.50
Re: same counter in al levels back and forth? [Re: Fiskekona] #125021
04/19/07 15:04
04/19/07 15:04
Joined: May 2006
Posts: 132
Norway
Fiskekona Offline OP
Member
Fiskekona  Offline OP
Member

Joined: May 2006
Posts: 132
Norway
But let me ask the question in an other way?

How do I do this?
make a counter that count the time in the main level, continues to count when it comes to the secret level and still counting when I get back to the main level?


Programmer in training... Own GameStudio Commerical 6.50
Re: same counter in al levels back and forth? [Re: Fiskekona] #125022
04/19/07 15:34
04/19/07 15:34
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
Maybe I don't understand You but simple var isn't still counting when You change the level? like: some_time +=1; wait(-1);


Never say never.
Re: same counter in al levels back and forth? [Re: tompo] #125023
04/19/07 15:42
04/19/07 15:42
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Store it in a global variable...
Then just keep adding to it...


xXxGuitar511
- Programmer
Re: same counter in al levels back and forth? [Re: xXxGuitar511] #125024
04/19/07 16:16
04/19/07 16:16
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Code:

var counter;
var counter_state = 0; //0 = not counting, 1 = counting

function counter_set(_state,_value)
{
counter = _value;
while(counter_state)
{
counter -= 1;
counter_state *= sign(counter);
wait(-1);
}
}

function counter_add(_value)
{
counter += _value;
}

//Start the counter like this (e.g. 20 seconds):
counter_set(1,20);

//End the counter like this:
counter_set(0,0);

//Add something to the counter (e.g. +40 seconds):
counter_add(40);

//player did something wrong, give him less time (-20):
counter_add(-20);



Re: same counter in al levels back and forth? [Re: Xarthor] #125025
04/19/07 18:09
04/19/07 18:09
Joined: May 2006
Posts: 132
Norway
Fiskekona Offline OP
Member
Fiskekona  Offline OP
Member

Joined: May 2006
Posts: 132
Norway
thanks i will look at this in the morning


Programmer in training... Own GameStudio Commerical 6.50
Re: same counter in al levels back and forth? [Re: Fiskekona] #125026
04/19/07 18:33
04/19/07 18:33
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline
Expert
mpdeveloper_B  Offline
Expert

Joined: Feb 2006
Posts: 2,185
it looks like it's closing the while loop as soon as the counter hits 3, because of this:

Code:

while(seconds > 3){


if(seconds == 3)
{



this means as soon as the while loop gets to 3 seconds, the while loop stops, which means you might want to put this:

while (seconds > 2)

it's just an idea, but it might be the reason


- aka Manslayer101
Re: same counter in al levels back and forth? [Re: Fiskekona] #125027
04/19/07 21:56
04/19/07 21:56
Joined: Apr 2004
Posts: 516
USA
Trooper119 Offline
User
Trooper119  Offline
User

Joined: Apr 2004
Posts: 516
USA
I appologize I missed something but I looked at the latest post and something popped out at me of why this doesn't work, so if this was said already, my bad.

For the following code:
Code:

function go_back_to_game_startup()
{
while(seconds > 3)
{
if(seconds == 3)

{
level_load(startspill_wmb);
seconds = 40;
wait(3);
}
}
}



Notice the highlighted code, I'm assuming that you are continously counting down somewhere else, so then this code comes into play, it first checks if seconds are > 3, if it is, it goes into your loop, but if seconds = 3, the loop IS NOT STARTED, so your if statement if(seconds == 3) never gets triggered, I think what you want to do is make the while statement read

while(seconds >= 3)

That seems to be the piece of code that is incorrect, I didn't look any further but that should fix your current problem

EDIT: I reread the last post, it seems someone else beat me to the punch, depending on if you want the code to run at exactly at 3 seconds, or if you want some leeway time will depend on if you want the while loop to >= 3 or > 2, I like my way better, but then again, I was the one who suggested "my" way lol

Last edited by Trooper119; 04/19/07 21:59.

A clever person solves a problem.
A wise person avoids it.
--Einstein

Currently Codeing: Free Lite-C
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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