/ Published in: Other
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
mob verb Blacksmith() var/list/L = list() for(var/smithItem/s in smithItems) L += s.name //We'll use the nice name for input var/V = input(src, "What do you want to smith?", "Smithing") in L var/smithItem/S = smithItems[L.Find(V)] //Confusing. We're finding what we selected, and then selecting the corresponding item from the global list. var/list/held = contents //Copy the contents list for(var/atom/A in S.tools) for(var/V = 0, V < S.tools[A], V++) var/atom/B = locate(A) in held if(B) held -= B else if(S.tools[A] > 1) usr << "You need [S.tools[A]] [A]s" else usr << "You need \an [A]" return 0 held = contents //Reset the list //We reset it because materials may have the same thing as tools //Thus, the tools would be destroyed after use. Elegent, no? for(var/atom/A in S.materials) for(var/V = 0, V < S.materials[A], V++) var/atom/B = locate(A) in held if(B) held -= B else if(S.materials[A] > 1) usr << "You need [S.materials[A]] [A]s" else usr << "You need \an [A]" return 0 //If we're here, we've passed the test. contents = held //It has all the materials already removed. for(var/V in S.itemType) for(var/v = 0, v < S.itemType[V}, v++) new V() src << "You made \a [V]" if(!V.Move(src)) V.Move(loc) //And give us what we made.