The Daily Click ::. Forums ::. Klik Coding Help ::. Inventory System Help
 

Post Reply  Post Oekaki 
 

Posted By Message

vinicio



Registered
  11/04/2015 21:20:09
Points
  142
11th November, 2016 at 11/11/2016 21:14:02 -

Im making an adventure game with an inventory system however im having trouble, i have 8 inventory slots that are the same active with diferent ID's, i have global strings that put the name and object in the inventory
Example:
Item1="Camera" Slot1="Camera"
Item2="Ticket" Slot2="Ticket"

the problem comes when i grab and delete said items, for example, in a puzzle i want to use the camera and then it will be deleted from your inventory or i grab an item and i want it to be in the next free slot, however i havent managed to program something that helps, i cant do set Items for each active because my game is non-linear and there are multiple puzzles that can be solved in diferent order how the player wants.
anybody got an idea?

 
n/a

Demondevilmon



Registered
  29/12/2014 18:58:20
Points
  152
12th November, 2016 at 12/11/2016 20:02:32 -

Well i am not sure if i understood your question.
U want to pick something up and put it directly in the next free slot?

Imagine ur Inventory has 5 Slots [][][][][]

The first 3 Slots are filled with items [x][y][z][][]

At start u run an event on loop(times=numbers of slot)

When ur NOT over the maximum of slots
+ Check if current slot is empty.
-> If yes write slot number into NextEmptySlot and stop loop.
-> If no move on to the next slot.

When ur over the maximum of slots
-> Write down that inventory is full. Stop loop.

Now u got the number of the NextEmptySlot saved

Next time u pick up an item
+ Inventory is not full
->write the itemID in the Slot with the NextEmptySlot number.
__________________________________________________________________
For the Camera using thingy...
Are u using the camera by picking it up from the inventory or is the game telling u at some point "Do u want to use the camera?"?

Greets DD

Edited by Demondevilmon

 
I am not a hero... never was... never will be.

vinicio



Registered
  11/04/2015 21:20:09
Points
  142
13th November, 2016 at 13/11/2016 01:26:19 -

Thanks a lot for the answer, thats exactly what i wanted to do!


As for the camera using thingy my inventory system as it is right now has you equip the item by holding the button and choosiong one of 8 directions, once equipped you go to a interactable object and then use it with the interact button, to de-equip the item you just push the invetory key once. now also i want to know how to delete said items if they are used only once, some of the items in my game have multiple uses but others do not, i want it to check for the specific item in a specific slot and then delete said item from that slot.
sothing like this using your NextEmptySlot example:
+ if Z key is pressed
+ player is overlaping door
-check for string "key" in a slot and then set it to ""



 
n/a

Demondevilmon



Registered
  29/12/2014 18:58:20
Points
  152
13th November, 2016 at 13/11/2016 06:57:04 -

How about u additionally display if an item has unlimited or limited uses?
So f.e. if u pick up the camera the first time which is perhaps of unlimited use by picking it up u additionally save a number to the camera which is in that case maybe -1 (for unlimited)
[f.e U got an array with one row for the items and below one row for the uses. Lining up over another]
[Camera] [Potion]
-1 1

If u pick up an healing potion or something which is of limited use u put it in a slot with adding usecount +1.
If Usecount drops to zero delete Item from inventory.

The upside is that this system will work for every item now. The downside is that u have to save an additionally information but it will be worth it.

Greets DD

Edited by Demondevilmon

 
I am not a hero... never was... never will be.

vinicio



Registered
  11/04/2015 21:20:09
Points
  142
16th November, 2016 at 16/11/2016 00:11:56 -

Sorry for the late reply.
any way while that sounds really good im already having alittle bit of trouble in the invenotry system, im using global strings since it makes it easier for me to remember,i dont think im doing right since im not percevieng any changes i should have specified that my item menu is a sub-aplication.
i think i might know how to solvw it, but i dont know how to calcualte a range of global strings, like i want to calculate from the first to the last global string.
sorry if you find this annoyng im still a newbie in this.

 
n/a

Demondevilmon



Registered
  29/12/2014 18:58:20
Points
  152
16th November, 2016 at 16/11/2016 00:19:47 -

Well honestly i don't use global values for inventories and i have not so much exp with globals.
Sub application? U mean u have ur inventory in an extra application? D:
I use Sub applications for datadisplay of arrays or stuff like that, but ... hm ... Handling values over applications for two things which are normaly in one app seems to be more complicated than necessary.
But i respect your way

Edited by Demondevilmon

 
I am not a hero... never was... never will be.

vinicio



Registered
  11/04/2015 21:20:09
Points
  142
16th November, 2016 at 16/11/2016 01:29:01 -

