Hello everybody, I am working on a little something involving lists and paths when I suddenly ran into a issue: when I use a verb to pick from a list, it'll return in the form of a path, not a name.
Now I know this has been extensively asked before and people gave answers such as using a Associative list like so:
obj
Apple
Orange
var/list/Fruits = list("Apple" = /obj/Apple, "Orange" = /obj/Orange)
mob/verb
All_Fruits(anything in Fruits)
But using this method just wont cut it out for me, since it would be a pain to do this for every single equipment I have.
So I asked for some help in Skype and a friend of mine told me I could return the name of said path with something like:
proc
path2name(path)
path = "[path]"
var pos, lastPos
do
lastPos = pos
pos = findtextEx(path, "/", pos + 1)
while(pos)
return copytext(path, lastPos + 1)
This indeed returns the name of said path. But there's a catch. It doesn't link the name to the path.
I want to be able to actually link the name to a specific path, like how Associative lists do. How can I go upon doing this?
What I have right now only returns the name, which is pretty useless..