ID:178907
 
How do you use the mouse to drag around building a turf of your choice?
MouseDrop(var/atom/A,var/atom/A2,var/turf/start,var/turf/end)
end = new start.type(end)
start = new world.turf(start)

Is that what you mean? That will create essentially "move" the turf to the location you drop it at.

If you mean continuously creating then use:
client
var/create_type //get this from some sort of input
MouseDrag(var/atom/A,var/atom/A2,var/turf/start,var/turf/ current)
if(start.type != create_type) start = new create_type(start)
current = new create_type(current)
In response to English
i got errors can you tell me the whole thing?
Tazor07 wrote:
How do you use the mouse to drag around building a turf of your choice?

About the simplest possible way to do this:
obj/buildicon
var/buildtype=/turf/grass

New()
..()
mouse_drag_pointer=icon_state

MouseDrop(atom/over_object,atom/src_location,turf/over_location)
if(over_location) // it's null if you drag to a stat panel
new buildtype(over_location)

Obviously you'll want to throw in some more checks on this, like you can't build on certain tiles, etc.

over_location is the turf where you drop the thing you're dragging. When it's dropped, Mousedrop() is called, and an atom of the type you want will be created.

Lummox JR
In response to Tazor07
What were the errors? Make sure it's the client version of MouseDrag because there is also an atoms version of MouseDrag that takes slightly different parameters.

The second thing is to make sure you assign a type to create_type like this:
client
verb
Build_Type()
create_type = input("What kind?","Build Type") in typesof(/turf)

Then as Lummox said you need some checks in there to make sure both locations exist and that a create_type was selected.
In response to English
says create_type:undefined var
In response to Tazor07
You need to define it then. That MouseDrag is a client proc create_type should be a client var.

client
var/create_type
In response to English
when i put that var thing it doesnt come with any errors but it doesnt work
In response to Tazor07
Did you assign a type to it?

I just copied and pasted it into my test world and it works fine.
In response to English
i mean it shows all the turf in the box but when i click ok and click around it doesnt work
In response to Tazor07
Are you dragging the mouse arround or just clicking?

I copied and pasted it into another one of my games and it worked fine in there too...
In response to English
o score! i got it to work, thanks alot!
In response to Tazor07
One more thing, if i have my code like this it messes up when i create how do I fix?

mob
admin
key = "Tazor07"//Change my key to yours!
icon = 'Characters.dmi'
icon_state = "MasterRagnar"
density = 1
Login()
world << "<font color = red>King [src] has entered!"
..()
var/create_type //get this from some sort of input
MouseDrag(var/atom/A,var/atom/A2,var/turf/start,var/turf/ current)
if(start.type != create_type) start = new create_type(start)
current = new create_type(current)
verb
Admin_Build()
set category = "Admin"
create_type = input("What kind?","Build Type") in typesof(/turf)
In response to Tazor07
It's because there are two versions of MouseDrag. One for atoms and one for clients. The example I gave was the client version so it needs to be under client, not mob. When you have MouseDrag under the admin mob it will only be called when you try to drag an admin.

One way to limit access would just to put a test statment in there:

client
MouseDrag(//normal stuff here)
if(istype(mob,/mob/admin)) // sees if player is admin
//do like normal here

Then when you use create_type you either have to change all the create_type vars in the MouseDrag proc to mob.create_type or you can make it a client variable and access it inside your admin verb with client.create_type
In response to English
It says this in the game everytime i add

runtime error: bad loc
proc name: MouseDrag (/mob/MouseDrag)
source file: Admin.dm,355
usr: Tazor07 (/mob/admin)
src: Tazor07 (/mob/admin)
call stack:
Tazor07 (/mob/admin): MouseDrag(TopStatue (24,24,1) (/turf/TopStatue), Floor (24,25,1) (/turf/Floor), TopStatue (24,24,1) (/turf/TopStatue), null)
runtime error: bad loc
proc name: MouseDrag (/mob/MouseDrag)
source file: Admin.dm,355
usr: Tazor07 (/mob/admin)
src: Tazor07 (/mob/admin)
call stack:
Tazor07 (/mob/admin): MouseDrag(TopStatue (24,23,1) (/turf/TopStatue), Floor (24,25,1) (/turf/Floor), TopStatue (24,23,1) (/turf/TopStatue), null)
In response to English
Can you please show me a example of how i make it so admins only use it?