Array-based Inventory Items and their Effects

Get help using Construct 2

Post » Thu Dec 05, 2013 1:02 pm


Needing some guidance here. Again, I feel like I'm overlooking a very simple way of doing this...

So, first off, I have an inventory stored in an array which counts items picked up, dropped, amount, etc...

First query: however, I'm trying to understand how to apply an 'as long as item is in inventory' effect (example: player has Boots of Speed - add 50 to speed variable on the player) but I can't figure it out.

I'm currently comparing a value in the array, checking if it's true and then, on true, doing the 'add 50 to speed'. This constantly adds every tick though.

How would I get this to just be a once-off effect?

As well, how would I get this effect to be removed when the item is removed from the inventory? Would this apply to items 'stacking' onto the same variable (so two different items altering the speed of the player)?

Thanks in advances, everybody. :)
Posts: 5
Reputation: 310

Post » Thu Dec 05, 2013 1:12 pm

I think your logic is wrong. Instead of constantly checking if an object is in your array and apply its effects, you should only update your game state when you add/remove something from your inventory. On Pick Up boots > add to inventory and add 50 speed. On Drop boots > remove item from inventory and sub 50 speed.
Posts: 132
Reputation: 2,637

Post » Thu Dec 05, 2013 1:15 pm

if true - trigger once - add speed

if false - speed is startingspeed+50 - trigger once - subtract speed

If you are able to check if it's true you are also able to chance this value to false I presume. So set the value to false when not in inventory. And th
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
Posts: 6,160
Reputation: 19,775

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 4 guests