ID:143358
 
Code:
this is part of my code that is the problem
            var/obj/Items/Food/F = input(typesof(/obj/Items/Food/)) in usr
if(F == "Cancel")
return
usr << "[F]"
if(F.name == "Fish")
(This is where It does stuff btw)


Problem description:
it won't do anything...
Hellonagol wrote:
Code:
this is part of my code that is the problem
>           var/obj/Items/Food/F = input(typesof(/obj/Items/Food/)) in usr
> if(F == "Cancel")
> return
> usr << "[F]"
> if(F.name == "Fish")
> (This is where It does stuff btw)
>

Problem description:
it won't do anything...
The "input(typesof(/obj/Items/Food/)) in usr" wont work because the input proc takes the source as the first argument, and then text strings and such. It should be like this:
var/Food[0]
for(var/obj/Items/Food/F in usr)Food+=F
input(src,"Hello")as anything in Food
In response to Kakashi24142
Here is the full code. The thing you said to try just gave a runtime error called Bad Client.
obj/jobs/stove
icon = 'obj.dmi'
icon_state = "stove"
density = 1
nosay = 1
verb
Cook()
set src in view(1)
if(usr.job != "Cook")
line1 = "I can't cook... I am not a chef."
return
var/Food[0]
for(var/obj/Items/Food/F in usr)Food+=F
input(src,"Hello")as anything in Food
usr << "[src]"
if(src.name == "Fish")
switch(input(usr,"Make What?") in list ("Sushi (lvl 1)","Cancel"))//Change
if("Cancel")
return
if("Sushi (lvl 1)")//change
var/reqjoblvl = 1//Change Required job Lvl
var/result = "Sushi"//Change Result Name
var/resultname = "Sushi"//Name you will see
if(usr.joblvl < reqjoblvl)
usr << "Need Higher Job Lvl"
return
usr << "Making [resultname]..."
if(usr.InventoryUp == 1)
usr:Inventory()
usr.lockinventory = 1
usr.move = 0
sleep(100+reqjoblvl - usr.joblvl)
del(src)
var/resultnew = "/obj/Items/Foodresults[result]"
new resultnew(usr)
var/jobup = rand(1,reqjoblvl+usr.joblvl)
if(jobup == 2)
usr.joblvl ++
usr << "Job Level Increased! It is now [usr.joblvl]."
usr << "Made [resultname]"
usr.lockinventory = 0
usr.move = 1
if(src.name == "Egg")
switch(input(usr,"Make What?") in list (,"Scrambled Eggs (lvl 1)","Fried Eggs (lvl 4)","Hard Boiled Egg (lvl 10)","Cancel"))//Change
if("Cancel")
return
if("Scrambled Eggs (lvl 1)")//change
var/reqjoblvl = 1//Change Required job Lvl
var/result = "Scrambled_Eggs"//Change Result Name
var/resultname = "Scrambled Eggs"//Name you will see
if(usr.joblvl < reqjoblvl)
usr << "Need Higher Job Lvl"
return
usr << "Making [resultname]..."
if(usr.InventoryUp == 1)
usr:Inventory()
usr.lockinventory = 1
usr.move = 0
sleep(100+reqjoblvl - usr.joblvl)
del(src)
var/resultnew = "/obj/Items/Foodresults/[result]"
new resultnew(usr)
var/jobup = rand(1,reqjoblvl+usr.joblvl)
if(jobup == 2)
usr.joblvl ++
usr << "Job Level Increased! It is now [usr.joblvl]."
usr << "Made [resultname]"
usr.lockinventory = 0
usr.move = 1
if("Fried Eggs (lvl 4)")//change
var/reqjoblvl = 4//Change Required job Lvl
var/result = "Fried_Eggs"//Change Result Name
var/resultname = "Fried Eggs"//Name you will see
if(usr.joblvl < reqjoblvl)
usr << "Need Higher Job Lvl"
return
usr << "Making [resultname]..."
if(usr.InventoryUp == 1)
usr:Inventory()
usr.lockinventory = 1
usr.move = 0
sleep(100+reqjoblvl - usr.joblvl)
del(src)
var/resultnew = "/obj/Items/Foodresults/[result]"
new resultnew(usr)
var/jobup = rand(1,reqjoblvl+usr.joblvl)
if(jobup == 2)
usr.joblvl ++
usr << "Job Level Increased! It is now [usr.joblvl]."
usr << "Made [resultname]"
usr.lockinventory = 0
usr.move = 1
if("Hard Boiled Egg (lvl 10)")//change
var/reqjoblvl = 10//Change Required job Lvl
var/result = "Hard_Boiled_Egg"//Change Result Name
var/resultname = "Hard Boiled Egg"//Name you will see
if(usr.joblvl < reqjoblvl)
usr << "Need Higher Job Lvl"
return
usr << "Making [resultname]..."
if(usr.InventoryUp == 1)
usr:Inventory()
usr.lockinventory = 1
usr.move = 0
sleep(100+reqjoblvl - usr.joblvl)
del(src)
var/resultnew = "/obj/Items/Foodresults/[result]"
new resultnew(usr)
var/jobup = rand(1,reqjoblvl+usr.joblvl)
if(jobup == 2)
usr.joblvl ++
usr << "Job Level Increased! It is now [usr.joblvl]."
usr << "Made [resultname]"
usr.lockinventory = 0
usr.move = 1
if(src.name == "Potato")
switch(input(usr,"Make What?") in list ("Baked Potato (lvl 1)","Bag of fries (lvl 10)","Cancel"))//Change
if("Cancel")
return
if("Baked Potato (lvl 1)")//change
var/reqjoblvl = 1//Change Required job Lvl
var/result = "Baked_Potato"//Change Result Name
var/resultname = "Baked Potato"//Name you will see
if(usr.joblvl < reqjoblvl)
usr << "Need Higher Job Lvl"
return
usr << "Making [resultname]..."
if(usr.InventoryUp == 1)
usr:Inventory()
usr.lockinventory = 1
usr.move = 0
sleep(100+reqjoblvl - usr.joblvl)
del(src)
var/resultnew = "/obj/Items/Foodresults/[result]"
new resultnew(usr)
var/jobup = rand(1,reqjoblvl+usr.joblvl)
if(jobup == 2)
usr.joblvl ++
usr << "Job Level Increased! It is now [usr.joblvl]."
usr << "Made [resultname]"
usr.lockinventory = 0
usr.move = 1
if("Bag of fries (lvl 10)")//change
var/reqjoblvl = 10//Change Required job Lvl
var/result = "Bag_of_fries"//Change Result Name
var/resultname = "Bag of fries"//Name you will see
if(usr.joblvl < reqjoblvl)
usr << "Need Higher Job Lvl"
return
usr << "Making [resultname]..."
if(usr.InventoryUp == 1)
usr:Inventory()
usr.lockinventory = 1
usr.move = 0
sleep(100+reqjoblvl - usr.joblvl)
del(src)
var/resultnew = "/obj/Items/Foodresults/[result]"
new resultnew(usr)
var/jobup = rand(1,reqjoblvl+usr.joblvl)
if(jobup == 2)
usr.joblvl ++
usr << "Job Level Increased! It is now [usr.joblvl]."
usr << "Made [resultname]"
usr.lockinventory = 0
usr.move = 1

