Array help

0 favourites
  • 11 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Ive made an inventory where you can pick up an drop but when I drop I want the object to spawn by the player. I set up some code but it didnt work, can i get an explanation on what Im doing wrong?

    Ive blacked out the unimportant events and the border between events on the layouts, top one is the game layout, bottom is the menu.

  • Pretty much impossible to tell from a screenshot. I would suggest putting some debug logging in, in the form of pushing text to an array. It is useful for working out where things are going wrong. Also look at the array in debug view to see what the value is at 0,y. What is actually wrong, is the animation not as expected? Is it spawning the item? It's not even clear if RemoveFromInv function runs at all and it picks up IDREMOVED value correctly.

  • You are looping through every single value, in X and Y, and deleting (and pushing) only X=0. You haven't explained how your array is organized, but you should just be searching in one dimension for the item to drop, then flagging the row with IDREMOVED (maybe). As says, there's just not enough here to really know how to help.

  • So heres some more info- IDREMOVED tells me what the object ID ive removed from the inventory (I have that array set up very well, it works fine so really doesnt play a part in fixing this), the information is correctly being put into the array using it, it will be there when I return to the game but it didnt remove them correctly. A few times my Item object would spawn but only be the first frame, if I removed more than one it would only spawn one, ect. I got the same effect just using a function, "DropItem" when you return to the game layout. It would only spawn one item and only the first frame, thats why I switched to an array.

    I can give yall the capx but it is veeery messy.

  • I would share the capx on here or in pm, I can debug it. Explaining it won't really help get to the cause of the issue here.

  • Here it is: https://www.dropbox.com/s/46xcc4l9mj8ex ... .capx?dl=0

    Im using a few addons with it, rex Moveto and rex PushOutSolids

  • Bump, still need help with this

  • Please provide some instructions on what to do to test.

  • You move over an item in the game window with WASD, press E to pick up. If you go to the menu again and see the item in there, you click to drop. When the item drops I had mixed results of it not dropping and it dropping only one item (if you dropped multiple) and it only being the first frame. My attempts at it have changed a lot so the code isnt the same for me anymore (still havent figured it out) but the code should be under these folders in the Game Code event sheet

    Objects > Chest > CHESTADD

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • a) just "For each X"

    b) set frame to CurValue (not CurX)

    c) just clear the array at the end. Deleting and pushing in the middle of a Foreach generally is a bad idea. Your DropItems starts as empty, so just empty it again when done.

  • EDIT- It works! Had a little problem but I fixed it, it works perfect now! Thank you so much for the help!

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