ID:159789
 
*MAP TELEPORTING


Hey People!! This is Gabo...

Well, my question is how to make map teleporting to work... With map teleporting I mean using a skill that shows you a small image of all your map or maps, and when you click on it you get teleported to that spot (I mean exactly that spot!! O.o)

I know this has been done, i've seen it in the game Charmed the Return, it's a downloadable game so you can get a big idea of what im talking about if you play it... I've also seen that code in Xoule's Charmed Online source, but that code just won't works T.T

I managed to make it work but only a little, it sends you only to some places in the map, and in Charmed the Return, you're sent anywhere in the map so please help me with that...

THANX A LOT!!! ^^
Well, it would help if you could describe where exactly you're running into a problem, so people could give you a hint on how they would go about it.

It'd be useful to know exactly what you plan for the graphical representation of the map as that's kind of an important hook and there is a multitude of ways to realise this idea.
In response to Schnitzelnagler
Schnitzelnagler wrote:
Well, it would help if you could describe where exactly you're running into a problem, so people could give you a hint on how they would go about it.

It'd be useful to know exactly what you plan for the graphical representation of the map as that's kind of an important hook and there is a multitude of ways to realise this idea.


<font face = "Kristen ITC"><font size=+3>W</font>ell thanx, i didn't tought of that ^^', let me show you the code and explain what everything does:
<font color=red>***CODE***</font>
Town
icon = 'FMap.png'
MouseUp(location,xx,yy)
var/turf/loca = location
var/x3 = ((loca.x-56) * 32) + xx
x3 = round(x3/2)
var/y3 = ((loca.y-47) * 32) + yy
y3 = round(y3/2)
if(x3 > world.maxx || y3 > world.maxy)
return
Orb(usr,x3,y3,2)
<font color=red>***CODE***</font>

Ok, Town is a turf, that's the map image, and it's size is 200X200px(By the way, it is 200x200 because my map size is 100x100, if the map's size was 50x300, the image's size would be 100x600 px), now when you use a skill called <font color=red>Orb_Around()</font> (That's the skill name in my game but it can be any other) you're sent to the position of the map. When you click in the map (Anywhere in it) MouseUp is activated.

var/turf/loca = location (This takes the part of the map you clicked in 32x32 px)

var/x3 = ((loca.x-56) * 32) + xx (Then you create a variable that's equal to the X of the turf - 56 because that's the lower left part of the map position in X. Then it's multiplied for 32 to make it seem like if there are 32 turfs in that space and you're set in (1,1). Finally you add xx that is the pixel_x of the Mouse, but that's were I get the bug.)

x3 = round(x3/2) (Then you round x3/2 cause the image size is the map size x 2)

var/y3 = ((loca.y-47) * 32) + yy
y3 = round(y3/2) (Then it's the same but with Y. I get another bug in ((loca.y-47) * 32) + yy)

if(x3 > world.maxx || y3 > world.maxy)
return (This just checks that you don't exceed the map size.)

Orb(usr,x3,y3,2) (Then I run a turf/proc I made called Orb, where you need a Mob to teleport, and the X, Y, and Z vars. Z is 2 because that's the map the usr's going to be sent, but if the map is somewhere else, just change the Z var.)

So this is it... I don't know what are xx, or yy values so don't ask me. I tried to change xx and yy for pixel_x and pixel_y, and tile_x; tile_y and it won't work either. I changed the code and now it's like this:

<font color=red>***CODE***</font>
Town
icon = 'FMap.png'
MouseUp(location)
var/turf/loca = location
var/x3 = ((loca.x-56) * 32)
x3 = round(x3/2)
var/y3 = ((loca.y-47) * 32)
y3 = round(y3/2)
if(x3 > world.maxx || y3 > world.maxy)
return
Orb(usr,x3,y3,2)
<font color=red>***CODE***</font>

But that only sends you into 1,1 of the turf you clicked, so if you have any ideas, please help me cause it's very frustrating...
In response to Gaboswsttj
Okay, three things:
1) Don't use goofy-looking fonts. They're just obnoxious.
2) If you're going to be obnoxious and use varying colors to show your sections, use one that goes better with blue. Red is an awful choice.
3) Use <dm> to show your code. For example the following:

<dm>
mob/Login()
world << "Hello, world!"
</dm>

Becomes this :
mob/Login()
world << "Hello, world!"
In response to Gaboswsttj
In this special case it's going to be essential to know the version of BYOND that you're using.
MouseUp has changed massively.

"Note: In BYOND 3.5 this procedure took three different arguments: location, icon_x, and icon_y. Since icon_x and icon_y have been replaced, old code will need to be modified. Games compiled before this change will still work normally."

Though, I' say listen to the warning and don't use MouseUp at all...
"Don't define this unless you need it, because it generates extra communication that is otherwise avoided. Most operations can be done through Click(), DblClick(), and MouseDrop(). The other procedures are simply available for completeness."

I'd say you can achieve what you're doing through overriding Click() with less overhead.
In response to Schnitzelnagler
Thanx for the help, so i just got 1 question left, which are the variables of the Mouse's pixel_x and pixel_y, that's all I need to fix the code... =P
In response to Gaboswsttj
Uhm, I'm not exactly sure that I know what you wanted to ask.
Did you follow the link in my posting and read up on what the reference has to say about the mouse control?

As you're overriding an atom hook, I think you can go with
atom/Click(location, control, params)

The location argument (...) will be the turf where the mouse action happened.

The control argument is the ID of the skin control where the action happened, such as "mappane.map" or "mainwindow.banner".

The params argument is text, and can be converted to a list using params2list().
icon-x, icon-y: Pixel coordinates within the icon; 1,1 is the lower left (...) will only be set if they are used.

Edit: If you are still unsure about the mouse controls, you could of use the forum search, which would reveal a link to this thread which contains this example to explicitly show what you seem to be seeking.
In response to Schnitzelnagler
Note the location argument isn't just like src.loc (it'd be pointless then); it could also actually be equal to a text string instead if the object wasn't clicked from the map (containing the statpanel's name, or the grid control's cell).
In response to Kaioken
I was trying to simplify the statement provided by the reference as he seemed to have trouble reading it.
In this case, it should be the turf, as for how I understood the provided code.
In response to Schnitzelnagler
In 'this' case yes, but once you place the override it can be called for anything. Even if you implemented it for clicking on the map, a player could still try clicking on something in his statpanel, for example, which might cause errors if a proc relies on the argument always being an atom and treats it as such. Of course, this is especially probable if you override at an ancestor-level like /atom.
In response to Kaioken
Well, thanx for all the help, I finally got the code to work with your help.

The code was like this in the end:
turf
Maps
Town
icon = 'FMap.png'
Click(location,control,params)
var/turf/loca = location
var/list/p=params2list(params)
var/x3 = ((loca.x-56) * 32) + text2num(p["icon-x"])
x3 = round(x3/2)
var/y3 = ((loca.y-47) * 32) + text2num(p["icon-y"])
y3 = round(y3/2)
if(x3 > world.maxx || y3 > world.maxy)
return
Orb(usr,x3,y3,2)


Thanx for all the help ^^
In response to Gaboswsttj
Remember instead of doing something like this-
MyProc(Arg)
var/atom/A = Arg

You can just initially define the variable with the needed type (arguments can be defined just like any other var):
MyProc(atom/Arg)


Though, you should probably just use src instead of the location argument. That way you won't have to worry about it possibly being text, and src is even a little easier to use.