<dm>
In response to Hellonagol
Look up "input" in the reference, you're using it wrong.
var/obj/Items/Food/F = input(usr,"pick a food item!")in typesof(/obj/Items/Food/))
In response to Masterdan
It seems he's trying to search for that object type in contents rather than in general, so I don't think that would achieve it.
In response to Keeth
Okay heres how it should be.
It should take an item from the usrs inventory that is the type obj/Items/Food and put it in a list. Then you choose from that list and if the name of the item = Fish. It will show an option of what to cook. A little help please.
obj/jobs/stove
icon = 'obj.dmi'
icon_state = "stove"
density = 1
nosay = 1
verb
Cook()
set src in view(1)
if(usr.job != "Cook")
line1 = "I can't cook... I am not a chef."
return
var/L = list()
for(var/obj/Items/Food/P in usr)
L += P
var/obj/Items/Food/F = input(usr,"pick a food item!") as anything in L
if(F.name == "Fish")
switch(input(usr,"Make What?") in list ("Sushi (lvl 1)","Cancel"))//Change
if("Cancel")
return
if("Sushi (lvl 1)")//change
var/reqjoblvl = 1//Change Required job Lvl
var/result = "Sushi"//Change Result Name
var/resultname = "Sushi"//Name you will see
if(usr.joblvl < reqjoblvl)
usr << "Need Higher Job Lvl"
return
usr << "Making [resultname]..."
if(usr.InventoryUp == 1)
usr:Inventory()
usr.lockinventory = 1
usr.move = 0
sleep(100+reqjoblvl - usr.joblvl)
del(F)
var/resultnew = "/obj/Items/Foodresults[result]"
new resultnew(usr)
var/jobup = rand(1,reqjoblvl+usr.joblvl)
if(jobup == 2)
usr.joblvl ++
usr << "Job Level Increased! It is now [usr.joblvl]."
usr << "Made [resultname]"
usr.lockinventory = 0
usr.move = 1
if(F.name == "Egg")
switch(input(usr,"Make What?") in list (,"Scrambled Eggs (lvl 1)","Fried Eggs (lvl 4)","Hard Boiled Egg (lvl 10)","Cancel"))//Change
if("Cancel")
return
if("Scrambled Eggs (lvl 1)")//change
var/reqjoblvl = 1//Change Required job Lvl
var/result = "Scrambled_Eggs"//Change Result Name
var/resultname = "Scrambled Eggs"//Name you will see
if(usr.joblvl < reqjoblvl)
usr << "Need Higher Job Lvl"
return
usr << "Making [resultname]..."
if(usr.InventoryUp == 1)
usr:Inventory()
usr.lockinventory = 1
usr.move = 0
sleep(100+reqjoblvl - usr.joblvl)
del(F)
var/resultnew = "/obj/Items/Foodresults/[result]"
new resultnew(usr)
var/jobup = rand(1,reqjoblvl+usr.joblvl)
if(jobup == 2)
usr.joblvl ++
usr << "Job Level Increased! It is now [usr.joblvl]."
usr << "Made [resultname]"
usr.lockinventory = 0
usr.move = 1
if("Fried Eggs (lvl 4)")//change
var/reqjoblvl = 4//Change Required job Lvl
var/result = "Fried_Eggs"//Change Result Name
var/resultname = "Fried Eggs"//Name you will see
if(usr.joblvl < reqjoblvl)
usr << "Need Higher Job Lvl"
return
usr << "Making [resultname]..."
if(usr.InventoryUp == 1)
usr:Inventory()
usr.lockinventory = 1
usr.move = 0
sleep(100+reqjoblvl - usr.joblvl)
del(F)
var/resultnew = "/obj/Items/Foodresults/[result]"
new resultnew(usr)
var/jobup = rand(1,reqjoblvl+usr.joblvl)
if(jobup == 2)
usr.joblvl ++
usr << "Job Level Increased! It is now [usr.joblvl]."
usr << "Made [resultname]"
usr.lockinventory = 0
usr.move = 1
if("Hard Boiled Egg (lvl 10)")//change
var/reqjoblvl = 10//Change Required job Lvl
var/result = "Hard_Boiled_Egg"//Change Result Name
var/resultname = "Hard Boiled Egg"//Name you will see
if(usr.joblvl < reqjoblvl)
usr << "Need Higher Job Lvl"
return
usr << "Making [resultname]..."
if(usr.InventoryUp == 1)
usr:Inventory()
usr.lockinventory = 1
usr.move = 0
sleep(100+reqjoblvl - usr.joblvl)
del(F)
var/resultnew = "/obj/Items/Foodresults/[result]"
new resultnew(usr)
var/jobup = rand(1,reqjoblvl+usr.joblvl)
if(jobup == 2)
usr.joblvl ++
usr << "Job Level Increased! It is now [usr.joblvl]."
usr << "Made [resultname]"
usr.lockinventory = 0
usr.move = 1
if(F.name == "Potato")
switch(input(usr,"Make What?") in list ("Baked Potato (lvl 1)","Bag of fries (lvl 10)","Cancel"))//Change
if("Cancel")
return
if("Baked Potato (lvl 1)")//change
var/reqjoblvl = 1//Change Required job Lvl
var/result = "Baked_Potato"//Change Result Name
var/resultname = "Baked Potato"//Name you will see
if(usr.joblvl < reqjoblvl)
usr << "Need Higher Job Lvl"
return
usr << "Making [resultname]..."
if(usr.InventoryUp == 1)
usr:Inventory()
usr.lockinventory = 1
usr.move = 0
sleep(100+reqjoblvl - usr.joblvl)
del(F)
var/resultnew = "/obj/Items/Foodresults/[result]"
new resultnew(usr)
var/jobup = rand(1,reqjoblvl+usr.joblvl)
if(jobup == 2)
usr.joblvl ++
usr << "Job Level Increased! It is now [usr.joblvl]."
usr << "Made [resultname]"
usr.lockinventory = 0
usr.move = 1
if("Bag of fries (lvl 10)")//change
var/reqjoblvl = 10//Change Required job Lvl
var/result = "Bag_of_fries"//Change Result Name
var/resultname = "Bag of fries"//Name you will see
if(usr.joblvl < reqjoblvl)
usr << "Need Higher Job Lvl"
return
usr << "Making [resultname]..."
if(usr.InventoryUp == 1)
usr:Inventory()
usr.lockinventory = 1
usr.move = 0
sleep(100+reqjoblvl - usr.joblvl)
del(F)
var/resultnew = "/obj/Items/Foodresults/[result]"
new resultnew(usr)
var/jobup = rand(1,reqjoblvl+usr.joblvl)
if(jobup == 2)
usr.joblvl ++
usr << "Job Level Increased! It is now [usr.joblvl]."
usr << "Made [resultname]"
usr.lockinventory = 0
usr.move = 1
Hellonagol wrote:
Code:
this is part of my code that is the problem
>           var/obj/Items/Food/F = input(typesof(/obj/Items/Food/)) in usr
> if(F == "Cancel")
> return
> usr << "[F]"
> if(F.name == "Fish")
> (This is where It does stuff btw)
>


Well, there are more than a few problems there. The big one is that you're using input() completely wrong. If you look in the reference you'll see that's not how it's done.

var/obj/Items/Food/F = input("Choose some food", "Choose food") as null|anything in usr


But that won't restrict your list to just food, so you need to make a list just for this purpose:

var/obj/Items/Food/F
var/list/L = new
for(F in usr) L += F
F = input("Choose some food", "Choose food") as null|anything in L


Then you need to change your cancel code, so instead of looking for F=="Cancel" it looks for null:

if(!F) return   // played canceled


Lummox JR