Saving Inventory Loadout

0 favourites
From the Asset Store
Match the similar cards with each other and free all animals!
  • 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?

  • 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.

  • 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.

  • 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.

  • 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.

  • 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.

    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.

  • Did you understand my code ? Where you able to make any progress in your game?

  • 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

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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

  • When CurX >23 ... give it a new tx so it starts drawing on the x position of the first arsenal.

    The array must be (on the X-as) bags + arsenals width.

    Place in the array on x=0 to x=23 will then be the bags.

    Place in the array on x=24 to x=.... will then be the arsenals.

    The array is zero based.

  • Thanks 99Instances2Go I will try that but maybe you can help me with this new Array I am trying aswell.

    Trying new array system, Set up just like the example, and just like the last array system my sprites with frames play on start out.. so all "Item" sprites and "Slot" sprites play to end of frames.. In example they do not, I do not know why. In the other Array system Set it to stop animations of those sprites so that they would not play. It was ok for the other system , but this one needs slots to change Frames to show "Item" in them. I do not see anything the examples have done to make the animations not play. I like this system better then the last but I dont get how to get it to work with the animations playing when they are not supposed too..

    Example Tut link-

    https://www.scirra.com/tutorials/583/ea ... ray/page-1

    Example playing image-

    http://imgur.com/gIezvbO

    My game image with new system-

    http://imgur.com/xx1DtVr

    My games Logic same as examples.

    http://imgur.com/tadmTAQ

  • B4 you set the the animation frame. You just stop the animation. Its an action under sprite ... section animations .. stop.

    Event 95.

  • I tried that already, and again. It wont change the slot animation frame when I click on an item If have Stop animation. What I dont get is, in the example they do not have Stop animation, it just seems to not play the animation. Why is that?

    Example Tut link-

    https://www.scirra.com/tutorials/583/ea

  • Because they have the animation speed set to zero in the sprite-animation-editor.

    And they use a dedicated sprite with 1 frame of all the items.

    If your animations keep gooing after you told them to stop, then you are including the inventorum events sheet into a game sheet where you tell them to animate, or something close to that.

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