ID:149632
 
A.S. I.F. stands for Artificial Socks International Foundation in my game. In it you need salt,cotton,alcohol, and cloth to make an Artificial Sock, no need to go into detail, but you NEED to have all 4 items, heres my code:
mob
As_If_Agent
verb
Create_Sock()
if(usr.Salt == 0)
usr<<"Not enough materials!"
if(usr.Cotton == 0)
usr<<"Not enough materials!"
if(usr.Alchol == 0)
usr<<"Not enough materials!"
if(usr.Cloth == 0)
usr<<"Not enough materials!"
else
usr.Salt = 0
usr.Alchol = 0
usr.Cotton = 0
usr.Cloth = 0
usr.contents -= /obj/Salt
usr.contents -= /obj/Alcohol
usr.contents -= /obj/Cotton
usr.contents -= /obj/Cloth
usr.contents -= new/obj/Artificial_Sock

But when I do this in the game it doesn't work!
Please assist. Thank you.
Replace:

usr.contents -= new/obj/Artificial_Sock

With:

usr.contents += new/obj/Artificial_Sock
What happens when you use the verb? The first part looks ok, but then you have this:

usr.contents -= /obj/Salt
usr.contents -= /obj/Alcohol
usr.contents -= /obj/Cotton
usr.contents -= /obj/Cloth
usr.contents -= new/obj/Artificial_Sock

You are removing types from usr.contents, not actual objects.

Your first part is testing variables to see if they have the components... is this how the information is stored, or is it by object ownership? What is supposed to happen when they fail? Are all of their ingredients supposed to disappear?

If you want to delete all salt objects, you could do this:
for(var/obj/Salt/S in usr.contents)
del(S)

To delete only one, do this:
for(var/obj/Salt/S in usr.contents)
del(S)
break

Another method that would delete one of each in a list would be this (untested):

for(var/the_type in list(/obj/Salt, /obj/Alcohol, /obj/Cotton, /obj/Cloth))
for(var/obj/O in usr.contents)
if(istype(O, the_type))
del(O)
break

Take out the last "break," and all of the objects would be deleted.
In response to Mertek
Mertek wrote:
Replace:

usr.contents -= new/obj/Artificial_Sock

With:

usr.contents += new/obj/Artificial_Sock

This does not create a new object in the inventory. You would need to do this:

var/obj/Artificial_Sock/the_sock
the_sock = new(usr)
In response to Mertek
Put_In_Jail(M as mob in world)
M.Mute = 1
world<<"[M] was put in jail!"
M.Move(locate(29,2,1))
Remove_From_Jail(M as mob in world)
M.Mute = 0
M.Move(locate(26,2,1))
GiveJob(M as mob in world)
M.Job = input("Well?","Whats their job?",src.Job)
M:Job()

The errors are:
Enjoy Life.dm:297:error:M.Mute:undefined var
Enjoy Life.dm:299:error:M.Move:undefined proc
Enjoy Life.dm:301:error:M.Mute:undefined var
Enjoy Life.dm:302:error:M.Move:undefined proc
Enjoy Life.dm:304:error:M.Job:undefined var

Soo.... Kenya help?
In response to FireEmblem
Change all the:
M as mob in world
to:
mob/M as mob in world