Forum Topic: Idiot subtraction problem

(127 views • 2 replies)

This topic is 1 page long.

<< < > >>
Questioning

Satis

Reply To Post Reply & Quote

Posted at: 2/26/06 03:31 PM

Satis LIGHT LEVEL 05

Sign-Up: 01/18/06

Posts: 8

My God I feel like a moron I should be better than this. Sorry if this is a repeat but I didn't see anything like this covered after about half an hour of searching the BBS.

Ok - what I'm trying to do is have a scenario in which a random number between -25 and 25 (variable is gamblingresult) is created, and then both subtracted from a cash total (variable is cash) and displayed in dynamic text. I also have a different dynamic text box below this (displaying the variable plusminus$) that calls it either a profit, a loss or a break-even day. Take a look at my horrible coding:

randomvariable=random(51)
gamblingresult=25-randomvariable
if(gamblingresult>0){
plusminus$="profit :)"
}
else if(gamblingresult=0){
plusminus$="break even session"
}
else if(gamblingresult<0){
plusminus$="loss :("
}
cash+=gamlingresult

The dynamic text displays are coded within the stage and don't seem to be a problem. The trouble I'm having is that it seems to work when the result is a positive number, but if gamblingresult would contain a negative number, it seems to end up as zero. Unless it's just generating 0 as a result of the computation, and that seems beyond probability.

Also, I'm teaching myself (out of a background in QBasic :p) so if anyone has a suggestion for a cleaner way to do this, please let me know, but try to explain fully, since it'll probably be over my head.

Thanks.


None

Vengeance

Reply To Post Reply & Quote

Posted at: 2/26/06 03:40 PM

Vengeance EVIL LEVEL 28

Sign-Up: 03/18/05

Posts: 5,049

else if(gamblingresult=0){
plusminus$="break even session"
you need double equals
else if(gamblingresult==0){
plusminus$="break even session"

========|| WWWWWWWW>[-[Blog] - [Audio] - [Userpage] - [Flash] - [Last.fm]-]<WWWWWWWW ||========

BBS Signature

None

Satis

Reply To Post Reply & Quote

Posted at: 2/26/06 03:55 PM

Satis LIGHT LEVEL 05

Sign-Up: 01/18/06

Posts: 8

:0

Ok you're right it was that simple. Idiot!

Thanks!


All times are Eastern Standard Time (GMT -5) | Current Time: 12:59 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!