ID:2215418
 
(See the best response by FKI.)
Code:
mob/player
proc
invchoice()
itemsnumber=0
for(var/obj/items/i in src.contents)
if(i.itemtype==inventorytype)
itemsnumber++
if(itemsnumber==28-src.cursory+itemscrolled)
callitemchoice(i)
if(itemsnumber < src.cursory+itemscrolled && menuid==3) closeitemsmenu()

callitemchoice(i as obj)
if(menuid!=9)
menuid=9
src << "Item called: [i]"
playsound('sfx/sounds/accept.wav')
src.chooseitemHUD=new
chooseitemHUD.icon+=rgb(redhud,greenhud,bluehud,alphahud)
chooseitemHUD.maptext_y+=90
for(var/itemverb in i.itemverblist)
chooseitemHUD.maptext+=itemverb
chooseitemHUD.maptext_y-=30
chooseitemHUD.maptext+="Return"
src.chooseitemFRAME=new
src.client.screen+=chooseitemHUD
src.client.screen+=chooseitemFRAME
oldcursor=list(cursorx,cursorxsmall,cursory,cursorysmall)
Setcursor(23,0,19,30)


Problem description:

I am trying to make a menu using only buttons and so, I have this inventory script running. Long story short, the real problem lies with trying to pass down an item from one proc to another via callitemchoice(item), as somehow, all that gets passed over is only the name. The list in which I store what can be done with the item itemverblist isn't loaded and I get this error message:

code\outsidemenu.dm:531:error: i.itemverblist: undefined var
Dunglas.dmb - 1 error, 0 warnings (2/19/17 10:24 pm)
Best response
code\outsidemenu.dm:531:error: i.itemverblist: undefined var


You are getting this error because the variable i doesn't have a proper type assigned to it. Using i as obj does not mean i is an obj the way you are using it. That format is mainly for verb arguments when searching a container, e.g.:

mob/verb/find_obj(var/obj/o as null|obj in container)


Instead, what you want is this:

callitemchoice(var/obj/i)
Thanks man, it worked out perfectly!
In response to FKI
The var keyword is redundant in proc arguments. I submit the actual correct definition is:

callitemchoice(obj/items/i)

This is because in the calling routine, the var was an /obj/items type as well.