Inventory Management using Functions

For questions about using Classic.

Post » Tue Jul 26, 2011 10:55 pm

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 :)
B
3
G
1
Posts: 4
Reputation: 483

Post » Sun Jul 31, 2011 2:12 pm

Bump.. [IMG=450x406]http://pappersduva.blogg.se/images/2011/forever_alone_144412754.png[/IMG]n00bDooD2011-07-31 14:12:39
B
3
G
1
Posts: 4
Reputation: 483

Post » Sun Jul 31, 2011 3:51 pm

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 !"
Kyatric2011-07-31 15:54:53
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests