Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,449 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
function call #145229
08/02/07 12:52
08/02/07 12:52
Joined: Apr 2007
Posts: 83
prog Offline OP
Junior Member
prog  Offline OP
Junior Member

Joined: Apr 2007
Posts: 83
hi,
In the code below count_down() function is called when a question pop-up. If the correct answer is selected the timer should disappear (or) if the timer is (0:00) it should disappear(i.e., count_down should stop).





//////timer//////////
string time_str;
string temp_str;
var seconds = 30; // number of seconds to be counted down
var temp_seconds;

function count_down()
{
while(seconds > 0)
{
sleep (1);
seconds -= 1;
temp = int(seconds / 60); // compute the number of minutes
str_for_num(time_str, temp);
str_cat (time_str, " : ");
temp_seconds = seconds - temp * 60; // compute the remainder (the number of sec)
str_for_num(temp_str, temp_seconds);
if (temp_seconds < 10)
{
str_cat (time_str, "0"); // add a zero (if needed)
}
str_cat (time_str, temp_str);
}
}

///////////////////quiz
function give_quiz1()
{
current_quiz = 2;
toggle_quiz_panels(1);

count_down();

if(current_quiz==2)
{
str_cpy(quiz_string, quiz2_string);
str_cpy(answerA_string, answer2_optionA_string);
str_cpy(answerB_string, answer2_optionB_string);
str_cpy(answerC_string, answer2_optionC_string);
str_cpy(answerD_string, answer2_optionD_string);


this_answer_is_correct=1;
}

}


function answer_quizA()
{
answer_quiz(1);


}
function answer_quizB()
{
answer_quiz(2);

}

function answer_quizC()
{
answer_quiz(3);

}
function answer_quizD()
{
answer_quiz(4);

}


function answer_quiz(answer)
{
player_var = answer;

if(answer == this_answer_is_correct)
{
str_cpy(response_string, "C O R R E C T ! Well done");

snd_play (correct_answer_wav, 200, 0); //play select sound


}
else
{
str_cpy(response_string, "Sorry, you got this one wrong.");

snd_play (wrong_answer_wav, 200, 0); //play select sound
}
wait(2);
quiz_text.visible= off;
toggle_quiz_panels(0);
quiz_panel.visible = on;
response_text.visible = on;
sleep(1);
toggle_quiz_panels(0);

Re: function call [Re: prog] #145230
08/02/07 13:57
08/02/07 13:57
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline
Serious User
Happy Birthday Scorpion  Offline
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
set your code in [ code ] [ /code ] bbreakets, else that's just a bit crap no one can read :]

to the question(without looking at the code^^):
you just need a text-element to show the timer. if the time is out just set its visible flag off

Re: function call [Re: Scorpion] #145231
08/02/07 15:44
08/02/07 15:44
Joined: Sep 2002
Posts: 700
Orange County, CA
L
LogantheHogan Offline
Developer
LogantheHogan  Offline
Developer
L

Joined: Sep 2002
Posts: 700
Orange County, CA
Sounds like you need a break function. Try this.

function count_down()
{
while(seconds > 0)
{
if(correct_answer_is_selected) { break; }
sleep (1);
seconds -= 1;
temp = int(seconds / 60); // compute the number of minutes
str_for_num(time_str, temp);
str_cat (time_str, " : ");
temp_seconds = seconds - temp * 60; // compute the remainder (the number of sec)
str_for_num(temp_str, temp_seconds);
if (temp_seconds < 10)
{
str_cat (time_str, "0"); // add a zero (if needed)
}
str_cat (time_str, temp_str);
}
stop_count_down();
}

Re: function call [Re: Scorpion] #145232
08/03/07 05:51
08/03/07 05:51
Joined: Apr 2007
Posts: 83
prog Offline OP
Junior Member
prog  Offline OP
Junior Member

Joined: Apr 2007
Posts: 83
thank you scorpion,
I have tried that, but when sec = 0:00, it is not invisible and the questionpanel should also be removed.

Re: function call [Re: prog] #145233
08/03/07 11:02
08/03/07 11:02
Joined: Apr 2007
Posts: 83
prog Offline OP
Junior Member
prog  Offline OP
Junior Member

Joined: Apr 2007
Posts: 83
hi,
in the below code, if time_seconds==0;
then am calling function entername(); continuously,
how to restrict it to call the function only once..
thanks for any help..


var seconds = 30;
function count_down()

{
while(seconds > 0)

{

sleep (1);

seconds -= 1;

temp = int(seconds / 60); // compute the number of minutes

str_for_num(time_str, temp);

str_cat (time_str, " : ");

temp_seconds = seconds - temp * 60; // compute the remainder (the number of seconds)

str_for_num(temp_str, temp_seconds);

if (temp_seconds < 10)

{

str_cat (time_str, "0"); // add a zero (if needed)

}

str_cat (time_str, temp_str);


}

if(temp_seconds == 0)
{
time_txt.visible = off;
toggle_quiz_panels(0);
entername();



}


}


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

Gamestudio download | 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