Array Database (need advanced users help :P)

This forum is currently in read-only mode.
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • So, i found a way to make system use some king of database and it's hopefully works except one thing.

    (You need to download this file :3)

    You have 3 arrays.

    1. Inventory

    2. In-game objects

    3. Database

    The database represents the tablet with object "id" and name.

    What i'm using in my example:

         x1    x2    x3

    y1   ?1     2     3

    y2 stick stone apple

    and when you drop item, system compare item's id and id in array and using name under this id to create object.

    This is pretty fine system but i can't make it works to load objects on start up. (?21 and ?25 events in example).

    And i again hoping on your help guys :P

  • This is pretty fine system but i can't make it works to load objects on start up. (?21 and ?25 events in example).

    I'm not sure what you mean. It works for me, loads the items from the array and shows them at the correct places. I can place items in the inventory, I can move them around and they get saved when exiting the application. The next time I start everything is loaded correctly as it was when exiting.

  • > This is pretty fine system but i can't make it works to load objects on start up. (?21 and ?25 events in example).

    I'm not sure what you mean. It works for me, loads the items from the array and shows them at the correct places. I can place items in the inventory, I can move them around and they get saved when exiting the application. The next time I start everything is loaded correctly as it was when exiting.

    I want these events to replace on these but i when i'm trying to do it, it doesnt works.

  • Please excuse me, but I still don't understand.

    Do you want the inventory to be saved everytime when it is changed, instead of just on exiting?

    I mean, it works, right? Why would you want to change it?

  • Please excuse me, but I still don't understand.

    Do you want the inventory to be saved everytime when it is changed, instead of just on exiting?

    Sorry for my bad english.

    So ok, there are 2 ways to create necessary object.

    First one:

    <img src="http://s1.ipicture.ru/uploads/20111102/zA72Xk5J.png" border="0">

    It's inconvenient way, because you need to add every id by yourself every time when you wanna add new object in game.

    Second one:

    <img src="http://s1.ipicture.ru/uploads/20111102/yzsWVOiT.png" border="0">

    This way using database array to detect necessary object and it's even more easier then first

    On startup event, i have first way to create objects (where i need to type every id) but i want make it like in second one but I can't do it.

    I hope now you understand :<

  • Ah, yes, now I see! I'm sorry for being so numb sometimes :)

    I'll try to make it work.

  • Here you are:

    http://www.mediafire.com/file/3rb8r4xz1gzdkd5/database_array_simplified.cap

    It was just a matter of indirect referencing, if you look at the events you will instantly see what I mean. But feel free to ask, if it is not obvious.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here you are:

    http://www.mediafire.com/file/3rb8r4xz1gzdkd5/database_array_simplified.cap

    It was just a matter of indirect referencing, if you look at the events you will instantly see what I mean. But feel free to ask, if it is not obvious.

    Thank you very much!

  • Here you are:

    http://www.mediafire.com/file/3rb8r4xz1gzdkd5/database_array_simplified.cap

    It was just a matter of indirect referencing, if you look at the events you will instantly see what I mean. But feel free to ask, if it is not obvious.

    I found some kind of bug. When system using id from array it uses id thats compare of array index (id = 3 array = 3,1)

    I added 3 objects that is not compare array's indexes and 1 which is compare. First 3 doesn't work and last one works fine.

    screen of array

    cap file

  • The next time I start everything is loaded correctly as it was when exiting. ...

    ___________________

    Diablo 3 Items

    try to do it with colorblock1 colorblock2 and stoneblock ._.

  • An index is a number used to enumerate things. By nature this has to be a progressive integer.

    An array also uses integers.

    Something like '3,1' is not a number to Construct, so it interprets it as a string.

    For you to not lose overview, use the array 'database' as a simple 1-dimensional array to store the names of the objects:

    stick stone apple colorblock1 colorblock2 stoneblock

    Now you may reference the object by its index (stick = 1, stone =2, ..., stoneblock = 6)

    When filling the inventory, put in this index, e.g. if the second slot of the inventory should contain an apple, then inventory(2) = 3

    To look up the name, you use database(inventory(2)), which resolves into database(3), which is "apple", because the third item of database is "apple"

  • An index is a number used to enumerate things. By nature this has to be a progressive integer.

    An array also uses integers.

    Something like '3,1' is not a number to Construct, so it interprets it as a string.

    For you to not lose overview, use the array 'database' as a simple 1-dimensional array to store the names of the objects:

    stick stone apple colorblock1 colorblock2 stoneblock

    Now you may reference the object by its index (stick = 1, stone =2, ..., stoneblock = 6)

    When filling the inventory, put in this index, e.g. if the second slot of the inventory should contain an apple, then inventory(2) = 3

    To look up the name, you use database(inventory(2)), which resolves into database(3), which is "apple", because the third item of database is "apple"

    Sorry, but i'm don't understand this:

    hen filling the inventory, put in this index, e.g. if the second slot of the inventory should contain an apple, then inventory(2) = 3

    To look up the name, you use database(inventory(2)), which resolves into database(3), which is "apple", because the third item of database is "apple"

    Can you show me? :3

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