ID:141954
 
Code:
obj
clickable
equip
icon='visual.dmi'
icon_state="equip"
Click()
world<<"1"
var/templist[]=new
for(var/n in usr.weapons)
world<<n
templist+=n
world<<templist
var/q=input("Select from your weapons.") in templist
usr.selected_weapon=q
var/obj/gun/w=new usr.selected_weapon()
w.equip(usr)


Problem description:

The general idea is just to select an item from a type path to use. I hope the code explains it better than I do. Sorry for the spam of questions, this is the last for the night; promise! :p


This is the gun procedure:

obj
gun
var
bullet_type
proc
equip(mob/m)
m.equipped=1
m.selected_weapon=src
dequip(mob/m)
if(!m.equipped)
return
m.selected_weapon=null
pistol
icon='gun.dmi'
icon_state="pistol"
bullet_type=/obj/bullet/pistol

not sure what you are trying to do but I think this covers it

save the type thing as a string
"/obj/bullet/pistol"

and then you can used text2path to return it at a later time.
(maybe when your creating bullets)
As for your problem, I see some issues in the code but I'm not so sure what you're actually trying to do, but why on earth do you have both equipped and selected_weapon vars? :P You should only have one, which keeps track of the equipped weapon. It can detect when nothing is equipped all the same, because when the player has nothing equipped you set it to a false value (null) instead of to an object reference.
mob
var/obj/weapon/equipped_weapon
obj/weapon
verb
Equip()
if(usr.equipped_weapon)
usr << "You already have [usr.equipped_weapon] equipped."
return
usr.equipped_weapon = src
Unequip()
if(!usr.equipped_weapon)
usr << "You have nothing equipped."
return
usr.equipped_weapon = null
In response to Kaioken
I have an on screen button which I want to click to bring up a list of weapons the player currently has, the player selects it (which is what I was trying to do with the templist :p) then whenever he uses the 'shoot' macro, it will shoot the selected weapon type.

The bullet_type is the actual pistol reference to be created (I already have all the properties set up for the bullet for when it's created)



You should lose the mob/var/equipped variable. It tells you nothing that selected_weapon doesn't tell you already, and selected_weapon has more information.

Lummox JR
In response to Speedro
But isn't being equipped basically identical to being selected, now? Then you don't need 2 vars for it, and the equipped var is less useful than the other one anyway.
Also, in your first post, it seems you're having trouble with the selection itself? The input() shouldn't be in the loop, and also you could simply do this:
Click()
usr.selected_weapon = input("Select weapon") in usr.weapons

No loop or extra list / messing should be required as far as I see it. =)
In response to Kaioken
Thanks ^_^