I've been trying to think of a way to do this all day now and I feel like I must be overthinking it so I felt like it was time to ask for help.
I need to find a way to create a new obj in-game without defining the type path of that obj.
Basically the code is coming down to asking the player to input the name of an item in the game, and then creating a copy of that item for them. The items having multiple obj paths.
obj/item/weapon/sword/longsword
obj/item/weapon/sword/greatsword
obj/item/weapon/polearm/spear
obj/item/shield/round
obj/item/armor/chest/leather
things like that.
I'm using an input, that asks them to input a line of text, then search the items for one who's name var matches, then create that item for the player. I've tried a few different ways and I'm just drowning in a sea of "Undefined type path" errors.
ID:2199512
Jan 12 2017, 12:01 am
|
|
That's not really an option.
Think of this like a Genie granting a wish. You tell them what you wish for and they give it to you, but if you don't know the item exists, how are you suppose to wish for it? I just found a way to do what I needed. It's simple enough. Never realized .type was a thing up until now. var/obj/item/iwish = new X.type seems to be doing the job I need. |
var/list/Granted=list("Items")//You can add more I think you would make a list of the stuff like this, just add a little twick to it and you might get what you want. |
In response to IceFire2050
|
|
IceFire2050 wrote:
Think of this like a Genie granting a wish. You tell them what you wish for and they give it to you, but if you don't know the item exists, how are you suppose to wish for it? Do you actually want them to type in what they want, instead of selecting from an input of all the item names? I wrote some simple code up in either case if you wish to look at it. var list/genie_wishes |
You could ask them to just type the path itself or build a list of valid names and ask them to choose one, though.