#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# More extensive use of the IF perameter

edited November 2015
So i'm not sure how to accomplish this but i've been fiddling around with it for days on and off.

I know that;

<<if \$PER lte 3>>
Your hearing and sight is imparied.
<</if>>

<<if \$PER gt 3>>
<</if>>

etc..

But what I'm wondering is;

If there is a point in combat where someone throws, say, a flashbang grenade, then I would ideally want the perception attribute to be temporarily lowered to accomodate for the disruption that would accompany this.

Also, if a certain attribute is low, it could bring other physical attributes up or down to accomodate this (so you don't have any powerhouse bodybuilders who've got the endurance of a bedbound 100 year old, etc..).

I've tried using the <<if>>, <<set>> and <<print>> perameter for these, but to no avail.

I have also attempted to simply <<set>> an attribute to -3 (on it's own) and then <<print>> the result but the number still appears constant regardless.

I've also tried to incorporate an identical set of stats outside of the stat menu, but I wasn't sure what the applicable macro would be besides doing each one individually, e.g:

<<if \$CHA is 6, \$CCHA is 6>>

etc..

Could any one provide some insight to this more thoroughly?

If there is a point in combat where someone throws, say, a flashbang grenade, then I would ideally want the perception attribute to be temporarily lowered to accomodate for the disruption that would accompany this.
Well, you could have a modification \$variable for each statistic, which would normally be 0 but be modified by events as necessary. To get the effective stat value you'd just add the base stat and the modifier together. For example:
```/*
Assume \$PER is 6, but due to an event \$PERMOD is -4, so the effective
perception comes out to be 2 here.
*/
<<if \$PER + \$PERMOD lte 3>>…<</if>>
```

As for the rest, you're a bit scant on details. It would probably be better for you to give specific examples of exactly what you've tried to accomplish and the code you've tried to do it with. Otherwise we're guessing as to what you'd find useful, and that's not really helpful for anyone.
<<if \$CHA is 6, \$CCHA is 6>>
If you want to check two (or more) conditions within a single <<if>> macro you need to separate each condition with either the and or the or keyword depending on if both conditions have to be true or if only one of the conditions needs to be true.

a. If both conditions ( \$CHA is 6 and \$CCHA is 6 ) need to be true for the <<if>> to be true:
```<<if \$CHA is 6 and \$CCHA is 6>>
```

b. If only one of the conditions need to be true for the <<if>> to be true:
```<<if \$CHA is 6 or \$CCHA is 6>>
```
• edited November 2015
Hey guys,

Okay so I'm just gonna come straight out with what I'm trying to do.

<<if \$Str gte 4 and \$Str lte 5>>
You are Disabled.
<<set \$VIT -2>>
<<set \$DEX -4>>
<</if>>

<<print \$Str>>
<<print \$Vit>>

Basically this is the method i'm trying to take in order to integrate a perk-esque system (if it is at all possible), though the STR value is the same as it is on the stat allocation page, the Vitality and Dexterity values are the same as well (or at least the 'Print' macro determines), which is rather annoying, because as you can see I'm trying to change their innate value.

Is this method at all possible (I intend to do this for the rest of the stats as well) or should I just return to the drawing board? Sorry for the delay in responding as well, I was trying to think how to breach this question to you guys.

• First, just about everything in TwineScript is case-sensitive, so keep your cases consistent (i.e. \$VIT and \$Vit are not the same variable). Pick a style and stick with it. I'll be using \$Vit and \$Dex for the remainder of this post.

Second, I assume you're trying to subtract 2 from \$Vit and 4 from \$Dex and not set them to -2 and -4, respectively. Either way, you need to brush up on the <<set>> macro, because you're murdering the syntax.

Subtraction example:
```<<set \$Vit to \$Vit - 2>>
<<set \$Dex to \$Dex - 4>>
```
Alternatively, you could do it more more succinctly with the subtraction assignment operator, like so:
```<<set \$Vit -= 2>>
<<set \$Dex -= 4>>
```
And you really don't need two invocations of <<set>> there. One invocation is sufficient, as long as you separate your sub-expressions with the comma or semi-colon, for example:
```<<set \$Vit -= 2, \$Dex -= 4>>
```

On the off chance that you actually were trying to set them to -2/-4, then you could do it like so:
```<<set \$Vit to -2>>
<<set \$Dex to -4>>
```
• Oh god, I can't believe it was so simple x) I feel like such a fool now but at least the matter is resolved. It works a treat thank you

I feel like I can't thank you guys enough!