"Already Purchased" feature?


  • Posts: 59

In my game I have a shop where you can purchase a variety of upgrades and costumes for your character. I want to make it so when you purchase the item, the item will become 'sold out!' and you cannot buy it again. The problem is if you leave the shop and then return later, you will be able to purchase the item again, even though you already have it.

Obviously I can create an attribute for EACH item in the shop that determines individually if the item was bought or not, to fix the problem, but I was just wondering if there was a better way to do this, like perhaps only having one attribute, but applying it separately for each item in the shop. Or something similar.

Help would be greatly appreciated. Thanks!  ;D


  • *
  • Posts: 1961
This could be achieved with a "binary string". For example, if your shop has five items, at the start of the game, the string would look like this: "11111". After the second and fifth items in the list have been purchased, the string would look like this: "10110".

You just have to interrogate the "bit" that represents the item number in the store, to determine if it has been purchased or not.

The various text manipulation blocks can be used to achieve the reading and writing of the bits.
Visit www.TheStencylBook.com - the only published book for learning Stencyl.


  • Posts: 59

Perfect! Exactly the kind of thing I was looking for thanks man!  :D