Blockland Forums > Modification Help

Basic Math Problems

Pages: (1/4) > >>

brickybob:

How do I set a variable to be 100 LESS than it's original value?  I tried...

--- Code: --- $rackunit = $rackunit - 100
--- End code ---
and

--- Code: --- $rackunit = {$rackunit - 100}
--- End code ---
and

--- Code: --- $rackunit - 100
--- End code ---

but nothing seems to work

what do

Treynolds416:

Many ways to do it


--- Code: ---%var = %var - 100;
%var -= 100;
%var += -100;
--- End code ---
etc.

Anyway be careful, you haven't used a semicolon in any of your examples. You may want to look at a scripting tutorial about basics, you seem pretty uninformed about scripting syntax in general.

otto-san:

$rackunit -= 100;

the first one would have worked if you remembered a semicolon, but you can set a variable with maths (what a horrible way to explain it, haha) by just doing op= instead of =.


ie +=, -=, *=, /=


Warning - while you were typing a new reply has been posted. You may wish to review your post.
welp

phflack:

i think the second one would've worked too with a semicolon
in java {} are used by for/while/if and other statements, but can also stand alone, so i'd assume it'd not affect anything here either

otto-san:


--- Quote from: phflack on April 26, 2012, 08:29:55 PM ---i think the second one would've worked too with a semicolon
in java {} are used by for/while/if and other statements, but can also stand alone, so i'd assume it'd not affect anything here either

--- End quote ---
this is not java

unless it's some long lost syntax rule i've never heard of, that won't work

Pages: (1/4) > >>

Go to full version