ID:170833
 
Hi, I am trying to make it so when I click ont he map screen I have the user is located to a new area.
I know how to do this with the entered() proc and that works fine but I would prefer for it to need to be clicked on for something I am implementing later on.
The trouble is that I am using areas for the things to click on and whenever I run a click command with
client
Click(O)
usr << "You clicked on [/area/O]"//used to check whats being clicked will be removed later
..()

area
ToSand
Click() //on click
usr.loc = locate(40,40,2) //user is located to 40,40,2


The output to usr says I am clicking on the object "worldmap" rather than the area ToSand. I have experimented with this a bit but still cannot find how to make this work without changing the areas to objects which I don't want to do.

Can anyone tell me how to make it so the area is clicked on instead of the object please?

Ramini
hmmm Clicking areas is a little diffucult. But I went into my testword and found out this.

area/ClickingArea
Click()
world << "U clicked the area.."

client
Click(O)
var/area/A
for(A in world)
if(O in A)
A.Click()
break
..()

What this will do is output the U clicked the area.. message when you click on an object, or turf that is contained with in the clickingArea's area. Not sure this is what you wanted but I hope it helps.

True the for loop can be pretty painful because its looping through the whole world every time you click but. You could do this if you want.

world
New()
var/atom/A
var/area/Area
for(A as mob|obj|turf in world)
for(Area in world)
if(A in Area)
A.harea = Area
break
..()
atom/var/harea


This code declares harea to the area that contains that object. So in the click code you would only need to do a var/area/A = A.harea
A.Click()
Then again it does give all objects in world under atom object a new variable which is somthing you may not want.
In response to Green Lime
There are a few ways to handle area clicking. If you only want to click on areas, just alter mouse_opacity.
atom
mouse_opacity = 0 // invisible to mouse
area
mouse_opacity = 2 // always clickable

In response to Shadowdarke
Thanks for your help, I can't try it now as I didn't bring my latest version of my code home with me (Wasn't expecting to have much free time)
I haven't used mouse_opacity before but that sounds about right for what I need, I'll try both and see if one is faster maybe.
Again thanks
Ramini