ID:2862308
 
(See the best response by Kaiochao.)
Code:

Here is the Cooking verb from the Campfire obj.

obj/items/campfire
icon='build7.dmi'
icon_state="82"
name="Camp fire"
New()
spawn(600)
del(src)

var
beingcooked=0
verb
Put_Out()
set src in oview(1)
set category = "Skills"
if(!src.beingcooked)
view(usr)<<output("A campfire was put out.","rpoutput")
del(src)
else
usr<<"The fire is cooking something."
return
verb
Cook()
set src in oview(1)
set category = "Skills"
if(!usr.cooking)
for(var/obj/items/Food/Cookable/F in usr.contents)
var/list/Options=list()
Options["[F.name] - x[F.Amount]"]=F
var/Choice = usr.CustomInput("Cook","What would you like to cook?",Options + "Cancel")
if(Choice:name=="Cancel")
return
if(typesof(Choice,/obj/items/Food/Cookable/))
usr.cooking=1
view(usr)<<output("[usr] is cooking a [F]","rpoutput")
src.beingcooked=1
usr<<"test" // after this line is where the verb suddenly stops working.
usr.cookselection+=F
usr<<"testfinish"
Cookup(F) // see next code for this one <-- It's my cook proc to apparently cook the object you selected from your inventory via CustomInput() above.
sleep(30)
//F.Amount-=1
usr.cooking=0
src.beingcooked=0
view(usr)<<output("[usr] has cooked a [F].","rpoutput")
usr.cookselection-=F
return
else
usr<<"You are already cooking."



Here is my cookup proc, which is supposed to cook the object you selected from the campfire Cook verb. It does work up into an extent, but the name changes does not work. I've tried using replacetext, but maybe I'm using it wrong.



obj/proc/Cookup(obj/items/Food/Cookable/O in usr.cookselection)
if(O.Amount==1)
usr<<"testedfirst"
var/obj/items/Food/Cookable/F = new
F.icon=O.icon
F.hungerpts=O.hungerpts
F.thirstpts=O.thirstpts
F.hungerr=O.hungerr
F.strbuff=O.strbuff
F.endbuff=O.endbuff
F.resbuff=O.resbuff
F.forcebuff=O.forcebuff
F.speedbuff=O.speedbuff
F.offbuff=O.offbuff
F.defbuff=O.defbuff
F.regenbuff=O.regenbuff
F.recovbuff=O.recovbuff
O.name = replacetext("[O.name]","Raw", "Cooked")
//F.name="Cooked [O.name]"
F.name=O.name
usr<<"another test"
if(F.strbuff>0.0001) //strcook
F.strbuff+=0.5

if(F.endbuff>0.0001)//endcook
F.endbuff+=0.5

if(F.forcebuff>0.0001)//force cook
F.forcebuff+=0.5

if(F.resbuff>0.0001)// res cook
F.resbuff+=0.5

if(F.speedbuff>0.0001) // spd cook
F.speedbuff+=0.5

if(F.offbuff>0.0001)
F.offbuff+=0.5

if(F.defbuff>0.0001)
F.defbuff+=0.5


if(F.regenbuff>0.0001)
F.regenbuff+=0.5


if(F.recovbuff>0.0001)
F.recovbuff+=0.5
var/icon/I=new(F.icon)
I.Blend(rgb(90,0,30),ICON_MULTIPLY)
usr<<"finaltest"
F.icon=I
//F.Amount=1
usr.itemAdd(F)
del(O)
if(O.Amount>1)
usr<<"testedsecond"
if(O.strbuff>0.0001) //strcook
O.strbuff+=0.5

if(O.endbuff>0.0001)//endcook
O.endbuff+=0.5

if(O.forcebuff>0.0001)//force cook
O.forcebuff+=0.5

if(O.resbuff>0.0001)// res cook
O.resbuff+=0.5

if(O.speedbuff>0.0001) // spd cook
O.speedbuff+=0.5

if(O.offbuff>0.0001)
O.offbuff+=0.5

if(O.defbuff>0.0001)
O.defbuff+=0.5


if(O.regenbuff>0.0001)
O.regenbuff+=0.5


