ID:159944
 
Hello all, I'm just about to stat working on my inventory but I'm not exactly sure where to start and what I need to know when making one. My objective is to make an inventory system something like the Backpack in WoW. I'd like to have the squares there and when I get an item, it goes to an empty one. And I guess it wouldn't hurt to have it so I can drag the items around in the cells.

Here's a picture of reference if anyone out there needs one:
http://www.theaveragegamer.com/wp-content/Screenshots/ MurlocRPG/Murloc%20RPG%20-%20Blacksmith.gif
I'd suggest Lummox JRs tutorial on skins since it covers a basic start on grid based inventories. From there, it's best you browse the skin tutorial.
In response to Schnitzelnagler
I have a basic grasp of how to use grids and I've looked over some already made inventory systems but I still cannot relate them to how I want mine to work.

I thought of having multiple grids, one for each slot, and then when I want to gain an item, loop through them for the first empty one and place the item there. Problem is, I'm not sure how to achieve that. Also, I'd like to remove the object name from showing up with the picture, I'd like just the image.
In response to DisturbedSixx
DisturbedSixx wrote:
I'd like to remove the object name from showing up with the picture, I'd like just the image.

Seems more people have that desire.
Maybe one of us should launch a feature request?
In response to Schnitzelnagler
I don't think it needs to be a feature really, I'm sure there are ways to remove the name with code and I have a few in mind. But first, I need to figure out how to get my boxy effect that I so long for. >.>

Do you know if it's possible to assign variables to grids?
In response to DisturbedSixx
It seems as though I have succeeded a bit. If you're still wondering on how to remove the names, I have a very easy method:
for(var/obj/O in contents)
O.name=null
src<<output(O,"invgrid:1,[++i]")
In response to DisturbedSixx
I wasn't wondering that, since this method and an even better one was debated in the thread I liked you to already.
I was under the, obviously wrong, assumption that you'd read it.
Yet, as you can read in the thread, this and every method that was come up with, still provides some drawbacks.
In response to DisturbedSixx
From what I know, some people achieved this boxy effect by having a box icon and outputting that along with the item...

I suppose you can have it set via the CSS (style) option for the icon as well (though you may need to browse_rsc it but I am taking a guess) but you can always make a border thicker (and somewhat deeper looking) for a temp. solution.

I assume you have the basic idea of how to use grids, this snippet I'll show will output items in X # of rows with each row having 5 columns:
var
column = 0
row = 1
for(var/items/I in M) // M = usr or whomever
if(++column >= 6) // This increases the column by 1. If the column is at least 6 (which we don't want since we want 5)
column = 1
row += 1 // Increases the row... obviously

M << output(I,"GridID:[column],[row]")

winset(M, "GridID", "cells=5x[row]") // resizes the grid - which is important! Especially if you drop an item!!
// Note that the most the column could be is 5 in this snippet but row can be X amount.


In case you are wondering about the ++var and var++ difference:

++(var) = adds 1 to var and returns the new value
(var)++ = returns the old value of var THEN adds 1
var +=1 = adds 1, no values returned.
The hardest part about doing this system is not being able to hide the atom name. There are crappy hacks like using dummy objects and setting the objects name to null, but I think they all suck.

What I did in my current game is to make the inventory a associative list with the objects grid location set equal to the object, so that way you can reference the object by its location.

The best method I came up with for a drag and drop inventory is setting the mouse_drag_pointer for object at New() like this.

obj
Equipment
New()

mouse_drag_pointer = icon_state
..()


Then you would use MouseDrop() and it's built-in varables like src_location and over_location to change/swap the position of the objects in the grid. You would use over_control to perform different actions when you drop in different controls or you could make it do nothing for some controls.

If you need more detailed explanation let me know, but honestly if you want the inventory look like wow's you will have use client screen objects.