[Open Source] Adventure Game Engine: INVENTORY!

Discussion and feedback on Construct 2

Post » Mon Dec 26, 2016 8:35 pm

EDIT: R0j0hound's new and improved version with MUCH tighter events! https://dl.dropboxusercontent.com/u/542 ... y_mod.capx

Okay, it's based HEAVILY on the brilliant idea of @AlexFrancois and I used his post example as a launchpad (here's the original post: how-do-i-make-a-simple-inventory_p934190?#p934190)

I've hard-coded a lot of the stuff, so preferably a forum genius could tighten the code up and optimize it so it's more dynamic for folks wanting to use it without learning through the code, but here goes, v1.0 of the Z(ebbi's) A(dventure) G(ame) E(ngine) Inventory source! https://www.dropbox.com/s/cfbhwiuhjvbux ... .capx?dl=0

Feel free to use it, if it's actually of any use to anyone, as you can see, there's a couple of variables to sort out the current page, I WISH I could have gotten modulo to work to decide how many pages there need to be (for instance, if there's between 1 and 3 over the remainder of a division of 4) but so far, this will work for up to 16 items, more can easily be added by adjusting the code.

Hope it's of use, I'll keep working on the rest of the engine and sharing it as it's completed. PLEASE feel free to improve it and tidy the code and post you're updates, it could definitely do with it! :? :lol:
Last edited by Zebbi on Sun Jan 01, 2017 9:06 pm, edited 1 time in total.
B
41
S
12
G
14
Posts: 1,120
Reputation: 11,259

Post » Mon Dec 26, 2016 8:44 pm

Wow, I'm gonna take a serious look at this. Thanks for sharing with the community, mate.
B
16
S
4
Posts: 86
Reputation: 1,525

Post » Mon Dec 26, 2016 8:55 pm

LeuNoeleeste wrote:Wow, I'm gonna take a serious look at this. Thanks for sharing with the community, mate.

No problem! Please do let me know what you find, any bugs or what not!

I have the garbage bin there to remove items from inventory, as you can imagine it would be easy to use that function and switch it for whatever you need like, giving an item or using it, just click the item on the bin to remove it :D
B
41
S
12
G
14
Posts: 1,120
Reputation: 11,259

Post » Tue Dec 27, 2016 1:28 am

Thank you for sharing this. :)
B
135
S
33
G
17
Posts: 1,557
Reputation: 20,717

Post » Tue Dec 27, 2016 8:56 pm

No problem! Maybe a genius like @R0J0hound could take a look at how easy it would be to turn some of the hard codes more dynamic, things like the array events for each object should be able to be selected by the name of the sprite, and somehow work modulo into the expression so it only makes a new page if there's 1-4 items over each division of 4? (I'm probably being cheeky asking for this! :p )
B
41
S
12
G
14
Posts: 1,120
Reputation: 11,259

Post » Sat Dec 31, 2016 6:09 am

This will give you the maximum scroll value:
max(0, ceil(count/4)-2)

If you're setting the animations like this:
For each inventorySprite
--- set animation to array.at(loopindex+scroll*4)
B
92
S
32
G
110
Posts: 5,295
Reputation: 71,501

Post » Sat Dec 31, 2016 11:44 pm

R0J0hound wrote:This will give you the maximum scroll value:
max(0, ceil(count/4)-2)

If you're setting the animations like this:
For each inventorySprite
--- set animation to array.at(loopindex+scroll*4)

Just a quick heads up to thank you, I'll be implementing it as soon as I figure out what the hell I wrote last week! :?

EDIT: Seems to work so far! I'll add the other shortly...
Image
B
41
S
12
G
14
Posts: 1,120
Reputation: 11,259

Post » Sun Jan 01, 2017 1:22 am

@R0J0hound
Having a slightly hard time working this one out: Image
I need to figure out the X size of the array dynamically, at the moment it's kinda hard coded and I need to work out how to test for a change in the size of the array to correspond to the pages/slots?
B
41
S
12
G
14
Posts: 1,120
Reputation: 11,259

Post » Sun Jan 01, 2017 7:57 pm

I don't quite understand what you did with those events and the "but" variable. Best I can tell you're setting it up so it controls when the scroll buttons can be used.

If it helps here's the capx I did to figure out that expression above and work out how things could be simplified. As I said I didn't understand that bit so I did it a different way.
https://www.dropbox.com/s/l8hw93anmoofu ... .capx?dl=0
Last edited by R0J0hound on Sat Mar 25, 2017 5:04 pm, edited 1 time in total.
B
92
S
32
G
110
Posts: 5,295
Reputation: 71,501

Post » Sun Jan 01, 2017 9:05 pm

R0J0hound wrote:I don't quite understand what you did with those events and the "but" variable. Best I can tell you're setting it up so it controls when the scroll buttons can be used.

If it helps here's the capx I did to figure out that expression above and work out how things could be simplified. As I said I didn't understand that bit so I did it a different way.
https://dl.dropboxusercontent.com/u/542 ... y_mod.capx

I think I was trying to figure out which page the player was on and set the height, but I couldn't work it out with maths so I used some silly variables, I really appreciate you simplifying this!! I estimated it could be done in under 30 events but you took it down to 19, wow!! :shock: :D

I really appreciate this, I'll update the main post with this version!
B
41
S
12
G
14
Posts: 1,120
Reputation: 11,259


Return to Construct 2 General

Who is online

Users browsing this forum: mihirolover and 10 guests