Inventory Management using Functions

This forum is currently in read-only mode.
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • Hello! I am in the process of creating a action/adventure game in Construct Classic r1.2, and to accompany that i am creating a inventory.

    That inventory consists of an array. The objects are read from the array using single values. For example, a key has the value 1 and a sword the value 2. You get the idea.

    This works good, but i would like to access the Inventory array easily using functions and function parameters. So far i have managed to create a function that searches for either a free spot, or for an object of the same type and adds the object to the inventory.

    The problem is removing objects. What i am attempting to do it Pretty much the same as with adding. I'd like to have a function that checks if the object specified in the function parameter exist in the Inventory. So far my attempts have been successful.

    But from there, i'd need that function to fire another function, one that tells what object has been removed, or if it doesnt exist in the inventory (or in the quantity required).

    I have not figured out a simple and flexible way to perform this, so now i am turning to the community, and to people with better Construct knowledge than myself.

    I have stripped down my game to the bare minimum, although i fear i have removed an important object/event and therefore it is not functional.

    But hopefully it will give you a good idea of what i have at the moment and enabling you to give me pointers at what i should do next.

    Due to the stripped down .cap file's inability to function properly, i will also be providing you with the full (current version, its far from finished) .cap file for the game i am attempting to create.

    Download the stripped-down version here

    Download the "full" version here

    Thank you :)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Bump..

    http://pappersduva.blogg.se/images/2011/forever_alone_144412754.png[/IMG]

  • If I were you, I'd rather make a function that would check the inventory to see if the param object is present. (said function would be called from the collision detection between char & door)

    The function would return either 1 if the object is present or 0 if it is not.

    I'd test that return in a subevent. If it is equal 1 then I'd remove the object from the inventory array (thanks to a dedicated simple function that would remove param object from the array) and open the door. If it is not, play a sound, or insult the player and do whatever. ^^

    "You need a KEY dumbass !"

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)