i have a problem with my HUDbased inventory
here's the error messege
runtime error: list index out of bounds
proc name: Click (/obj/HUD/Menu/Items/Next/Click)
source file: HUD Items.dm,135
usr: Dark Legend (/mob/Saiyan)
src: (/obj/HUD/Menu/Items/Next)
call stack:
(/obj/HUD/Menu/Items/Next): Click( (8,21,3) (/turf/Pathways/Grass))
here's the proc
Previous
icon_state = "Previous"
screen_loc = "6,3"
Click()
usr.client.screen -= usr.curitem //remove the currently displayed item
usr.curitemnum-- //find the index of the item "below" the current one
if(usr.curitemnum <= 0) //if it's invalid
usr.curitemnum = usr.items.len //set it to the "top" item
usr.curitem = usr.items[usr.curitemnum] //set the curitem var for future clicks
usr.client.screen += usr.curitem //display the new one
i made usr.items be the item list so it doesn't show everything in usr.contents. when someone picks up an item, i put usr.items += list("[src]").
mob
var
list/items = new
obj/Equips
var
EQUIPPED="false"
screen_loc = "7,3"
verb
Get()
set category = "Interact"
set src in oview(0)
src.loc = usr
src.items += list("[src]")
usr << "Info: You pick up the [src]."
... blah blah blah
here's the drop part since the equip works already.
if("Drop")
if(src.EQUIPPED == "true")
usr <<"Info: You need to unequip it first."
sleep(2)
return ..()
if(src.EQUIPPED == "false")
src.loc = usr.loc
usr.items -= list("[src]")
usr << "Info: You drop the [src]."
usr.DispItemMenu()
and this below is the part when you buy something off of an NPC
usr.items += list("[/obj/Equips/SaiyanArmor1]")
ID:147796
![]() Nov 23 2003, 7:09 am
|
|
Better yet, don't add text to the items list; add the items themselves. Adding the text is sort of silly when you can get access to the actual objects just as easily.
|
ok. Crispy, i took your advice and made it like this.
mob var list/items = new here's my get verb obj/Equips var EQUIPPED="false" screen_loc = "7,3" verb Get() set category = "Interact" set src in oview(0) usr.items += new src usr << "<font color=red size=1>Info:</font> <font color=white size=1>You pick up the [src].</font>" my drop verb is the same but is usr.items -= new src instead of + src. and here's a sample equipment obj/Equips/WhiteShortGloves name = "White Short Gloves" icon = 'EQUIPSWhiteShortGloves.dmi' layer = 6 it still causes an error saying this in-game runtime error: list index out of bounds proc name: Click (/obj/HUD/Menu/Items/Previous/Click) source file: HUD Items.dm,125 usr: Dark Legend (/mob/Saiyan) src: (/obj/HUD/Menu/Items/Previous) call stack: (/obj/HUD/Menu/Items/Previous): Click( (5,144,7) (/turf/Pathways/Wood)) this is HUD Items.dm. line 125 is bold and underlined Click() usr.client.screen -= usr.curitem //remove the currently displayed item usr.curitemnum-- //find the index of the item "below" the current one if(usr.curitemnum <= 0) //if it's invalid usr.curitemnum = usr.items.len //set it to the "top" item usr.curitem = usr.items[usr.curitemnum] //set the curitem var for future clicks usr.client.screen += usr.curitem //display the new one |
ZDarkGoku wrote:
my drop verb is the same but is usr.items -= new src instead of + src. Eek, no. Scratch the "new" bit. It should just be "usr.items += src" and "usr.items -= src". As for the runtime error, it's hard to say... could you insert a debug message stating the value of usr.curitemnum at the beginning of that Click() (like <code>world << usr.curitemnum</code>), and post what that debug message says (with that changed Click() so I can see exactly where you've put the debug message in)? |
i did src instead of new src. the get and drop verbs works ok. but the NPC buy doesn't work. do i put usr.items += new/obj/Equips/BlueShirt? here's the debug messege. i clicked many times it repeats this
runtime error: wrong type of value for list proc name: Click (/obj/HUD/Menu/Items/Previous/Click) source file: HUD Items.dm,127 usr: Dark Legend (/mob/Saiyan) src: (/obj/HUD/Menu/Items/Previous) call stack: (/obj/HUD/Menu/Items/Previous): Click( (4,144,7) (/turf/Pathways/Wood)) 1 runtime error: wrong type of value for list proc name: Click (/obj/HUD/Menu/Items/Previous/Click) source file: HUD Items.dm,127 usr: Dark Legend (/mob/Saiyan) src: (/obj/HUD/Menu/Items/Previous) call stack: (/obj/HUD/Menu/Items/Previous): Click( (4,144,7) (/turf/Pathways/Wood)) 2 here's my previous and next click objs for the screen. line 127 is in bold and underlined. Previous icon_state = "Previous" screen_loc = "6,3" Click() world << "[usr.curitemnum]" usr.client.screen -= usr.curitem //remove the currently displayed item usr.curitemnum-- //find the index of the item "below" the current one if(usr.curitemnum <= 0) //if it's invalid usr.curitemnum = usr.items.len //set it to the "top" item usr.curitem = usr.items[usr.curitemnum] //set the curitem var for future clicks usr.client.screen += usr.curitem //display the new one Next icon_state = "Next" screen_loc = "8,3" Click() world << "[usr.curitemnum]" usr.client.screen -= usr.curitem //remove the currently displayed item usr.curitemnum++ //find the index of the item "above" the current one if(usr.curitemnum >= usr.items.len+1) //if it's invalid usr.curitemnum = 1 //set it to the "bottom" item usr.curitem = usr.items[usr.curitemnum] //set the curitem var for future clicks usr.client.screen += usr.curitem //display the new one |
I'm gonna assume that your curitem is not an mob/obj/var. So, that's why it's not placing it on the screen. Redefine it as:
mob obj var curitem |
i do have it as a var as an obj.
here's the var mob var/tmp obj curitem it works now. but when i buy the item off an NPC (which is made as a mob) i use usr.items += /obj/Equips/BlueShirt. it doesn't shows up, i have to create a black shirt and use the my Get verb and get it and it shows up.the blue and black shirt. so the only thing that's wrong now is the NPC buy verb. mob NPC Shopkeeper NPC_Shop_Clerk_1 name = "\[NPC] Shop Clerk 1" NPC = "true" icon = 'MOBS.dmi' icon_state = "Clerk" verb Buy() set src in oview(2) set category = "Interact" switch(input("Hi there young traveler! What do you wish to buy?","Dragonball Live",text) in list ("Black Ushirt","Blue shirt","Cancel")) if("Black shirt") if(usr.ZENNI <= 149) usr << "<font color=red size=1>You need 150 zennis!</font>" return ..() if(usr.ZENNI >= 150) usr << "<font color=yellow size=1>You bought a Black shirt!</font>" usr.items += /obj/Equips/BlackShirt usr.ZENNI -= 150 return ..() ("Blue shirt") if(usr.ZENNI <= 149) usr << "<font color=red size=1>You need 150 zennis!</font>" return ..() if(usr.ZENNI >= 150) usr << "<font color=yellow size=1>You bought a Blue shirt!</font>" usr.items += /obj/Equips/BlueShirt usr.ZENNI -= 150 return ..() |
Try putting: new/obj/clothes/bleh when adding something like that. But, only where the item doesn't already exist.
|
nope. i added new/obj/Equips/blah. still doesn't shows up. Only way for it to show up as to use the Get verb and pick something up and then the new item that you just picked up shows and the old item that you bought shows up too.
buy verb is currently usr.items += new/obj/Equips/BlueUndershirt |
this is my Get verb
obj/Equips verb Get() set category = "Interact" set src in oview(0) src.loc = usr usr.items += src usr << "<font color=red size=1>Info:</font> <font color=white size=1>You pick up the [src].</font>" here's a sample equipment obj/Equips/WhiteShoes name = "White Shoes" icon = 'EQUIPSWhiteShoes.dmi' layer = 6 since my NPC is a mob, i can't use usr.items += src. i used usr.items += new/obj/Equips/WhiteShoes. when i buy it, it doesn't show up. but if i create a new whiteshoe on the map and use the Get verb to pick it up, both shows up. and it starts working. |
ZDarkGoku wrote:
src.loc = usr You're actually moving it to the contents of the player there as well as adding it to the items list... perhaps the HUD inventory system needs it to be "inside" the player as well as in the items list? |
i was thinking about it like that. here's what i tried
var/obj/Equips/BlueUndershirt/O O.loc = usr usr.items += new O that doesn't works. |
Try 'usr.curitem = usr.items["[usr.curitemnum]"]'