ID:144414
 
Code:
                            var/stufftobuild[0]
stufftobuild+=typesof(/turf/estate)
switch(input("What are we building?") as null|anything in stufftobuild)
if(null)
usr<<"You build nothing."
if("something in list")
new/turf/estate/x(usr.loc)

usr<<"You build [x]"
else
usr<<"Say what?"


Problem description:

I'm working on Citizen's build verb and I want players to be able to pick from a list of buildable turfs. I've figured out how to make this work, but I can't wrap my head around compiling the turf names instead of the type paths. A pre-emptive thanks for anyone brave enough to clue me in.

This is how I do it.
var/area[0]
proc/CreateAreas()
areas["Battle"] = /area/Battle
areas["Town"]= /area/Town
areas["Casino"]=/area/Casino
areas["Dungeon"]=/area/Dungeon
areas["Boss"]=/area/Boss
areas["Forest"]=/area/Forest
areas["Castle"]=/area/Castle
areas["Cave"]=/area/Cave
areas["Jail"]=/area/Jail
areas["Bar"]=/area/Bar
areas["Wilderness"]=/area/Wilderness
areas["Temple"]=/area/Temple
buildsomething = input("?") as null|anything in areas
world
New()
CreateAreas()
That is my area code.
In response to Xx Dark Wizard xX
Nice. But is there a way to code it to be more intuitive. I'm expected there to be many many new turfs to be added to the list of buildable turfs. I'd like to avoid having to add each one to the build verb.

Is there a way to parse only the last word of the type path? i.e. remove /turf/estate from each turf typepath returned by typesof(/turf/estate)? Or to index the turf.name while still using typesof()?
In response to Ariii
I couldn't find a way, Just copy paste alot.
In response to Ariii
Just create a list full of objects by going through typseof() and doing new() for each type. Then use the names for those elements. But you might want to delete the list after.
In response to Troubador0
Troubador0 wrote:
Just create a list full of objects by going through typseof() and doing new() for each type. Then use the names for those elements. But you might want to delete the list after.

to delete the items after*

Normally they'd get garbage-collected anyway, but might as well just delete them right away.

But yeah, on the principal, you were right.
See the second code block in my post [link] for a code example of that (specifically for monsters, but it can be for anything, of course).
DarkWizard, take in mind, you were saying there's no simple way etc while the aforementioned post ([link]) was replied to you...and in that topic, you didn't really even read it whole, apparently.