Show stats is multiplying inventory

I’m having trouble with code that is adding bullets multiple times.

The error I’m getting is, if you buy a gun (comes with 6 bullets) then a clip (6 bullets) , another 6 bullets get added to the inventory

My hunch is that the gun / bullet clip are adding every time the stats screen is checked

Is there a way to stop these bullets multiplying like this?

With the following example, 1 clip and the gun = 12 bullets, instead you get 18, I assume the gun’s bullets are being added again every time

		*goto top
	*if (gun = false) 
		*selectable_if (gold >= 10) #I'd like to buy the Gun
		
			“A Mark 1 Enfield revolver. This packs a punch even Sir Malcolm would be jealous of” says the shopkeeper, his placid eyes twinkling a little.
			*set empty_inventory false
			*set gun true
			*set bullets true
			*set bullets_number +6
			*set gold -10
			*goto top
	*selectable_if (gold >= 5) #I'd like to buy clip of bullets
	
		“Yes, if you are going to shoot things it’s worth going for it” says the shopkeeper.
		*set empty_inventory false
		*set bullets true
		*set bullets_number +6
		*set gold -5
		*goto top

What does your stat screen look like? Unless you also have *set ammo +6 in stats menu, it shouldn’t multiply like that.

edit: besides *rand re-rolling, I don’t believe there’s a way to manipulate vars by opening and closing stats screen.

1 Like

I can paste in the startup file and the stats file, they don’t have any bullets adding bits though
I just tested it on dashing don ,buying the gun creates 6 bullets
Buying the clip, 12!

Here is the full shop code if that is useful?:

*label shop
*set shop true
The hatch to the shop is rolled up and a well groomed older gentlemen in a white shopkeepers apron, blue bow tie and fez stands attentively in front of shelves stacked with various items.

A list is pinned to the countertop:
*label top
*line_break
Dynamite - 15 Gold Coins
*line_break
Gun and 6 bullets - 10 Gold Coins, in ordinary combat a successful attack yields 1 d 6 of damage, a 6 is an instant kill.
*line_break
Clip of 6 bullets - 5 Gold Coins per clip
*line_break
Knuckle Duster - 5 Gold Coins, adds +1 damage to every successful attack
*line_break
Provisions - 5 Gold Coins per pack, adds +5 to stamina
*line_break
Book on treating poisons - 5 Gold Coins
*line_break
Translation book - 5 Gold Coins
*line_break
Large framed painting of Queen Victoria - 100 Gold Coins
*line_break
*choice 
	*if (dynamite = false)
		*selectable_if (gold >= 15) #Dynamite please
		
			“An excellent choice. No adventure is complete without blowing something up” says the shopkeeper, his manicured hands folded neatly over his stomach.
			*set empty_inventory false
			*set dynamite true
			*set gold -15
			*goto top
	*if (gun = false) 
		*selectable_if (gold >= 10) #I'd like to buy the Gun
		
			“A Mark 1 Enfield revolver. This packs a punch even Sir Malcolm would be jealous of” says the shopkeeper, his placid eyes twinkling a little.
			*set empty_inventory false
			*set gun true
			*set bullets true
			*set bullets_number +6
			*set gold -10
			*goto top
	*selectable_if (gold >= 5) #I'd like to buy clip of bullets
	
		“Yes, if you are going to shoot things it’s worth going for it” says the shopkeeper.
		*set empty_inventory false
		*set bullets true
		*set bullets_number +6
		*set gold -5
		*goto top
	*if (knuckle = false)
		*selectable_if (gold >= 5) #Knuckle duster please
		
			“You could knock out an elephant with this” says the shopkeeper. “I know... I’ve done it” he says conspiratorially as he slides it across the counter to you.
			*set empty_inventory false
			*set knuckle true
			*set gold -5
			*goto top
	*selectable_if (gold >= 5) #Those provisions look tasty
	
		“These will fix you up. The mint cake is especially good” says the shopkeeper.
		*set empty_inventory false
		*set provisions true
		*set provisions_number +1
		*set gold -5
		*goto top
	*if (poisons = false)
		*selectable_if (gold >= 5) #That book on poisoning looks useful
		
			“How oft when men are at the point of death have they been merry, which their keepers call a lightning before death! Oh, how may I call this a lightning? O my love, my wife! Death, that hath sucked the honey of thy breath, hath had no power yet upon thy beauty. Thou art not conquered. Beauty’s ensign yetIs crimson in thy lips and in thy cheeks, and death’s pale flag is not advanced there. Tybalt, liest thou there in thy bloody sheet? O, what more favor can I do to thee, than with that hand that cut thy youth in twain to sunder his that was thine enemy?.”
			“Ahem. Anyway, a useful book.”
			*set empty_inventory false
			*set poisons true
			*set gold -5
			*goto top
	*if (translation = false)
		*selectable_if (gold >= 5) #That translation book looks useful
		
			“I think someone once said that to learn another language is to offer the hand of friendship” says the shopkeeper.
			*set empty_inventory false
			*set translation true
			*set gold -5
			*goto top
		*selectable_if (painting = false) #It is my patriotic duty to buy the painting
		
			The shopkeeper salutes the picture and starts to reach up to it carefully whilst humming the national anthem. He pretends to lift the painting from the wall and mimes wrapping the invisible picture.He mimics handing you the picture. 
			
			“That will be 100 invisible coins for the invisible painting please”
			*set painting true
			*goto top
	
	*if (museum = false) #Museum
		*goto museum
	*if (museum = true) #Leave the club
		*goto downstairs

Code looks good.

Again, check your choicescript_stats file for any *set ammo_count +6

1 Like

You found it!

*if (gun)
	*if comma
		*set inventory &", "
	*set comma true
	*set inventory &"Gun"
	*set bullets_number + 6

Many thanks! was driving me mad!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.