Saving Inventory Loadout

Get help using Construct 2

Post » Sat May 28, 2016 3:43 pm

Hello all,
I Have been trying to make a inventory screen where I can select units in the squad and edit their inventory. It should save the Items\weapons in their Inventory for each game after until you edit it again. I have followed about 5 inventory tuts 2 that use arrays and I could not get them to work.

So this is the last one I tried and it worked
https://www.scirra.com/tutorials/4957/i ... -no-arrays

Is it possible to save the data of the inventory with that type of programming? If so how do I go about doing it?

Here is what my SquadEditor\Inventory Screen looks like.
http://imgur.com/f5u8W8H


One other problem I have with that Inventory is.. say I add one of the SMGs to weapon slot 1, Then remove it by Rclicking it in the weapon slot 1. If I try to add the same Smg to the same slot again then the Smg sprite does not show there In that slot. But say I instead added the Rocket launcher to weapon slot 1 after removing Smg then remove Rocket launcher from it, then add Smg to slot 1 again, it will appear. How can I make it show the graphic even if I deleted it from the same slot I am adding it to?
B
22
S
9
G
2
Posts: 27
Reputation: 2,636

Post » Sun May 29, 2016 12:57 am

By save do you mean exiting the game and then load the game and it has saved what's in the inventory? You could look at save games for that, where you can store the state of the game.

The problem mentioned at the bottom is probably some faulty logic but it would be just a guessing game without a capx or possibly a screenshot of the relevant events.
B
46
S
16
G
78
Posts: 2,166
Reputation: 46,349

Post » Sun May 29, 2016 1:34 am

Hey thanks for the reply.
Link to the logic
http://imgur.com/m6K5xXs

The inventory and your squad setup needs to be the same as it was when you restart the game. Also when in the game layout where the battle is, the inventory needs to be like you set it in the Squad\inventory editor.
B
22
S
9
G
2
Posts: 27
Reputation: 2,636

Post » Sun May 29, 2016 9:44 am

Thylacine wrote:Hey thanks for the reply.
Link to the logic
http://imgur.com/m6K5xXs

The inventory and your squad setup needs to be the same as it was when you restart the game. Also when in the game layout where the battle is, the inventory needs to be like you set it in the Squad\inventory editor.


I made a game different from your but I think it can help you with your problem. In my game you have a gun shop where you buy guns to upgrade your firepower. I have a saving mechanism in place that you can use here is the capx file

http://www65.zippyshare.com/v/1byvwy1x/file.html

Its organized as I use as little code as possible and if you have any questions about how I did something just ask. The gunshop inventory in my game saves the last gun purchased which is what you want for your soldiers.
Check out my awesome Android Game releases https://play.google.com/store/apps/deve ... ames&hl=en
B
38
S
18
G
24
Posts: 682
Reputation: 16,615

Post » Sun May 29, 2016 10:18 am

Thylacine wrote:Is it possible to save the data of the inventory with that type of programming? If so how do I go about doing it?


Yes it possibled. But the easy way will be looping trough the inventory objects and translate theire state to an array. Then store that array. And (looking at where you start from) that is what you wanted to avoid.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun May 29, 2016 3:52 pm

@PixelPower-
Thanks for the help I will try to understand your file!, If you ever need art or sound let me know, id be happy to work with you.

@99Instances2go-
I started with 2 arrays. the code for 2 array systems is still in my game set to disabled. I could not get them to work. Maybe I need to post the code for them instead.
B
22
S
9
G
2
Posts: 27
Reputation: 2,636

Post » Sun May 29, 2016 4:37 pm

Did you understand my code ? Where you able to make any progress in your game?
Check out my awesome Android Game releases https://play.google.com/store/apps/deve ... ames&hl=en
B
38
S
18
G
24
Posts: 682
Reputation: 16,615

Post » Sun May 29, 2016 6:03 pm

@PixelPower-
I just found a 3rd Array tut and I am trying to understand it. It seems to be working, but now I need to have more then one section of slots to put at my Arsenal spot. Very happy I am getting the arrays now. As soon as I am done setting it up I will be trying to make the save data like your game. Btw way I meant "ill try to understand your code" meaning I am not too smart at programming.
Thanks for your help
B
22
S
9
G
2
Posts: 27
Reputation: 2,636

Post » Sun May 29, 2016 7:01 pm

@Thylacine

Pixel shows you how to store variables in the local store. Wich is fine. There are tutorials enough about how to use the Local Storage. And frankly, this is very easy to learn. And you will when you are ready for that.

Just consider that the gamelogic in the given example needs only 1 variable to make the choosen weapens work. The variable 'BulletPower'. You can not choose a gun during play, the player is not holding sprites that represent a gun, there are not squads that have to be made, equiped, ... etc.

Looking at the grafical representation of your inventory, you have bigger plans. Looking at the code, you are just filling a inventory, without building a database that can actual be used later in the gameplay.

The arrays, you should use, have not as main function to fill up the inventory. They are essential in the actual gameplay. In fact, the inventory is just and no more then a grafical representation of the actors in the game.

They just happen to be easy to get stored in the Local Storage.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun May 29, 2016 9:08 pm

@99Instances2Go
You are right, but maybe I can still use Local Storage and Variables for something else more simple!
Ok so ive been trying to understand the array and ran into a problem. Can I get some help with the placing of another section of slots that would work with the first section.. So make it create a section for the Arsenal Items as well?
As of now I got another section, but the slots are still considered the same I guess. If I move one item on the right side down one slot, then the same item on the left section moves its item down one too..

Array Logic
http://imgur.com/7WbbOxI

Inventory edit
http://imgur.com/3r9430N
Last edited by Thylacine on Sun May 29, 2016 10:19 pm, edited 2 times in total.
B
22
S
9
G
2
Posts: 27
Reputation: 2,636

Next

Return to How do I....?

Who is online

Users browsing this forum: AllanR, Artcadev and 14 guests