Skip to content

map

Shows map items to players and sets the area they show and their course of pins.

Source: src/Moongate.Server.Ultima/Modules/MapModule.cs

map.add_world_pin(serial, x, y) -> boolean

Adds to the course of a map item a pin at the tile x, y of the world, where its drawing shows it, as a treasure map marks its chest. False for an unknown or held item, one with no area, a tile outside its area or a course of 50 pins already.

Marks on a map the tile where a chest is buried:

map.add_world_pin(serial, chest_x, chest_y)
map.set_protected(serial, true)
ParameterTypeDefault
serialinteger
xinteger
yinteger

Returns boolean.

map.bounds(serial) -> any

The area a map item shows, as { x1, y1, x2, y2, width, height, facet }: its own, else the one of its preset template. Nil for an unknown item or one with no area.

ParameterTypeDefault
serialinteger

Returns any.

map.display(player, serial) -> boolean

Opens the map item for the player: its area, its course of pins and whether the player may change it. False for a player not in the world, an unknown item, an item with no area (a blank map), or a map of a facet other than Felucca and Trammel to a client older than 7.0.13. It does not check the distance: a script does.

A sign that shows the map it holds to whoever uses it:

function town_map_sign.on_use(serial, user)
local held = item.get_prop(serial, "map")
if held then
map.display(user, held)
end
return true
end
ParameterTypeDefault
playerinteger
serialinteger

Returns boolean.

map.pins(serial) -> table

The course plotted on a map item, as an array of { x, y } in pixels of its drawing, in order. Empty for an unknown item or one with no course.

Tells the player how many stops the course plotted on a map has:

mobile.message(user, "The course has " .. #map.pins(serial) .. " stops.")
ParameterTypeDefault
serialinteger

Returns table.

map.set_bounds(serial, x1, y1, x2, y2, width, height, facet) -> boolean

Sets the area a map item shows: its north-west corner x1, y1 and south-east corner x2, y2 in tiles (kept within 0 to 5119 and 0 to 4095), the size of its drawing in pixels (1 to 800, 200 for a small map) and the facet (0 Felucca, 1 Trammel, 2 Ilshenar, 3 Malas, 4 Tokuno, 5 Ter Mur). The course keeps its pixels: clear or set it again after changing the area. False for an unknown or held item, corners not north-west of each other, no drawing or an unknown facet.

Draws on a blank map the 400 tiles around the player:

local here = mobile.location(user)
map.set_bounds(serial, here.x - 200, here.y - 200, here.x + 200, here.y + 200, 200, 200, here.map)
ParameterTypeDefault
serialinteger
x1integer
y1integer
x2integer
y2integer
widthinteger
heightinteger
facetinteger

Returns boolean.

map.set_editable(serial, editable) -> boolean

Sets whether the course of a map item may be changed, as the lock of its window does. False for an unknown or held item.

ParameterTypeDefault
serialinteger
editableboolean

Returns boolean.

map.set_pins(serial, pins) -> boolean

Replaces the course of a map item with an array of { x, y } in pixels of its drawing (0 to width - 1, 0 to height - 1); an empty array clears it. False for an unknown or held item, one with no area, more than 50 pins, or a pin without numbers x and y or off the drawing.

ParameterTypeDefault
serialinteger
pinstable

Returns boolean.

map.set_protected(serial, guarded) -> boolean

Sets whether no player may ever change the course of a map item, as for a map a quest gives. False for an unknown or held item.

ParameterTypeDefault
serialinteger
guardedboolean

Returns boolean.

Made with ❤️ by Tom

Buy me a coffee