ID:178422
 
Ok, I know how to use the original "usr.contents" but how do I create one manually. I have it all assigned in variables:

Stat()
var/inventory = null
statpanel("Inventory", inventory)

then like a get verb:

obj/sword/verb/get
set src in oview(1)
src.loc = usr.inventory

but it doesn't show up in the inventory as always any help in this will be very much apreaciated.



Every mob already has a contents so you dont have to define invetory. look up contents in dream maker
Jinks wrote:
Ok, I know how to use the original "usr.contents" but how do I create one manually. I have it all assigned in variables:

Stat()
var/inventory = null
statpanel("Inventory", inventory)

then like a get verb:

obj/sword/verb/get
set src in oview(1)
src.loc = usr.inventory

but it doesn't show up in the inventory as always any help in this will be very much apreaciated.

You need to use contents for that still. Even if you correctly defined mob.inventory as a list (which you didn't), a list is not a valid value for atom.loc--which must always be another atom. src.loc=usr.contents is also incorrect, because usr.contents is not an atom; usr is.

The correct line is loc=usr (since src.loc is redundant), or Move(usr).

The contents list is a special list; adding to it changes an atom's loc value to whatever owns the list, and vice-versa. But other lists don't behave this way.

If you have another list, you can add atoms to it at will, but their location doesn't change. For example, suppose an RPG character could wear multiple pieces of armor at once:
mob
var/list/armor

proc/WearArmor(obj/item/armor/A)
if(!armor) armor=list()
armor+=A
A.suffix="(worn)"
proc/RemoveArmor(obj/item/armor/A)
if(!armor) return
armor-=A
A.suffix=null
proc/TotalArmorProtection()
if(!armor) return 0 // no armor
var/AC=0
for(var/obj/item/armor/A in armor)
AC+=A.AC*max(1-A.damage,0)
return AC

This uses a list to keep track of what armor you're wearing, but just putting armor in that list doesn't mean it's necessarily in your inventory, or that it has to be kept separate from your contents list.

Although you don't need to, you can in fact separate your inventory system from mob.contents. The way to do that would be to create a list var like the one above and add to it like this:
usr.inventory+=theobj
theobj.loc=null

And when you drop it:
usr.inventory-=theobj
theobj.loc=usr.loc

Basically what you're doing is moving the object to nowhere, and pretending it's in a virtual contents list. But, this is extra work done for no good reason.

Lummox JR
In response to Mrhat99au
Mrhat99au wrote:
Every mob already has a contents so you dont have to define invetory. look up contents in dream maker

I understand that but I want another one for something else.
In response to Jinks
Jinks wrote:
Mrhat99au wrote:
Every mob already has a contents so you dont have to define invetory. look up contents in dream maker

I understand that but I want another one for something else.

As I mentioned in my post, you seem to be thinking all wrong about the way contents lists work.

If you're looking to show different lists in your stat panels, I suggest you simply write a specialized Stat() proc instead.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
Jinks wrote:
Mrhat99au wrote:
Every mob already has a contents so you dont have to define invetory. look up contents in dream maker

I understand that but I want another one for something else.

As I mentioned in my post, you seem to be thinking all wrong about the way contents lists work.

If you're looking to show different lists in your stat panels, I suggest you simply write a specialized Stat() proc instead.

Lummox JR

Ok I got what you are saying and I got the list to work but now I need to know how to get a verb to work with the obj. Tehcnically the obj doesn't even exsist in the usr. So I tried doing this:
verb/settech()
if(src in list usr.techniques)
it give me like a missing comma error or something. I don't think I can do Find() inside of the if if you have any ideas please help.