verb/Use()
set src in usr.contents
if(usr.Working)
return
else
usr.Working=1
var/list/Buildlist=list()
for(var/obj/items/Alchemy/Potions/P)
if(!locate(P)in Buildlist)
Buildlist+=P
var/obj/C=input("Which potion would you like to make?")as null|anything in Buildlist
if(!C)
usr.Working=0
return
else
Problem description:
With this code, when i use the object, it builds the list correctly and everything works fine on it except for one thing. Theres a few potions that i have defined, but they dont show up in the list almost as if they don't exist. Does anyone know the reason for this, and if so how to fix it?
DM reads that code as (!locate(P))in List. Due to order of operations, !locate(P) occurs first. It looks for P, and if P exists, returns P, or true. The ! makes it opposite, false.
Then, it checks if "0" is in "List". Which doesn't make too much sense, does it?
Sooo:
This checks if P is in List first, then the opposite of that.
By the way, you're checking for all the potions in the world, and adding them to "Buildlist" if they aren't already in it. The for() loop loops through all the potions in the world only once, so you don't have to check if it already added it since "Buildlist" is a new temporary list. I'm not sure if this is what you want.