mob/verb/ViewAvailableFoods in typesof(/obj/Food/) //This verb is intended to populate a list of all Food objs available to buy
set hidden = 1 //Makes this invis since there's an interface button for it
switch(input("Select a category") in list ("Fruits","Veggies","Meat","Beverages","Cancel")) //The options
if("Fruits")
switch(input("Select a Friut") in list (src.name in typesof(/obj/Food/Fruits),"Cancel"))
if("Cancel") return //How do I make this Cancel option go back to the previous question, "Select a Category"?
if(typesof(/obj/Food/Fruit)) //Line 213. Am I not allowed to put a typesof() proc inside an if() proc? If the player selected one of the coded fruit objs in the list...
switch(input("[src.desc","[src.name]" in list ("Buy","Cancel")))
if("Cancel") return //Again, how do I make this Cancel option go to previous question, "Select a Fruit"?
if("Buy")
if(usr.Money < src.Cost) //Line 217. I thought the src here is the /obj/Food/Fruit the user selects
usr << output("You need don't have enough for this!")
return
else
usr.Money-=src.Cost //Line 221
//Going to enter some code here to place a new /obj/Food/Fruit/[fruit name here obviously]
usr << output("You have purchased [src]!")
return
Problem description:
loading Alchemy Online.dme
loading interface.dmf
Food System.dm:217:error: src.Cost: undefined var
Food System.dm:221:error: src.Cost: undefined var
Food System.dm:213:error: : expected a constant expression
Alchemy Online.dmb - 3 errors, 0 warnings (5/31/16 10:11 am)
1. What I aimed to do is allow players to view a categorized list of food objs. Each food obj has a description, name, and cost var. Cost is a var defined under obj/Food, and each specific fruit, meat, beverage, etc obj has their own cost/number assigned to their Cost var, so maybe that undefined var error has to do with 'src'?
2. How do I get the Cancel options to go back to the previous switch option? I was thinking to make each step a proc and calling the previous one, but I feel like there's a better option.
3. My typesof() proc doesn't work as an argument inside an if() proc. I don't know if that's illegal.. The DM guide doesn't say anything about it.
switch cases only take constants.