ID:178313
 
And you thought I was going to complain about all the build verb requests.. fooled you.

Actually, I have read through almost every post that has to do with build but none of them pertain to my likings. I strongly believe that having to walk over a turf to replace it with another turf is a hassle, so I ask everyone this:

What would be the best way to construct a verb which is hidden from a category and is only accessible by right-clicking a turf on the player's screen? Once the verb is selected, how would it then pull each turf defined in a Turf.dm file and throw them into a switch from which the player chooses from? Finally, and obviously, the selected input would replace the existing turf.

Knowing my luck, I read every post except the one with the solution. In the same sense, I'd go to Las Vegas with $10,000 to gamble and come home broke, missing a few fingers. If such a post exists, I would be most thankful to obtain the thread#.

Thank you in advance,
Matic293
heres a start it isnt whatya want but its a start

turf
entered_building //when the player enters entered building the area it allows the verb Build_rock to be enabled ect...
Entered()
usr.verbs += /mob/hidden/verb/Build_Rock
usr.verbs += /mob/hidden/verb/Build_2ndRock
usr.verbs += /mob/hidden/verb/Build_Floor
usr.verbs += /mob/hidden/verb/Build_Grass
usr.verbs += /mob/hidden/verb/Build_Door
usr.verbs += /mob/hidden/verb/Build_Road
Exited() //when the player enters exits the same area it will remove the verbs!
usr.verbs -= /mob/hidden/verb/Build_Rock
usr.verbs -= /mob/hidden/verb/Build_2ndRock
usr.verbs -= /mob/hidden/verb/Build_Floor
usr.verbs -= /mob/hidden/verb/Build_Grass
usr.verbs -= /mob/hidden/verb/Build_Door
usr.verbs -= /mob/hidden/verb/Build_Road
mob/hidden/verb/Build_Rock() /*what this does is creates a new wall at your postion and before addingit
it checks if you have enough buildpoints. If you do it will build if not then it wont. Ask me if you have any questions.
*/

set category = "Building"
if(build_points >= 1)//checks to see if player has enough buildpoints
usr << "You start to build!"
new/turf/wall(locate(usr.x,usr.y,usr.z))//creates a new wall
build_points -= 1//once built it takes 1 build_point so the player cant have unlimited building
mob/hidden/verb/Build_2ndRock()
set category = "Building"
if(build_points >= 1)
usr << "You start to build!"
new/turf/wall2(locate(usr.x,usr.y,usr.z))
build_points -= 1
mob/hidden/verb/Build_Floor()
set category = "Building"
if(build_points >= 1)
usr << "You start to build!"
new/turf/jail_floor(locate(usr.x,usr.y,usr.z))
build_points -= 1
mob/hidden/verb/Build_Grass()
set category = "Building"
if(build_points >= 1)
usr << "You start to build!"
new/turf/grass(locate(usr.x,usr.y,usr.z))
build_points -= 1
mob/hidden/verb/Build_Door()
set category = "Building"
if(build_points >= 1)
usr << "You start to build!"
new/obj/door(locate(usr.x,usr.y,usr.z))
build_points -= 1
mob/hidden/verb/Build_Road()
set category = "Building"
if(build_points >= 1)
usr << "You start to build!"
new/turf/Rock(locate(usr.x,usr.y,usr.z))
build_points -= 1

turf/lumber_yard
icon = 'build.dmi'
icon_state = "lumber"
verb/Get_Lumber()
set src in oview(1)
usr.build_points+=1
In response to Mrhat99au
Some start.. err, right.

Anyone else have a umm, less complex example I could refer to? One that wouldn't force me to rewrite my entire game? =P
Here's an exmple that should do the trick. :)
var // global var
build_list = list("Red Turf" = /turf/red, "Green Turf" = /turf/green)
/* fill this list in with the turfs players may build. You should
enter them in the format:
text = turf_path
where text is the text you want to appear in build menu, and
turf_path is the path for the turf. */


turf
blue
icon = 'blue.dmi'
verb/build()
set category = null // so it does not appear in the verb panels
set src in oview()
// select a type from the global buildlist
// null allows for no input, so the player may cancel
var/T = input("What would you like to build?","Build what?") as null|anything in build_list
if(!T) return // return without doing anything if the player cancelled
var/Type = build_list[T] // get the type
new Type(src) // create a new turf where this turf is

red
icon = 'red.dmi'
green
icon = 'green.dmi'

world
turf = /turf/blue
In response to Shadowdarke
Thank you for your wonderful example! It worked so well, I built a screen-sized fortress of red and green squares in your honor! (I didn't change the provided build_list to the likings of my turfs, and was having a good time.)

I've seen one example where someone defined a list with the contents of a .dm file. Instead of having to add every turf into the list manually, can I just tell the var "Hey! Do all the work for me and list all /turfs in 'Turfs.dm!'" and if so, how would one go by doing this?

Never satisfied but sincerely,
Matic293
In response to Matic293
Use the typesof() proc to list everything under /turf, but it doesn't turn out very pretty :o)
In response to Shadowdarke
Shadowdarke wrote:
> var   // global var
> build_list = list("Red Turf" = /turf/red, "Green Turf" = /turf/green)
> /* fill this list in with the turfs players may build. You should
> enter them in the format:
> text = turf_path
> where text is the text you want to appear in build menu, and
> turf_path is the path for the turf. */

>
> turf
> blue
> icon = 'blue.dmi'
> verb/build()
> set category = null // so it does not appear in the verb panels
> set src in oview()
> // select a type from the global buildlist
> // null allows for no input, so the player may cancel
> var/T = input("What would you like to build?","Build what?") as null|anything in build_list
> if(!T) return // return without doing anything if the player cancelled
> var/Type = build_list[T] // get the type
> new Type(src) // create a new turf where this turf is
>
> red
> icon = 'red.dmi'
> green
> icon = 'green.dmi'
>
> world
> turf = /turf/blue
I'd like to take this a step further by limiting this type of process to be available only to the GM and Administration. I had players running around the world map causing global flooding. ^_^'

This is how I acknowledge the player has GM powers:
mob/PC
if(src.key == "Matic293")
for(var/verb/I in typesof(/mob/GM/verb)) src.verbs += I
I've attempted to remove the turf/verb/build() when a player logs in with no luck. I'm guessing a verb cannot be taken away from a turf. Any ideas?

. . . Shadowdarke rocks!

Matic293
In response to Matic293
You'll have to make it a mob proc that accepts a turf argument, then add it to GM players on login.

mob/proc/build(turf/Where)
set category = null // so it does not appear in the verb panels
// select a type from the global buildlist
// null allows for no input, so the player may cancel
var/T = input("What would you like to build?","Build what?") as null|anything in build_list
if(!T) return // return without doing anything if the player cancelled
var/Type = build_list[T] // get the type
new Type(Where) // create a new turf where this turf is