-
Inventory
Im working on some sort of wow-alike inventory system.
If someone can tell me how to embed a file to this post, then i can show you how it is at the moment.
At this point, im only stuck at 2 spots:
1. How to 'sort' the items in the backpack, so that they do not overlap eachother, and finds a free slot to 'rest' until use.
2. To use the items, like using a potion and then it replenish some health etc etc... but i think i can handle that one.
Anyone got some ideas of how to discover the result of the 1st problem?
-
Re: Inventory
I'm not a WoW palyer, so don't know the system (scared to play it as I'd likely get sucked in, and lose many hours of life lol)
But...
1) To find a free slot, add a flag to the item slots - on means it has an item in it, off means it's clear - then fast loop to for an off flag to find a free slot.
To sort the items, you could give them a value of some sort to determine what they are (e.g. health potions on 1, weapons 2, etc) then order using that value.
2) to use items, set flag on, do item effects, clear slot, etc, etc? Not entirely sure what the question on point 2 was.
Hopefully that should help.
-
Re: Inventory
You could use a sort of 2 dimensional string array or a list (magic deque can work well too) for the inventory (dimension 1 is the inventory slot, dimension 2 are the properties of the object). Then reference the items as strings. Makes it easy to find free spots and sorting is easy too (just use the array's sort function).
You can use Mod to wrap the slot dimension around to get a sort of grid (e.g. 4x4 by using slot mod 4).
I assume all your items are only 1x1 in size (like in wow), else it gets a bit more complicated.
You should search the forum. I'm quite sure someone already posted a working inventory example.
-
Re: Inventory
Asholay, i apreciate your ideas and knowledge/creativness.
You were perfectly right about the second question ^^
Random, your knowledge is a little too high at my point, so here is 2 questions:
1. The Magic deque is what? a extension? or something else.
2. Not sure i can figure out what the second part is about, from "You can use Mod......."
Sry about my not too experienced knowledge.
And yes the items is 1x1... 18pixels times 18pixels.
I've searched the forum, but it all shows the same thread. And imo the search engine isnt the best to work with.
Tho' im very glad for your answers, both of you ^^
best regards SomethingOdd
-
Re: Inventory
Well in general, an inventory is a little bit tricky to do. So you have to find a way that works for you.
Magic Deque is an extension that holds a set of data as if they were cards (they have an order, can be sorted, you can pick them out, put some in between, etc.).
"Mod" is a function that "wraps" numbers. So 6 mod 4 becomes 2. 4 mod 3 becomes 1, etc. You can use it to wrap a linear number into rows, like so:
column = index mod row_length
row = index / row_length
-
Re: Inventory
Ah and.. I don't know how you are searching - but when I just search for "inventory" I get several threads all discussing inventories, and even one that comes with a commented example that does exactly what you want.
-
Re: Inventory
Oh man.. that is just awesome!
You just saved my day ^^
Not sure what i do wrong, but im glad that you found it :)
+rep Random! totally!
-
Re: Inventory
That tut. is simply amazing
but the events are fairly long
and my mind sorta blows up whenever i copy and paste and try to do EVERYTHING RIGHT. So can someone sorta explain to me how that could be put into groups and if there's a simple way of redoing the objects so that it fits my project.
Wow i just found out there's a widget section lol
-
Re: Inventory
Widgets are an important new phase and we still need to get them moving forward more, so I am glad you are now aware of them Angelfox.
Using them, commenting, participating, and creating them is going to be very helpful and may influence the future of the product if enough users exploit the idea well.
-
Re: Inventory
I think MMF(3) should support the creation of interfaces and encapsulation for objects. This will make widgets a lot more useful.
What I mean is that for example the variables a widget uses, can be stored "private" within the widget and are not accessable from the outside. Then the author should be able to declare variables he wants to expose (make public), e.g. for initial settings or output.
It would also be nice to have immediate conditions in behaviours, that appear as actions of the object - and on the same line - functions (like marcello's power function object) and conditions that are exposed as functions and conditions of the object.
Ultimately it should be possible to put a lock on the widget - as it should not be nescessary at all for the user to look into it or know the details of the implementation. Also an object hierarchy would come really handy here, so a widget could actually contain a set of objects that are locked within it. Like this authors can create autonomous interface elements (that require no extra objects) and other complex widgets that JUST WORK.
It will also make the normal use of MMF much easier, as the interfaces will allow a user to keep his objects apart much better.