ID:1353104
 
(See the best response by DivineTraveller.)
I and my friends are wondering and trying how to do a map editor in-game. so we could have 3 mapper "colaboration" while the game is live...

I will show you a simple example about how I was thinking.

Code:
//I'm add the turfs to stat(inventory) contents list var, because
//I don't know make list like "contents".
// Click(location,control,params)


mob/var
mode_mapper=0
var
active_obj_for_map
list/mappers = list("my_key","my_friend")
mob/verb/mode_mapper_Toggle()
if(!src.key in mappers)return
if(mode_mapper)
usr.mode_mapper=0
return
else
usr.mode_mapper=1
return
turf/turfs
icon='Pant.dmi'
grass
icon_state=""
water
icon_state="2"
waterfall
icon_state= "3"
door
icon_state="4"

Click()
if(usr.mode_mapper)
if(active_obj_for_map.id == "water")
var/turf/water/s=new(src.loc)
if(active_obj_for_map.id == "grass")
var/turf/grass/s=new(src.loc)

usr<<"you add [active_obj_for_map.id] in the map" //this is a msg 4 test...

//this is a example of how I was try to do it... since this is other pc and I don't have the original project.


Problem description:

I'm try from 19 days ago, and yet I can't do it... I don't know how can I do which work it. Please if somebody has a example pls help me...
I didn't sleep today because I'm still thinking about in that...

Please somebody what know how-do it.. pls help to do it together.
Best response
As a general rule of thumb, you don't want to try to create new turfs - it causes wonky behaviour. Instead, I'd recommend using objects and setting them on TURF_LAYER.

This is just a start, though, for a more full map creation system you'd need to wrap Enter()/Entered()/Exit()/Exited() (make the turf version call the objects version) and have some form of map saving/loading in place.
using object (obj as turf)?

example
Code:
obj
grass
icon='turfs.dmi'
icon_state="grass"

Like this?

other question: how can I do a list with all the turfs for the stat panel? but than the turfs be diferent, since if add Click() when somebody click in the turf on the map then the Click() function do it...

Code:
obj/turfs
grass
icon='turfs.dmi'
icon_state="grass"
Click()
..()//here the proc to do a new turf
mob/Stat()
if(!client)return
var/i = 0
for(var/obj/turf/s in src.TurfMap) //TurfMap is a list
usr << output(s,"Mapper_Grid:2,[++i]")
..()


I'd like know how can I do what obj/turf/grass "is in the floor" be diferent than "obj/turf/ in the "Mapper_Grid".
Yes, that's basically it. In obj/turfs/Click() you'll want to set the usrs active_obj_for_map, so the program understands what you want to drop on the map. Then, you'll want to add a /turf/Click() that checks if the usr has an active_obj_for_map, and if so, place a new one on the map.
In response to DivineTraveller
As a general rule of thumb, you don't want to try to create new turfs - it causes wonky behaviour. Instead, I'd recommend using objects and setting them on TURF_LAYER.

Where did you get this idea? Creating new turfs doesn't create any strange behavior at all. It deletes the old turf at that location, and replaces it with the new one. This is documented behavior.
In response to Ter13
Ter13 wrote:
As a general rule of thumb, you don't want to try to create new turfs - it causes wonky behaviour. Instead, I'd recommend using objects and setting them on TURF_LAYER.

Where did you get this idea? Creating new turfs doesn't create any strange behavior at all. It deletes the old turf at that location, and replaces it with the new one. This is documented behavior.

I got this idea because when I did it, it caused wonky behavior. It could have been the environment I was working in, but it happened, so I haven't given it a second try.
mmmh I'm try to do it still, but I don't know the best way to do it, I can't image how do to appear all the /turf and /obj in a grid and what when I click on them and later click on the map (what the game know what I'm drawing that turf clicked in the grid) and the better way to remplace it...

The only form what I can do something like a Map-editor is doing everything manually (example: 2 grass, 2 water, 2 wall)
1 grass to add in the map, the other grass is to add it to grid with Click() funtion. "2 grass totally diferent", I'm waiting the new byond's feature "MouseMove()", for when I move the mouse what add the turf clicked. but I'm try to think in other way "cuz I think what that what I was thinking and that I said is very bad". pls somebody give me a hand.

I just want a example and a good answer. Thanks anyway
Hello, I wrote up a couple examples of how you can use the mouse to lay down tiles. I threw in my menu library for displaying turfs on the screen for easy access.

You can either replace a turf with a new one or update the icon and icon_state of the turf at a given location.

In response to DivineTraveller's comment I would not use objects instead of turfs. I also wouldn't mark that as the best response so other's aren't directed to use objs instead of turfs.

In the file below I wrote an example of how to add new tiles at a given location based on a turf's type

https://dl.dropboxusercontent.com/u/17935054/ Map%20Editor2_src.zip

Map Editor.dm
mob
var
currentType

atom
MouseDown(turf/tile)
..()
if(tile && tile.z) // We only want to edit a tile if it's z level is greater than 0
placeTileAt(tile)
MouseDrag(turf/tile)
..()
if(tile && tile.z)
placeTileAt(tile)

proc/placeTileAt(turf/tile)
//currentType is being set in Menu.dm in the rowSelectedForTable proc
new usr.currentType(tile) // We're using usr because the usr is executing the proc through a click.


An example of how currentType is defined would be /turf/tiles/grass

Another way to look at how I'm placing the tile is:

new /turf/tiles/grass(locate(1,1,1))



In the file below I wrote an example of how to change the icon's of an existing turf.

https://dl.dropboxusercontent.com/u/17935054/ Map%20Editor_src.zip

There isn't much different other than the variables I'm using and the placeTileAt proc.

mob
var
currentIcon = 'tiles.dmi'
currentIconState = "grass"

//[Mouse functions]

proc/placeTileAt(turf/tile)
//currentIcon and currentIconState are being set in Menu.dm in the rowSelectedForTable proc
tile.icon = usr.currentIcon // We are using usr because the usr is performing the MouseDown action on the current location
tile.icon_state = usr.currentIconState


I hope this post is of some use to you or anyone else that comes acrossed it.