## Odd and even numbered Variables?

2 years ago

I'd also like to ask how to list multiple number on one Variable as well.

In List - Only if the number is one of the numbers you put into the box are they allowed access. The numbers have to be separated by only comma's and no spaces (From Help & Info > How to use the Advanced Editor)

Does anyone know how?

## Odd and even numbered Variables?

2 years ago
I'm not sure what you're trying to ask, however a variable can only store one number, and "In List" is used to check if a variable's value is equal to something in said list.

## Odd and even numbered Variables?

2 years ago

Just one number only? Then it's going to be a lot of work for me... Basically, I was trying to put up the varible %P = (0,2,4,6,8,10,12,...) and %P = (1,3,5,7,...). Odd and even numbers, kinda like jumping through hurdles.

## Odd and even numbered Variables?

2 years ago
What are you trying to do exactly? There's probably a workaround.

Easy enough to just have the game react to whether the number is odd or even, if that's all you're needing.

## Odd and even numbered Variables?

2 years ago

Let's just say I'm trying to include some math quiz that requires the player to memorize and manipulate it to their favor. For example, there is a fight going like this:

1. There is the AP, Action Point, ranging from 0 to 20.
2. Dog VS Cat with a game of Rock, Paper, Scissors. Each with 10 lives each.
3. I take the role of the Dog.
4. Whenever I throw my paw at the Cat, the AP will increase by 1, 2 or 3 randomly. Of course there is a way to decrease? AP to prevent going overboard but ignore that for now.
5. The Cat was designated to pull Rock when AP is at even, Paper when AP is at odd and Scissors when AP is one of the very specific numbers (3, 7, 13, 19). As long as I know that, I can win without losing a single life.
6. No one wins since dog and cat don't have fingers to play that game.

That's the gig of it. I probably need to rethink my plan after this.

## Odd and even numbered Variables?

2 years ago
This sounds like exactly what the In List function was designed for though? If the variable is one of those specific numbers, have the game react accordingly.

E: have you read the articles on scripting? IF THEN covers most things you'll ever need to do.

## Odd and even numbered Variables?

2 years ago

I have, yes. IF THEN, exactly! But what I didn't get was how to correctly use the In List function.

Dog picks paper

• IF %AP = 0 THEN %CATLIFE := %CATLIFE - 1
• %AP := %AP + 1D3

Do I have manually do it every time like:

• IF %AP = 0 THEN %CATLIFE := %CATLIFE - 1
• IF %AP = 2 THEN %CATLIFE := %CATLIFE - 1
• IF %AP = 4 THEN %CATLIFE := %CATLIFE - 1

Or is there a simpler way I am missing?

## Odd and even numbered Variables?

2 years ago
If you're only working in a range between 1 and 20 it probably wouldn't be that tough to just copy and paste the script a few times and plug in new numbers, just a bit tedious.

But In List works as a variable restriction only afaik, so another option (can't actually test it out right now though) would be to use those with your list of odds and evens and only have the applicable link show up on the page each time. The %CATLIFE or whatever you want to change can then just go in the link script as the player gets moved or the page gets refreshed.

I'm assuming your basically reusing the same page for most of this anyway if all that's needed is for the game to spit out a line of text and manipulate a variable. You'd need odds, evens, then the list of whatever exceptions lead to Scissors.

## Odd and even numbered Variables?

2 years ago

Wow, you read my mind! Guess I'll stick to the basic and see what I can come up with. Thanks.

## Odd and even numbered Variables?

2 years ago
Okay just got it working fine in a test game. Plugged a bunch of numbers into two restricted links and then set a %TEST variable to a random result within that range each time I loaded the page. It's a lot easier than doing IF THEN a bunch.

## Odd and even numbered Variables?

2 years ago

That means...I don't have to do that every time? Could you specify odds and evens that way?

## Odd and even numbered Variables?

2 years ago
The little stop sign next to a link takes you to variable restriction settings. You can select In List from the drop down box and type the numbers the way it explains in the bit you quoted in the OP.

So you'd have one link that only shows up with an odds result, another with evens, and a third for whatever numbers lead to Scissors. Put a script inside those links adding whatever to health and subtracting action points, or setting the main variable to a new random number for the next round.

For a game of rock paper scissors or any simple combat system you can probably just reuse the same couple of pages. Just a matter of adding more variable restrictions to do something like taking the player to a different page if their health drops below zero, or after a certain number of rounds, for instance.

## Odd and even numbered Variables?

2 years ago

Well why do I feel like an idiot, didn't even see the thing. Thanks for pointing that out, I'll give that a try right now.

## Odd and even numbered Variables?

2 years ago

You can take advantage of the truncation of fractional components here. If a number doesn't divide evenly by two, its decimals are truncated, and thus multiplying that result by two won't result in the original number. Therefore:

```IF %AP = (%AP / 2) * 2 THEN # %AP is even
ELSE # %AP is odd```

## Odd and even numbered Variables?

2 years ago

Thank you. It works great!

## Odd and even numbered Variables?

2 years ago
I feel like you're just approaching this in a weird way. Why not just have a random number between 1 and 3 determine the out? Given AP increments in random intervales (and that the player presumeably cant see the AP) its effectively the same.

## Odd and even numbered Variables?

2 years ago

Unfortunately, I was planning for AP to be seen.