Inventory system, copy ID

Get help using Construct 2

Post » Sun Feb 19, 2017 9:50 pm

Hello there! ^_^ (capx included below)
So i have been studying and following this particular inventory system; https://www.scirra.com/tutorials/583/easy-inventory
And i have adjusted it to what i need - however i have problem of copying the ID of the ground item (pick up)
into the inventory (created item). The item that is on the ground will play a random number value of, lets say
'StrID' and 'VitID'.

Coptying the item frame from the ground to the inventory was easy and fine, but copying the ID value does not seem to work.
Anyone knows how to do it, if possible?

I uploaded a capx here;
http://www.filedropper.com/testshow
B
12
S
3
Posts: 164
Reputation: 1,530

Post » Mon Feb 20, 2017 7:03 am

Hi @Greaver,

In your logic and after the loop in your AddToInv function, just pick the right Slot and set variables with passed values in parameters. Have a look in the modified capx. https://dl.dropboxusercontent.com/u/507 ... ified.capx

Good luck for the next steps! :)
B
37
S
14
G
9
Posts: 62
Reputation: 7,233

Post » Mon Feb 20, 2017 1:55 pm

Sebastien wrote:Hi @Greaver,

In your logic and after the loop in your AddToInv function, just pick the right Slot and set variables with passed values in parameters. Have a look in the modified capx. https://dl.dropboxusercontent.com/u/507 ... ified.capx

Good luck for the next steps! :)


Hehe hey, great! Thank you so much!! ^_^
I have few questions though;

1. Browser thing, is this necessary for it to work? And what does it do? Cant figure it out.
2. arr_inventory.At(Self.slotID) - sets the frame to ID to match the item picked up - however what code can we do to also set the animation? Not only frame but animation too?
3. Can we store 10 different values? Or is there a limit? Hehe thanks in advance! ^_^
B
12
S
3
Posts: 164
Reputation: 1,530

Post » Mon Feb 20, 2017 4:44 pm

Hello again @Greaver, you're welcome. :)

1. Browser thing, is this necessary for it to work? And what does it do? Cant figure it out.

The Browser object can be very useful, in this case, to help debug your script with log messages. You can see this messages by displaying the console message of your browser (in my case I press CTRL+Shift+J on Chrome under Windows to show/hide the console). For more convenience you can also use a function to call this Browser object. I suggere for "cleanliness" and performances to disable this log messages when a project is in production.

2. arr_inventory.At(Self.slotID) - sets the frame to ID to match the item picked up - however what code can we do to also set the animation? Not only frame but animation too?

I don't have explore anymore your needs but I suppose, in the same way, something like "Set animation" of the Slot sprite to the animation value of the Item sprite ("YourSprite.AnimationName" expression) should do the trick.

3. Can we store 10 different values? Or is there a limit? Hehe thanks in advance! ^_^

I'm also currently working on an inventory system, fully stackable and dynamic, whith a hotbar for action shortcuts ("à la Diablo" or Minecraft in much simpler for the moment). I would say that you can store and do whatever you want, it depends on your approach and your vision, but in terms of methodology I think I will be gone on something more agile, but after all it's not essential and depends again on your needs.
B
37
S
14
G
9
Posts: 62
Reputation: 7,233

Post » Mon Feb 20, 2017 7:20 pm

Sebastien wrote:Hello again @Greaver, you're welcome. :)

1. Browser thing, is this necessary for it to work? And what does it do? Cant figure it out.

The Browser object can be very useful, in this case, to help debug your script with log messages. You can see this messages by displaying the console message of your browser (in my case I press CTRL+Shift+J on Chrome under Windows to show/hide the console). For more convenience you can also use a function to call this Browser object. I suggere for "cleanliness" and performances to disable this log messages when a project is in production.

2. arr_inventory.At(Self.slotID) - sets the frame to ID to match the item picked up - however what code can we do to also set the animation? Not only frame but animation too?

I don't have explore anymore your needs but I suppose, in the same way, something like "Set animation" of the Slot sprite to the animation value of the Item sprite ("YourSprite.AnimationName" expression) should do the trick.

3. Can we store 10 different values? Or is there a limit? Hehe thanks in advance! ^_^

I'm also currently working on an inventory system, fully stackable and dynamic, whith a hotbar for action shortcuts ("à la Diablo" or Minecraft in much simpler for the moment). I would say that you can store and do whatever you want, it depends on your approach and your vision, but in terms of methodology I think I will be gone on something more agile, but after all it's not essential and depends again on your needs.


Sorry i dont understand ur animation explanation, anyone else knows how to do this??
B
12
S
3
Posts: 164
Reputation: 1,530

Post » Tue Feb 21, 2017 6:54 am

However all is said! :D
Do you take the time to read the doc or do some research?

To change the animation, it's simple:
"Add action" for your Slot sprite at the same level of the previous change.
Choose "Set animation" and put the name of your animation in the value field.
You can pass it again by a parameter in your function, it depends on how you want to do it.
B
37
S
14
G
9
Posts: 62
Reputation: 7,233


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 26 guests