well the thing is since global values and string stay over frames so i've used them in my other projects to calculate things like lives and money to keep them the same in all the levels, menus, etc.
i tried to do it equally in here because of the non linear nature of my game so it keeps the same values over frames, like one player might do one section and may have found an item and then continues in that section, but another player might find the same item and then head back to another section where it finds another item.
as for the sub-app. i usually use them for pause menus and other stuff like that, i make another frame in the same aplication, make it smaller than the window an then make it appear at the center under certain conditions.
However since you are not having any trouble whatsoever doing something simple like this then im doing something wrong, do tell what im doing wrong.

 
n/a

Demondevilmon



Registered
  29/12/2014 18:58:20
Points
  152
16th November, 2016 at 16/11/2016 14:00:06 -

Well i think a little bit ahead... is there a saveoption in ur game?
If so will it save the whole game as a freezed version? Are u saving data with ini or array?
Because if u use array u can also load the information at any frame. Would be interessting if and how ur going to make it possible to save data.
What happens if ur inventory appwindow is open and the player doesn't close it but just click back on the first appwindow to continue playing?
Are there any securities for that not to happen?
I mean maybe i am wrong. I never used this way to implement an inventory.

At the end, everyway is the right way, if all ways are leading to the same destination.

 
I am not a hero... never was... never will be.

vinicio



Registered
  11/04/2015 21:20:09
Points
  142
16th November, 2016 at 16/11/2016 21:15:39 -

is not implemented yet but there will be savepoints, and only one save slot, i usually use ini since i dont know how to work arrays.
as for the window, sub-apps work in the way that meanwhile an subapplication is open, you cant control what happens on the back(unless you want to)and it does not open as another window in your desktop (unless you want to), it appears as frame in front of your actual frame, it appears without borders so it gives the illusion of a pause menu that is programmed in the same frame, you can make the window come from a different aplication althogether but i dont see its utility.
so in short theres no problesm with subapplications unless you dont know configure them easily.


 
n/a

Demondevilmon



Registered
  29/12/2014 18:58:20
Points
  152
18th November, 2016 at 18/11/2016 03:03:36 -

ok so lets get back to ur original problem.
U wanna work with global strings. U wann work with a range of global strings.
So u need to specify how many slots ur inventory has.
f.e 10
so u can just use 10 global strings from all global values.
So u can limit ur loops on 10 times.
U know what i mean?

greets

 
I am not a hero... never was... never will be.

vinicio



Registered
  11/04/2015 21:20:09
Points
  142
19th November, 2016 at 19/11/2016 04:28:30 -

yes i know, my inventory has 8 slots, all global strings, labeled item1,item2,etc.
the problem is that i dont how to get the range of global strings

 
n/a

Demondevilmon



Registered
  29/12/2014 18:58:20
Points
  152
21st November, 2016 at 21/11/2016 12:42:35 -

When u say range u mean the number of letters in each string?
u can receive globals values under
->Specials->recieve global values.

That u would need to put in a Textobejkt and than use a loop to count a letter, go to the next letter and count it again until u reach end of it.

 
I am not a hero... never was... never will be.

vinicio



Registered
  11/04/2015 21:20:09
Points
  142
23rd November, 2016 at 23/11/2016 02:46:54 -

im thinking more that it dettects that for example "key" is written in one of the global strings

 
n/a

Demondevilmon



Registered
  29/12/2014 18:58:20
Points
  152
24th November, 2016 at 24/11/2016 00:46:02 -

I don't understand why u would need that?
All ur items are predefined right?
U have Key as defined item in ur game?

U don't allow people to rename an item to "key"?
It would be much easier to give every item a number like key=1 and if global value is 1 u know that one is key.
If u only wanna know in which slot what item is...
Checking for strings is more complicated than checking numbers.

I mean ... maybe u want that to be... than... u would need to look for specific names in strings.
F.e. Check letter by letter for k,e,y and if all are positiv that is key... and yes you would need to do it for all words.

Edited by Demondevilmon

 
I am not a hero... never was... never will be.

vinicio



Registered
  11/04/2015 21:20:09
Points
  142
24th November, 2016 at 24/11/2016 05:08:53 -

yes i do have predefined items, with what you just said i realized that i should do it with values instead of strings.
the thing was that usually used strings because i memorized text faster than numbers associated with items. iguess i was finding a way to make it work but instead ill do it with values, im sorry if this thread has taken too long to end in something simple as this i didnt think it would drag on like this.

 
n/a

Demondevilmon



Registered
  29/12/2014 18:58:20
Points
  152
30th November, 2016 at 30/11/2016 21:55:39 -

It's ok.
Another hint maybe.
When i need to work with alot of numbers i start making a list on paper with the number relativ to the objects so i can look it up in a sec

Have fun!

 
I am not a hero... never was... never will be.
   

Post Reply



 



Advertisement

Worth A Click