ID:267562
 
Is there a way to make a maximum number of items in your contents? (Well, I know there is a way but how to do it.) I tried doing this, but it gives me errors.

mob/contents[4]

Could anyone show me a way to do it?
Check out the 'On-Screen' Inventory.

~wolf01
(TerranWolf)
In response to Wolf01
heres a quickie
world//for the world
mob=/mob/person//default mob for a person

mob/var//vars for the mobs
inventorysize
inventorysizemax=25

mob/person//the person mob
icon='person.dmi'//its icon
inventorysize=0//saying it has no inventorysize
Stat()//continually update..
statpanel("Inventory")//statpanel inventory
stat(contents)//contents

obj/food//food obj, for this demo
icon='food.dmi'//icon
verb/eat()//eat verb
usr.inventorysize-=1//inventory size goes down by one
usr<<"Yum yum!"//message
del (src) //deletes the item
verb/get()//get verb
set src in oview(1)//if your one step away from it
if(usr.inventorysize>=usr.inventorysizemax) return//if the inventory size is about the inventorysize max, dont pick it up
else//if not
usr.contents += src//add it to inventory
usr.inventorysize+=1//make person's inventorysize up by one
verb/drop()//drop
src.loc = usr.loc//move it to where the person is
usr.inventorysize-=1//makes the person inventory size down by one

obj/dball//dragonball obj, for this demo
icon='dball.dmi'//icon
verb/get()//get verb
set src in oview(1)//if your one step away from it
if(usr.inventorysize>=usr.inventorysizemax) return//if the inventory size is about the inventorysize max, dont pick it up
else//if not
usr.contents += src//add it to inventory
usr.inventorysize+=1//make person's inventorysize up by one
verb/drop()//drop
src.loc = usr.loc//move it to where the person is
usr.inventorysize-=1//makes the person inventory size down by one


// I have another verb, but I suggest to not use this

//mob/Move()//when you move
// if(inventorysize>0)//check if the inventory size is above one
// var/k=rand(inventorysize,inventorysize*2)//make a var
// var/L=rand(inventorysize,inventorysize/2)//make a var
// k-=L
// if(k<=0)
// k=rand(1,2)
// sleep(k)//wait it, for slower movment :)
// ..()//call parent (Move)
// else//if not
// ..()//call parent
Unknown Person wrote:
Is there a way to make a maximum number of items in your contents? (Well, I know there is a way but how to do it.) I tried doing this, but it gives me errors.

mob/contents[4]

You can't redefine the contents var; that's why.

Could anyone show me a way to do it?

If you use Move() to move all items into your inventory, instead of setting their loc directly, then you can do this:
mob
Enter(atom/movable/A) // A tries to enter M
if(contents.len>=4) return 0
return ..()

Lummox JR