Show Stats Bug?

If anyone’s still here,

Got a quick question…

I just don’t know anymore. So I made an inventory thing just like the equipment one, but modified a bit to decrease variables everytime players use them. Like potions and stuff. looks something like this:

    *label consumable
      You go through your things…
      *choice
        *if (potion_got) #Potion
          A potion that can increase your vitality…
          
          Potion: ${potion}
          *choice
            *selectable_if (potion >0) #Use Potion (1)
              You chug down a potion…
              *set potion -1
              *set health +200
              
              *goto consumable
            #(back)
              *goto consumable

The problem now is that everytime I press the Return to Game button and then back to the Show Stats then navigate my way to inventory, the potion variable bumps itself back to the number (like it was never used) but it still increases the health by 200. Is this some sort of bug? Because I see nothing wrong with the code (i think). Sometimes it even increases by it itself. (surpassing the original variable change that I did *set variable +1" (becomes 2)

Wow.


I think I can already imagine how’s your system will work. I doubt, tho, if multiple conditional checks (*if) is the case.

So… let me repeat your situation.
You want the stats_screen to shows all available Equipments and shows a set of radio checks to allow the player to equip one of those said equipments, correct?

1 Like

Yes! and I also want players to able to browse through items and consumable items and use them.
But I think that’s a similar case, and can be reprogrammed from the equipment code? I think…

Edit: Oh wait sorry not all available equipment, just the ones the players obtain through the game.

Hmm… I think the trick lies on using *ifs and *selectable_ifs on the *choice itself

This would be what I’ll do in your case. Prepare your body.

*label equipment
**Your stuffs**
_________________
*if (sword1)
   Sword1
*if (staff3)
   Staff3
etc.
etc.

*label equip
*choice
   *selectable_if (weapon != "sword") #Equip Sword
      *set weapon "sword"
      Sword Equipped.

      *goto equipment
   *if (weapon = "sword")
      *selectable_if (weapon != "sword") #You already equipped Sword.
   #Choices
   #Choices

Now that’s my code, let me dismantle it and explain it to you one by one.


The List
*label equipment
**Your stuffs**
_________________
*if (sword1)
   Sword1
*if (staff3)
   Staff3
etc.
etc.

Nothing much to explain. It’s pretty explanatory.


The Equipping thingy
*label equip
*choice
   *selectable_if (weapon != "sword") #Equip Sword
      *set weapon "sword"
      Sword Equipped.

      *goto equipment

If you don’t equip the sword, you’ll be able to choose this option (and equip the sword, ofc).


The "Already Equip This" thingy
 *if (weapon = "sword")
      *selectable_if (weapon != "sword") #You already equipped Sword.

The trick at this one is, to allows this #Option to show up if you equipped the sword, but keep it as “grayed-out” so the player can’t select it.


All in all, the idea is to have each options to be selectable when you don’t equip its weapon, and have it “grayed-out” if you equipped the weapon.

Do the similar thing to another piece of weapons/items.

However, if you’re already familiar with the multireplace command @{}, I think you can tackle this problem easier.

Edit: HAHA! I ninja-ed you, @Minnow :smiling_imp:

1 Like

Perhaps I’m too tired to be thinking about this clearly, but what about using a single *choice command and then using *if statements to show or hide the various #options only when they’re available?

Something like this...
*choice
	*if (sword) and (weapon != "sword")
		#Wield your sword.
			*set weapon "sword"
			You are now wielding your sword.
			*goto equipment
	*if (sword) and (weapon = "sword")
		#Stop wielding your sword.
			*set weapon ""
			You stow your sword, and are no longer wielding a weapon.
			*goto equipment
	*if (staff) and (weapon != "staff")
		#Wield your staff.
			*set weapon "staff"
			You are now wielding your staff.
			*goto equipment
	*if (staff) and (weapon = "staff")
		#Stop wielding your staff.
			*set weapon ""
			You stow your staff, and are no longer wielding a weapon.

Setting that aside, when you’re using *if with *elseif or *else, ChoiceScript will only allow one possibility to pass the check at a time, then will exit the block of code via the *goto commands *elseif and *else require. I feel like I’ve explained that terribly, so I’ll use examples.

*if (var1)
	All of these
*if (var2)
	will display
*if (var3)
	if all the variables
*if (var4)
	are true at the same time.
But...
*if (var1)
	Only one of these
*elseif (var2)
	will ever display
*elseif (var3)
	even if all the variables
*else (var4)
	are true at the same time.

I should point out, however, that you won’t get more than one *choice on a single page using a chain of *if statements like this. After each *choice there will be a page break. Which is why I suggested earlier considering putting all your *if statements inside a single *choice to control the visibility of the #options.

1 Like

So, basically what you want is a list of equipment first (easy enough) and then a choice set to equip whatever isn’t equipped. I think what you really want is to put all your “if” statements for equipping or not under a single choice, and not the other way around as you’ve done. Here’s how I’d do it:

*label EQUIPMENTLIST
Equipment:
*if (SWORD)
  Sword
  *if (weapon = "sword")
    (equipped)
*if (STAFF)
  Staff
  *if (weapon = "staff")
    (equipped)

*label EQUIPORNOT
*choice
  *if (SWORD) and (weapon != "sword")
    #Equip sword
      *set weapon "sword"
      Sword equipped.
      *goto EQUIPMENTLIST
  *if (STAFF) and (weapon != "staff")
    #Equip staff
      *set weapon "staff"
      Staff equipped.
      *goto EQUIPMENT LIST

I think this should produce the thing you want.

1 Like

You’ve got some replies here, but I have another possible code, a bit simplified.

*label equipment

Equipment

Currently Equipped: ${weapon}


All Equipment:

*if (sword)
    Sword
    
*if  (gun)
    Gun
    
*if (hammer)
    Hammer
    
*if (dagger)
    dagger
    

*choice
    *if ((sword) and (weapon != "sword")) #Equip Sword
        *set weapon "sword"
        *goto equipment
    *if ((gun) and (weapon != "gun")) #Equip Gun
        *set weapon  "gun"
        *goto equipment
    *if ((hammer) and (weapon != "hammer")) #Equip Hammer
        *set weapon  "hammer"
        *goto equipment
    *if ((dagger) and (weapon != "dagger")) #Equip Dagger
        *set weapon  "dagger"
        *goto equipment
    

Bit different from the others, but simple.

1 Like

Is this the same thing as what @Szaal advices?

I’m trying to wrap my head around it but so far I think I get the gist, and it seems like an ingenius idea! Let me try this along with @Miseri 's method.

1 Like

Cool! I think I get the gist of it, this is really smart. I’ll try it along side with @Szaal 's idea as well and get back.

For the label EQUIPMENTLIST, won’t it get an error if we don’t end the first IFs with a *goto or *finish?

Actually everyone’s code are exactly the same, with additional bling-bling of our preference, of course.

My code includes a QoL improvement where…
the notification text of “You have equipped this”
is replaced by a grayed-out choice “You already equipped the sword.”

@Minnow’s code includes a “sheathing” option that will allow your player to stop wielding any weapon.

@Miseri’s code is actually pretty similar with @seabean’s, but YMMV.


For pure list of *ifs, you won’t get the error.
But for the combination of *if - *else - *elseif, you’ll get the error.
*shamelessly put a link to his own thread

1 Like

Wow! this is pretty neat as well, Though I’m not sure about the multiple IFs check below the All Equipment:

Wouldn’t it give the same problem as I have now?

Nope. Worked fine for me.

1 Like

Lol, I am overwhelmed by all the code

1 Like

One minor thing, there should be a blank line in between each IF section in EQUIPMENTLIST in mine; as it is now, all the objects will display in a single line, which looks awful. Sorry.

As to whether it’ll get an error: No. Near as I can tell, Quicktest will return an error only if *else is involved … even though the thing will actually still work. If it’s just a single “IF” statement with no “ELSE”, Quicktest will let it pass.

And @Szaal is right, we’ve all basically given you near-identical codes with our own personal spin on presentation.

2 Likes

Lol. Let me re-quote my self.[quote=“Szaal, post:4, topic:28096”]
Prepare your body.
[/quote]

:laughing:

1 Like

Formatting is ugly, but here’s how it looks so you don’t have to try mine out.

1 Like

That looks great! You are too kind :grin:

Lol, I can’t stop laughing at how screwed my brain is right now. I’m at the point where things that should make sense don’t make sense and I’m fine with it. HAHAHA :joy:

1 Like

I’ve tried everyone’s (I think), and yea they are basically the same with only minor differences.

I really like @seabean 's simple format so I’ve kind of merged that with @Szaal 's and everyone elses and included a sort of 'Unequip" option. But I realize I don’t want it because it will make writing combat a pain due to the weapon variable I set to “(Nothing)” so if I type ${weapon} it will say: (nothing) and thats undesirable…

So now I am perplexed because I only gave the player 1 starting weapon, and the stats screen comes empty because it doesn’t have a choice if all the variables are met but still no other choice to make. like:

*if ((sword) and (pc_weapon != "sword")) #Equip Sword
    *set pc_weapon "sword"
    Sword Equipped!
    *goto equipment

This is solved if I add the ‘Unequip’ feature, but again it screws with the Weapon variable making ${weapon} = (nothing)

*if ((sword) and (pc_weapon != "sword")) #Equip Sword
    *set pc_weapon "sword"
    Sword Equipped!
    *goto equipment
*if ((sword) and (pc_weapon= "sword")) #Unequip Sword
    *set pc_weapon "(Nothing)"
    Sword Unequipped…
    *goto equipment

Still I can just add another variable entirely for writing like maybe weapon_noun and use that as the variable when writing combat. But I was just wondering if there is a solution without this…?