ID:147985
 
I finally got my on screen inventory system to work, but I'm having a bit of a problem.

It's suppose to: Drop the object in usr.loc (as shown), and the little item that shows up on my onscreen inventory(the pants), should be deleted.
obj/items/pants/black
icon = 'pants-black.dmi'
icon_state = "show"
layer=MOB_LAYER+10
var/wearing = 0
verb/Get()
set src in oview(1)
set category="Item"
Move(usr)
usr.contents += src
usr.refeshing()
Click()
switch(alert("What do you want to do?",,"Wear","Drop","Cancel"))
if("Wear")
if(src.wearing==0)
src.wearing=1
usr.overlays+='pants-black.dmi'
usr<<"You wear the [src]"
else
src.wearing=0
usr.overlays -= 'pants-black.dmi'
usr<<"You remove the [src]"
if("Drop")
if(src.wearing == 1)
src<<"<b>You're wearing the clothes."
return
else
set src in usr
var/deleted=0
while(deleted<=0)
for(var/obj/O in usr.contents)
if(O==src)
O.Move(usr.loc)
deleted=1
for(var/obj/items/F in usr.client.screen)
del(F)
usr.refeshing()
for(var/obj/background/BG in usr.client.screen)
del(BG)
usr << "You drop [src]."
if("Cancel")
return


Problem: When the player is suppose to drop the pants, it slows down movement dramatically, doesn't delete the content, and I get error:

If it is not an infinite loop, either do 'set background=1' or set world.loop_checks=0.
proc name: Click (/obj/items/pants/black/Click)
usr: Camaro (/mob/player/Dark)
src: the black (/obj/items/pants/black)
call stack:
the black (/obj/items/pants/black): Click(the carpet (1,12,3) (/turf/carpet))


I tried to put detail into this, because I'd really like help. Thank you :)

-Camaro-
while(deleted<=0)

should it be >=0?
woah.. >=0 is a mad face AND it checks if a var is greater than or equal to 0. COOL!
In response to Airjoe
Sadly that doesn't work. I still get the same error >.>


-Camaro-
In response to Camaro
When calling del(), it stops the proc. Look into that.
Camaro wrote:
I finally got my on screen inventory system to work, but I'm having a bit of a problem.

It's suppose to: Drop the object in usr.loc (as shown), and the little item that shows up on my onscreen inventory(the pants), should be deleted.
> obj/items/pants/black
> icon = 'pants-black.dmi'
> icon_state = "show"
> layer=MOB_LAYER+10
> var/wearing = 0
> verb/Get()
> set src in oview(1)
> set category="Item"
> Move(usr)
> usr.contents += src
> usr.refeshing()
> Click()
> switch(alert("What do you want to do?",,"Wear","Drop","Cancel"))
> if("Wear")
> if(src.wearing==0)
> src.wearing=1
> usr.overlays+='pants-black.dmi'
> usr<<"You wear the [src]"
> else
> src.wearing=0
> usr.overlays -= 'pants-black.dmi'
> usr<<"You remove the [src]"
> if("Drop")
> if(src.wearing == 1)
> src<<"<b>You're wearing the clothes."
> return
> else
> set src in usr
> var/deleted=0
> while(deleted<=0)
> for(var/obj/O in usr.contents)
> if(O==src)
> O.Move(usr.loc)
> deleted=1
> for(var/obj/items/F in usr.client.screen)
> del(F)
> usr.refeshing()
> for(var/obj/background/BG in usr.client.screen)
> del(BG)
> usr << "You drop [src]."
> if("Cancel")
> return
>

Problem: When the player is suppose to drop the pants, it slows down movement dramatically, doesn't delete the content, and I get error:

If it is not an infinite loop, either do 'set background=1' or set world.loop_checks=0.
proc name: Click (/obj/items/pants/black/Click)
usr: Camaro (/mob/player/Dark)
src: the black (/obj/items/pants/black)
call stack:
the black (/obj/items/pants/black): Click(the carpet (1,12,3) (/turf/carpet))


I tried to put detail into this, because I'd really like help. Thank you :)

-Camaro-

If you only want to move the item out of the characters inventory and onto the ground, why dont you replace everything under the else statement in the drop verb with
src.loc = usr.loc
eg.
if("Drop")
if(src.wearing == 1)
usr<<"You're wearing the clothes."
return
else
src.loc = usr.loc
usr << "You drop [src]."