ID:145050
 
Code:
obj
transcircle
icon = 'objects.dmi'
icon_state = "trans1"
name="Transmutation Circle"
verb
Transmute(var/obj/Items/O)
set name = "Transmute"
set desc="Transmutate an object in your inventory"
set src in view(0)
switch(input("What would you do wish to Transmute","Transmutation")in list("[O]","Back"))
if("Iron")
if(usr.level<=5)
usr.contents+=new/obj/Items/sword
if(usr.level>=5)
usr.contents+=new/obj/Items/better_sword
else
usr<<"You do not enough skill to do this!"
if("Gold")
usr<<"Sorry, that has not been implemented yet."
if("Sodium")
usr<<"Sorry, that has not been implemented yet."
if("Back")
return


Problem description:
Well, many of you know, [src/usr.contents] isn't the best thing to use, and I'm sure it isn't but It is the worst to see a list of all the material's you can use to Transmutate, rather than just seeing what you have in your inventory, so I was wondering if there is a proper way of doing this, the furthest I've gotten is seeing the /list in the Input box.
First, let's fix this problem
if(usr.level<=5)
usr.contents+=new/obj/Items/sword
if(usr.level>=5)
usr.contents+=new/obj/Items/better_sword
else
usr<<"You do not enough skill to do this!"


What will happen is that a person under to L5 will get the sword item AND will get get the message saying you do not have enough skill for this:

Fix: Change "if(usr.level>=5)" to "else if(usr.level>=5)"

Also, another problem is that you used "if(usr.level>=5)" and "if(usr.level<=5)"... that means that a person L5 WILL get both swords.... for one of them, take away the = sign


For your original question, you may want something like this:
var/tmp/io[0]//to store the items chosable
for(var/obj/Itemz/IiI in usr.contents)
io+=O
io+="Cancel"
switch(input("yadda yadda yada") as null|anything in io))//null|anything will make the buttons Okay and Cancel appear (Cancel == null NOT "Cancel")... 'in io' refers to the item list we made


- GhostAnime
In response to GhostAnime
Thanks, I will try this as an alternate method, I also caught the level restriction error before I had gotten to forums so, Thanks, But I found another way to do it while I was changing it around, so thanks :D
You've got a bit of a design issue there. Many new and old programmers like to use those darned inputs and make people like me suffer and try to navigate through large lists. Well, there's a better way to do what you want without doing too much more work.

First you declare the variables you'll need:
mob
var
transmuting=0 //This will be the object you are going to try to transmute.
warning_message=1 //This is a toggle for the warning message that appears when you try transmuting something. This should really go under the client, but I figured you're rather new so it'll be easier for you if you did it like this.


Next you'll want to give the items the appropriate procedures for this to function correctly:
obj
Items
Click() //What happens here is that when your transmuting is set to 1, it'll change into the reference to the object you want to transmute.
if(usr.transmuting==1)
usr.transmuting=src
else
return ..() //Otherwise the default action happens.
proc/Transmute()//This is what happens when you try transmuting that object. Right! This should go under the object you want to transmute, not the Transmuting Circle thingy.

iron //Here's a little example
Transmute(var/mob/M)
if(M.level<=5)
new/obj/Items/sword(M)
else if(M.level>5)
new/obj/Items/better_sword(M)


Now to hammer out that Transmuting Circle:
obj
transcircle
icon = 'objects.dmi'
icon_state = "trans1"
name="Transmutation Circle"
verb
Transmute(var/mob/M)
set name="Transmute", desc="Transmute an object in your inventory", src in view(0) //Personally, I like putting all my sets in the same line.
if(!M)M=usr //If the usr has clicked the verb instead of calling it like a procedure.
if(M.transmuting)return //Do not allow the person to try to transmute two things at once!
if(!ismob(M))CRASH("Invalid argument type.") //Just to be safe.
M.transmuting=1
while(M.transmuting==1) //This big loop will keep looping until M.transmuting is equal to anything but 1.
M<<"<font color='blue' face='Comic Sans MS'>Please click the object that is in your inventory that you wish to transmute.</font>" //Friendly message.
while(M.transmuting==1) //This nested loop will just delay the procedure from running until you click on an item.
sleep(1)
if(!istype(M.transmuting,/obj/Items)||!(M.transmuting in M))
M.transmuting=1
M<<"<font color='blue' face='Comic Sans MS'>This object is not yours so you cannot transmute it.</font>" //Make sure they're not transmuting something that isn't an item, or something that isn't theirs.
continue
if(M.warning_message) //Here's the warning message, if M.warning_message is 0, nothing is displayed.
if(alert(M,"You have chosen to transmute [M.transmuting], are you sure you want to proceed?","Transmuting","Yes","No")=="No")
M.transmuting=1 //Go back to the beginning
var/obj/Items/o=M.transmuting
o.Transmute(M) //Transmute the object!
M.transmuting=0 //Reset the variable for next time.


Well, I guess that's a better object-oriented approach at it :). It's also probably easier to navigate through what exactly you want to transmute instead of getting a list of text of what you want. I hope this helps!