Gamestudio Links
Zorro Links
Newest Posts
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
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
problem with a condition #174674
12/25/07 02:34
12/25/07 02:34
Joined: Sep 2003
Posts: 733
Whitefish, Montana
JazzDude Offline OP
User
JazzDude  Offline OP
User

Joined: Sep 2003
Posts: 733
Whitefish, Montana
My game uses this method to keep track of the year.



Code:
var week = -60; //60 seconds make a week
var_nsave count_time = 1815; //starting year number

function Year_startup() //calculates year
{
while(count_time >= 0)
{
wait(week);
wait(week);
wait(week);
wait(week);
count_time += 1;
wait(1);
}
}



That works as it is supposed to. The year number changes after the set amount of time.

But when I use count_time in a condition like this:

Code:
if(count_time > 1816)
{
wait(-5);
bronze_pan.visible = on;
set_mouse(2);
}



nothing happens. What am I missing?

Re: problem with a condition [Re: JazzDude] #174675
12/25/07 03:59
12/25/07 03:59
Joined: Apr 2006
Posts: 58
Moerk Offline
Junior Member
Moerk  Offline
Junior Member

Joined: Apr 2006
Posts: 58
I´m not sure but i think the while loop is endless!

"while count_time is higher or equal 0 add 1 to count_time"

After count_time get the value "1816" its still over 0. The While loop again waits 240 seconds and then adds 1 to count_time.

maybe you can write your code like that

Code:

var week = -60; //60 seconds make a week
var_nsave count_time = 1815; //starting year number

function Year_startup() //calculates year
{
while(count_time >= 0 && count_time <= 1816)
{
wait(week);
wait(week);
wait(week);
wait(week);
count_time += 1;
wait(1);
}

wait(-5);
bronze_pan.visible = on;
set_mouse(2);
}



Another possibility is that:

Code:

var week = -60; //60 seconds make a week
var_nsave count_time = 1815; //starting year number

function Year_startup() //calculates year
{
while(count_time >= 0)
{
wait(week);
wait(week);
wait(week);
wait(week);
count_time += 1;
if (count_time > 1816)
{
wait(-5);
bronze_pan.visible = on;
set_mouse(2);
// proc_kill(1);
}
wait(1);
{
}




"Die Kette die mich ewig hält möge man erst noch schmieden" Regina S.
Re: problem with a condition [Re: Moerk] #174676
12/25/07 05:06
12/25/07 05:06
Joined: Sep 2003
Posts: 733
Whitefish, Montana
JazzDude Offline OP
User
JazzDude  Offline OP
User

Joined: Sep 2003
Posts: 733
Whitefish, Montana
Thank you, Moerk. Neither suggestion worked, but I suspect you are right about the endless loop being the culprit. I can't see anything else to suspect.

Re: problem with a condition [Re: JazzDude] #174677
12/25/07 05:07
12/25/07 05:07
Joined: Sep 2003
Posts: 733
Whitefish, Montana
JazzDude Offline OP
User
JazzDude  Offline OP
User

Joined: Sep 2003
Posts: 733
Whitefish, Montana
I think I'll give it a rest and go watch for Santa Claus.

Re: problem with a condition [Re: JazzDude] #174678
12/25/07 09:22
12/25/07 09:22
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
The count_time won't update when you put all the codes
in a single loop, it just keep waiting....

It should work if you put the if statement to another function
since the engine can handle multiple processes at the same time.

Code:

function check_count_time()
{
if(count_time > 1816)
{
wait(-5);
bronze_pan.visible = on;
set_mouse(2);
}
}

function Year_startup() //calculates year
{
while(count_time >= 0)
{
wait(week);
wait(week);
wait(week);
wait(week);
// bTW, why not write : wait(week*4);

count_time += 1;

check_count_time();
wait(1);
}
}



Re: problem with a condition [Re: JazzDude] #174679
12/25/07 10:12
12/25/07 10:12
Joined: Apr 2006
Posts: 58
Moerk Offline
Junior Member
Moerk  Offline
Junior Member

Joined: Apr 2006
Posts: 58
Alright... it was late tonight and these ideas were my only ones.

I think "vlau" has the answer. Try it!

Merry Christmas!


"Die Kette die mich ewig hält möge man erst noch schmieden" Regina S.
Re: problem with a condition [Re: Moerk] #174680
12/25/07 16:31
12/25/07 16:31
Joined: Sep 2003
Posts: 733
Whitefish, Montana
JazzDude Offline OP
User
JazzDude  Offline OP
User

Joined: Sep 2003
Posts: 733
Whitefish, Montana
Vlau: Once again you have solved my problem. Thanks. That works.

But I have about a hundred instances where the year is a condition in my strategy codes. I hope I can find a way to avoid adding every function to the Year_startup function.

As to your other suggestion, there is something screwy with the engine when it comes to time. Try this function and you'll see what I mean.

Code:

var week = -60;
fps_max = 60;
function time_check()
{

wait(week);
wait(week);
wait(week);
wait(week); //4 minutes elapse
beep();

wait(week*4); // 65 seconds elapse
beep();
}



I had to use this workaround in the Lost Dutchman with A5 and it wasn't cured in A6. I don't know about A7.

Re: problem with a condition [Re: JazzDude] #174681
12/26/07 08:16
12/26/07 08:16
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
If you're checking with the same year, just put all
the if statements in check_count_time(), should work.

Yeah, wait(week*4) doesn't work correctly, but it
works with smaller value such as week = 1.


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