Positioning maplabel

All and any discussion and development of the Mudlet Mapper.
Post Reply
Nyyrazzilyss
Posts: 334
Joined: Thu Mar 05, 2015 2:53 am

Positioning maplabel

Post by Nyyrazzilyss »

I'm playing around with map labels right now

createMapLabel(areaID, text, posx, posy, posz, fgRed, fgGreen, fgBlue, bgRed, bgGreen, bgBlue, zoom, fontSize, showOnTop, noScaling)

In particular, i'm adding labels for zone edges (the name of the bordering zone). First issue i'm running into is x,y,z look to be always the top left corner of the label. If I create it on the left size of the map, however, i'm going to want the label to display to the left of the room, not to the right of it (on top of/or behind existing rooms). I did try subtracting a bit from posx to move where the label is actually created, which sortof works - Until you zoom in/out of the map, at which point the labels gets moved, usually to the wrong place.

Also, i'd like to have clicking on the label switch the map display to that area.

Questions:

Is what i'm trying to do something that has been done previously in another script, and am I just using the zoom/scaling/etc properties incorrectly? Anyone have a link to a script that already does this I could look at?

Do map labels have a click callback function?

User avatar
SlySven
Posts: 1019
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Positioning maplabel

Post by SlySven »

A quick review of the code suggests not - it might be possible to add such functionality, but at present user action/menus CAN be allocated to the context (right-click) menu that pops-up on. If it was, you may have to deal with the cause where the label is UNDER a room. I do note that the map label GUI functions are very limited and do not offer much in the way of interactive editing (they cannot be resize or the text/font/colours edited) but at present this is waaaaay-down my to-do list. :(

Nyyrazzilyss
Posts: 334
Joined: Thu Mar 05, 2015 2:53 am

Re: Positioning maplabel

Post by Nyyrazzilyss »

No problem, thanks for looking -

I wasn't using map labels at all previously. I can make things sortof work with the existing code, just wasn't sure if what I was hoping to do would have been just a matter of changing how I was using the functions. If it becomes a major issue i'll take a look at the code also, but it's really cosmetic.

(edit)

Here's a code fragment below that helps with label location, and has scaling options set properly

local x,y,z = getRoomCoordinates(room)
local length = string.len(message)

if direction == 1 then -- north
y=y+1.5+1
x=x-length/3.5
end

if direction == 4 then -- east
y=y+.5
x=x+.5+1
end

if direction == 5 then -- west
y=y+.5
x=x-(length/1.5)-.5-1
end

if direction == 6 then -- south
y=y-.5-1
x=x-length/3.5
end

if (z) then
createMapLabel(getRoomArea(room), message, x, y, z, f1,f2,f3, b1,b2,b3, 15, 15, false, false)
end

Post Reply