Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Getting a value to return to it's former state?

Author
Message
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 1st Jan 2005 00:30
Hello

I know this is probably a stupid question, But I have a variable called the victorytimer(0), the victorytimer(0)=1000 by default, and if the players objects come into contact with the enemies, the victorytimer will begin to go down, if it reaches 0 then the player wins. Now here is the problem, I want victory timer to go down only when the player is colliding with one of the enemies objects, and if the player stops colliding, the victory timer should go back up to 1000, and if the player wins, the victorytimer should go back up to 1000 so that it can be used at another time. I am using the following code to do most of this....



Of course that does not revert the victorytimer back to 1000 if...

the player is not in contact with the planet
the player has already captured the planet

both of those things should revert the victorytimer back to 1000
but I cannot figure out how. And if I put in an if statement like...

if planet(0)=1
victorytimer(0)=1000
endif

then I can no longer manipulate the victorytimer, because it is in a loop, and holds it at a constant value. This problem is hendering other areas of my project,because I was going to give the player more of a certain resource (stradegy game) if they capture planets, but if I use an if statement like...

if planet(0)=1
money(0)=6000
endif

well, then I won't be able to manipulate that variable any more, because commands like this wont work anymore....

money(0)=money(0)-1

the same applies to the victory timer.

So I need help!

Guns arn't the problem, people are the problem, shoot all the people and guns arn't a problem anymore.
demons breath
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 1st Jan 2005 00:46


u tried that yet?

sorry if you find it obvious & patronising or anything, or if it's just a stupid answer which doesn't work.

Am I the only one here who's really confused?
http://db1games.topcities.com
(used to be demonsbreath)
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 1st Jan 2005 02:47 Edited at: 1st Jan 2005 02:58
That doesn't seem to work. The problem is, that if you tell a value to equal something in a loop, the program is going to keep on makign it equal that ever loop, thus it will stay constant. I just have no idea how to tell it to return to 1000, without making it a constant.

Guns arn't the problem, people are the problem, shoot all the people and guns arn't a problem anymore.
bibz1st
22
Years of Service
User Offline
Joined: 2nd Jan 2003
Location:
Posted: 2nd Jan 2005 00:11
not sure I understand what you're trying to do but it seems like you need to check if planet = 1 or 0

maybe not
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 2nd Jan 2005 00:16
Nomatter what I try to do, if I put in victorytimer(0)=1000 in a loop, then I can't change that value anymore becasue it is in the loop and is held constant.

Guns arn't the problem, people are the problem, shoot all the people and guns arn't a problem anymore.
Xander
22
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 3rd Jan 2005 12:23
Quote: "Nomatter what I try to do, if I put in victorytimer(0)=1000 in a loop, then I can't change that value anymore becasue it is in the loop and is held constant."


It will only keep making the variable equal to 1000 if that part of the code is run. For example:

This will make the variable=1000 no matter what:


This will not make the variable=1000 because that part of the code is not run:


Do you understand that?

This should work for you:


In the above code, victorytimer(0) will only be reset to 1000 if there are no ships touching the planet. Is that how you want it? I can also make it so victorytimer(0) will reset to 1000 if there is a ship not touching the planet, like this:



Does one of the above examples do what you want to do?

Xander Moser - Bolt Software - Firewall
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 3rd Jan 2005 12:30
Yeah! Awesome! I totally forgot about the else command, DOH!

Thanks!

Guns arn't the problem, people are the problem, shoot all the people and guns arn't a problem anymore.

Login to post a reply

Server time is: 2025-05-24 17:04:43
Your offset time is: 2025-05-24 17:04:43