I'm having problems with *selectable_if


#1

I set my inventory by using booleans, so basically if you had 5 smoke grenades, I’d do

*set Smoke_grenades_5 true

then if you used one, I’d do

*set Smoke_grenades_5 false
*set Smoke_grenades_4 true

So now I’m at a point where the reader will have used a smoke grenade previously, but as long as he has at least one left, he should be able to choose the option

#Cast a smoke grenade at the assassin

But since I’m using booleans, I tried to use the code

*selectable_if (Smoke_grenades_4) or (Smoke_grenades_3) #Cast a smoke grenade at the assassin

but it came up with the error

line 102: Invalid expression at char 17 expected OPERATOR , was CLOSE_PARENTHESIS [)]

Does anyone know to fix this?


#2

Try this:


*selectable_if ((Smoke_grenades_4) or (Smoke_grenades_3))

I’m honestly not sure if that would work, though!


#3

@Redgrave
It worked! Thanks:)


#4

Dude… *ick* too many booleans!

Can I suggest…?

*temp smoke_grenades 5

then when you use one…

*set smoke_grenades -1

then your option should be

*if (smoke_grenades > 0) #Cast etc etc

Much MUCH simpler no?

If you insist on your option then…

*selectable_if ((Smoke_grenades_4) or (Smoke_grenades_3)) #Cast etc etc

you need an extra set of ( ) around the whole clause… but I’m guessing you’re going to have to have

*selectable_if ((((Smoke_grenades_5) or (Smoke_grenades_4)) or ((Smoke_grenades_3) or (Smoke_grenades_2))) or (Smoke_grenades_1)) # Cast etc etc

to make it work with all smoke grenades option…

I proper love ifs ands and brackets me… (just ask @CJW) but seriously… the above code looks like it would be hard to keep on top of!


#5

@nine
I agree that it’s too hard, but I couldn’t figure out another way that’d work with an inventory. Temps don’t work with inventories.


#6

then you can use *create. It’s just a variable, and you can use it later if need be. It can make it all more simple.


#7

Can I ask why you’re using a boolean? Why not use a variable with a numeric variable?


#8

@Caddmuss
Because I’m setting it into an inventory, instead of tracking it by itself like a health stat or something. If there’s a way to set it as a numeric value while simultaneously putting it into an inventory, I’d love to hear it. Plus, half of the stuff you can have in your inventory, you don’t have initially.


#9

I think most variables that are inventory-related deserve to be declared as global since you’re looking to use them repeatedly, either use *create or dump them into mygame.js which is a convenience of its own.

edit
Try setting a numeric variable and put something like this without *stat_chart in the stat txt file.

[b]Inventory[/b]

Grenades remaining: ${grenade} units

#10

@FcA
The reason I’m using booleans is because half of the stuff that you can have in your inventory, you don’t have initially.


#11

Maybe instead of booleans you can use *ifs. Because you now are declaring 6 different temp variables, and need to update them everytime you make a change. Instead, you could have a variable “smoke_grenades” with the number of grenades you own, and *if (smoke_grenades=5) “you have 5 smoke grenades” etc. To me it’s easier to understand it like this.

Edit: You can then write *selectable_if (smoke_grenades>0). If you have one or more, you can use it. If you don’t have any, you can’t.


#12

@Samuel_H_Young Right. I think it then calls for two variables, one for the item count and the other for whether it’s in there or not… unless someone else has a more efficient workaround to that.

edit (again, lol)

[b]Inventory[/b]

*if (grenade>0)
    Grenade remaining: ${grenade} units

which wouldn’t display if the player doesn’t have any? And it gets rid of an extra boolean


#13

Whereas smokegrenades are a numeric value:


Game:

*create smokegrenades 0

"blahblahblahacquire5grenades."

*set smokegrenades 5

"blahblahblahuse1grenade"

*set smokegrenades - 1

Inventory:

*if smokegrenades>0
, ${smokegrenades} Smoke Grenades

I’m rusty, but would that idea work into how you have it. I might be able to fix if I knew what your inventory looked like.


#14

@Caddmuss
This does seem like a better system, but I’ve already coded a significant portion of my book, with the booleans already used in numerous places. I’ll definitely keep this in mind for the future, though.


#15

You know, all this grenade talk reminds me of pineapple for some reason, which makes me hungry…


#16

[b]Inventory[/b]

*if (grenade !=1)
    You have ${grenade} grenades left
*if (grenade =1)
    You have ${grenade} grenade left

Just to make the syntax correct! (you can also tweak the numbers and include (grenade = 0) then have no text if you want to “hide” that there are any grenades in your game)

p.s: FIND and REPLACE is a beautiful thing!


#17

@nine
Indeed it is, but notepad++ doesn’t take enters into account and I’m afraid it might mess up the codes’ indents.


#18

What do you mean by enters? Carriage returns (line breaks)?
The standard find and replace won’t mess up your indents.


#19

@CJW Ah okay. I’ll replace the booleans with numeric variables then


#20

@Caddmuss
I transferred all the inventory item’s codes from booleans to numeric variables but I got this error message

line 51: invalid expression at char 17, expected OPERATOR, was: NUMBER [0]

line 51 is

*if Poisonous_darts 0