ID:158770
 
Okay, I have posted a topic like this before but I have edited my code a LOT. So here is my new backpack code:
mob
var/list/BACKPACK=list()
var/tmp/row=1
var/tmp/col=1
var/tmp/current=1
var
BP[10]
proc
UpdateBackpack()
for(var/obj/O in BACKPACK)
winset(src, "backpack", "current-cell=[col],[row]")
NEXT:
if(BP["[current]"] == TRUE)
++current
++row
++col
if(row == 10 || col == 10)
alert("Too much in invintory.","Error")
return
else
goto NEXT:
else
src << output(O,"BP:[col],[row]")


The problem? It does nothing...I test it by adding an object to the BACKPACK list and calling the proc at mob/Login(), can anyone please help me? The skin reference is no help anymore, I just can't get this...

Thanks.
Don't use goto.

Also: no damn idea what you're trying to do there.

This is what I'd do:

var/const/WIDTH = 10

var/x = 0
var/y = 0
for(var/obj/O in backpack)
x = x % WIDTH + 1
y += (x==1)
src << output(O, "backpack:[x],[y]")
//cut off un-needed rows
winset(src, "backpack", "cells='[WIDTH]x[y]'")
//fill any leftover cells with empty
for(x++; x <= WIDTH; x++)
src << output(null, "backpack:[x],[y]")


Also: convention is that all-caps variables are constants.
In response to Garthor
It still displays nothing...
In response to Hi1
I've tested it, it works fine (though I forgot to change one instance of "grid1" to "backpack" when posting it).

Are you actually calling the proc when the backpack list changes?
In response to Garthor
I'm using:
mob/Login()
new/obj/CLOTH/Shirt(BackPack)
UpdateBP()


That's a snippet of my login code, that's how I test it.
In response to Hi1
The location of something can't be a list. The object can be IN the list, but it needs an actual location (like src, which also puts it in contents). You'll need to add it to the list after creating it.
In response to Garthor
Garthor wrote:
Also: convention is that all-caps variables are constants.

More like #define macros, no? (And, of course, those aren't necessarily 'constant')
In response to Garthor
Thanks, got it working!
In response to Kaioken
Preprocessor macros also, by convention, use all caps. They can be thought of as the functional equivalent of constants, in that they are always performing the same set of operations on a given input.
In response to Garthor
(Ah, then everything can essentially be thought of as a[n equivalent of a] constant. =P
Also, similarly, a macro could expand into anything.)