if(O.recovbuff>0.0001)
O.recovbuff+=0.5
O.name="Cooked [O.name]"
var/icon/I=new(O.icon)
I.Blend(rgb(90,0,30),ICON_ADD)
O.icon=I
usr.itemAdd(O)


Problem description:
In the first code, it's supposed to just pop up a input box that allows you to select one of the foods in the usrs contents. But it only shows one type of the food, meaning it only gives one row. Maybe an error in my customInput() proc, but that's besides the point

The real issue is, that I cannot get the Cookup proc to register F as if it was the actual obj from the usr, basically it's suppose to just copy let's say a Raw Steak, adapt it's buffs, blend some color to make it look cooked, and change it's name. While also decreasing/deleting the Raw Steak amount prior. I'm probably make a few real clumsy noob mistakes but any advice can help.

Been at this for awhile and I really want to know how I can go about calling the actual object from one verb, into another proc.

Thank you


Here is the cookselection list I made:

mob/var
cooking=0
mob/var/list
cookselection = list()


I did this recently because I had a code that worked prior just intsead Cookup()'s proc did not copy the obj's icon for a duplicate, instead just made an empty icon in inventory named: Cookable

But yeah, i'm all out of "do-it-yourself" time, lol.
Best response
for(var/obj/items/Food/Cookable/F in usr.contents)
var/list/Options=list()
Options["[F.name] - x[F.Amount]"]=F
var/Choice = usr.CustomInput("Cook","What would you like to cook?",Options + "Cancel")
"For each cookable food in the user's contents: create a list of options, include the current food as an option, ask the user to choose from options."

var/list/Options=list()
for(var/obj/items/Food/Cookable/F in usr.contents)
Options["[F.name] - x[F.Amount]"]=F
var/Choice = usr.CustomInput("Cook","What would you like to cook?",Options + "Cancel")
"Create a list of options, include each cookable food from the user's contents as an option, ask the user to choose from options."
In response to Kaiochao
Kaiochao wrote:
> for(var/obj/items/Food/Cookable/F in usr.contents)
> var/list/Options=list()
> Options["[F.name] - x[F.Amount]"]=F
> var/Choice = usr.CustomInput("Cook","What would you like to cook?",Options + "Cancel")
>
"For each cookable food in the user's contents: create a list of options, include the current food as an option, ask the user to choose from options."
> var/list/Options=list()
> for(var/obj/items/Food/Cookable/F in usr.contents)
> Options["[F.name] - x[F.Amount]"]=F
> var/Choice = usr.CustomInput("Cook","What would you like to cook?",Options + "Cancel")
>
"Create a list of options, include each cookable food from the user's contents as an option, ask the user to choose from options."


Wow I didn't even realize that until now. Total doof moment!!! Thank you lots man you don't know how many brain hemorrhages I almost developed dealing with this.
In response to Kaiochao
Still having issues with this code though.

For some reason, the code stops after trying to store the Choice into the cookselection list.

var/list/Options=list()
for(var/obj/items/Food/Cookable/F in usr.contents)
Options["[F.name] - x[F.Amount]"]=F
var/Choice = usr.CustomInput("Cook","What would you like to cook?",Options + "Cancel")
if(Choice:name=="Cancel")
return
if(typesof(Choice,/obj/items/Food/Cookable/))
usr.cooking=1
view(usr)<<output("[usr] is cooking a [Choice]","rpoutput")
src.beingcooked=1
usr<<"test"
usr.cookselection+=Choice // Stops here. Can't for the life of me think of what's causing this. may think of creating anew proc just to insert this if I can't get to the bottom of it xD
usr<<"testfinish"
Cookup(Choice)
sleep(30)
//F.Amount-=1
usr.cooking=0
src.beingcooked=0
view(usr)<<output("[usr] has cooked a [Choice].","rpoutput")
usr.cookselection-=Choice
return



Note: What "CAN" be stored in mob/lists? and for/vars of objs how can that be done? I'm thinking. usr.cookselection=Choice instead of += ?
UPDATE: Trying

usr.cookselecton=Choice

worked.

lol, thank you again.