int problems... SOLVED

Started by Akumayo, Sun 23/10/2005 21:54:13

Previous topic - Next topic

Akumayo

I am having trouble using ints.Ã,  Here is of the things I have already done to try to resolve the problem:
-The globalscript now starts with all the int declarations.
-The globalscript now ends with all the export int lines
-The script header now has all the import int lines

The error:
-parse error in expr near 'health'

BTW:Ã,  'health' is defined as as int health in all the ways listed above.

Here's where it happens:
Code: ags

Ã,  if ((health -= loss)<0) {


Any ideas?
-Thanks, Akumayo
"Power is not a means - it is an end."

Elliott Hird

-=? That isn't an operator.

do you mean if int1 minus int2 equals int2?

Akumayo

#2
it should be an operator, no?Ã,  In the manual:
Quote
You can add to and subtract from a variable using the += and -= operators. So, to add 3 to the current value of my_counter, do the following:
Ã,  my_counter += 3;

I could be wrong, it could be wrong, I don't know.Ã,  What I want
Code: ags

if ((health -= loss)<0) {

To do is check if health minus loss will be less than 0, and react accordingly, is there a better way to do this maybe?

EDIT--Fixed the problem, as it is += and -= can only be used to SET the int values, in if functions, simple + and - can be used and will work.
"Power is not a means - it is an end."

strazer

Yes,
  x -= y
is shorthand for
  x = x - y
so it won't do any good in a conditional expression.

Akumayo

I think I should've figured that out sooner, but thanks for clearing it up completely.  :)
"Power is not a means - it is an end."

Janik

Well, in C this would have been a valid construction, (x -= a) both changes x and returns the result. I don't think that's what you wanted to do anyway...
Play pen and paper D&D? Then try DM Genie - software for Dungeons and Dragons!

SMF spam blocked by CleanTalk