Search In
• More options...
Find results that contain...
Find results in...

## Recommended Posts

I have an easy question this time. What is one easy line of scripting that will add 1 to a variable. I'm going to have this adding up to six. I need it for my current map. (Disabling bombs gives the variable a point, if all 6 are disabled script 1, the bomb script, stops!)

```If (i==6)
{
ACS_Terminate(bombscript#,map);
}
else
{
i++;
}
```
Could be something like that.

Hey that will work perfectly! And it makes it so I only have to use one script. Thanks Much!

Ok, so I found out I need more than one script... but it still works perfectly so thanks.

Did you consider to RTFM???

boris said:

Did you consider to RTFM???

Pardon me sir, but do you have any grey poupon?

Wanna know how to add 2?
variable = variable + 2;

Wanna know how to add 3?
variable = variable + 3;

Wanna know how to add 4?
variable = variable + 4;

Wanna know how to add 5?
variable = variable + 5;

Wanna know how to add 2 variables together?
combo = variableA + varibleB;

Wanna know how to subtract 2 from a variable?
variable = variable - 2;

Wanna know how to add 2 variables then subtract 2?
combo = varA + varB -2;

Heh, you know about the Zdoom reference right? Well Randy's making a new one since this one is so old. Cool.

Epyo said:

Wanna know how to add 2?
variable = variable + 2;

Wanna know how to add 3?
variable = variable + 3;

Wanna know how to add 4?
variable = variable + 4;

Wanna know how to add 5?
variable = variable + 5;

Wanna know how to add 2 variables together?
combo = variableA + varibleB;

Wanna know how to subtract 2 from a variable?
variable = variable - 2;

Wanna know how to add 2 variables then subtract 2?
combo = varA + varB -2;

Heh, you know about the Zdoom reference right? Well Randy's making a new one since this one is so old. Cool.

Yes but how do you add 1?!?!?

omg!%^

```var++; //add one to var
var += 2; //add two to var
var += 3; //add three to var
var += x; //add x to var
var -= 7; //subtract 7 from var
var--; //subtract 1 from var
var *= 2; //same as var = var * 2;
var /= 4; //same as var = var / 4;

```

What if we want to add, subtract, multiply, or divide two-digit numbers Cyb?

uh,

```x += 10;
x /= 1728;
x *= 751;
```

you can also do stuff like:
```x *= 0.75; //75% of x
x /= 0.5;  //double x
```
but those will only work if x is an int, not fixed point. if x is fixed point (1.2 or something like that) you need to do:
```x = fixedmul(x, 0.75);
x = fixeddiv(x, 0.5);
```
(aside from the last two lines, this is all fairly standard programming stuff avaliable in most (if not all) programming languages, in case you wanted to know or something :P )

You didn't explain how to subtract two-digit numbers. =/

Nanami said:

You didn't explain how to subtract two-digit numbers. =/

rofl the same exact way

x -= 25;
x -= 38343;

Cyb said:

rofl the same exact way

x -= 25;
x -= 38343;

What if my variable is not named "x"?

OMG even I can answer that!

```y -= 25;
whatever -= 25;
something *= 25;
etc /= 25;
```

Can anyone else confirm that cyber-menace is right? I really need this in a script I'm writing. But I don't want it to go havoc and break my computer or something.

after careful testing I can indeed say he is correct. however you need to uh, initalize those varible thingies otherwise it won't work...

Cyb you're confusing me!

Cyb said:

however you need to uh, initalize those varible thingies otherwise it won't work...

Where can I do that? Is it expensive?

I don't think it's legal in your country.

Initializing is done before the scripts. It's quite simple. Here's a couple of examples.

```#include "zcommon.acs"

int variablename
int forcef

(Scripts go here)
```
See it's that simple. So give'er a try.

Actually, you need semicolons.

boris said:

What if my variable is not named "x"?

rofl

boris said:

Where can I do that? Is it expensive?

nah, it's like 10 bucks/euros a variable or something so I guess you should try not to use too many. head to your local variable initilization store (if you don't have one there's an internet site, variableinitilizationsonline.com) and pay them and they'll get it done for you

If you guys keep joking around like this someone might just put this in post hell... I know I can't, but maybe someone else can.