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
Functions
Section titled “Functions”add_world_pin
Section titled “add_world_pin”map.add_world_pin(serial, x, y) -> booleanAdds 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)| Parameter | Type | Default |
|---|---|---|
serial | integer | |
x | integer | |
y | integer |
Returns boolean.
bounds
Section titled “bounds”map.bounds(serial) -> anyThe 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.
| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns any.
display
Section titled “display”map.display(player, serial) -> booleanOpens 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 trueend| Parameter | Type | Default |
|---|---|---|
player | integer | |
serial | integer |
Returns boolean.
map.pins(serial) -> tableThe 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.")| Parameter | Type | Default |
|---|---|---|
serial | integer |
Returns table.
set_bounds
Section titled “set_bounds”map.set_bounds(serial, x1, y1, x2, y2, width, height, facet) -> booleanSets 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)| Parameter | Type | Default |
|---|---|---|
serial | integer | |
x1 | integer | |
y1 | integer | |
x2 | integer | |
y2 | integer | |
width | integer | |
height | integer | |
facet | integer |
Returns boolean.
set_editable
Section titled “set_editable”map.set_editable(serial, editable) -> booleanSets whether the course of a map item may be changed, as the lock of its window does. False for an unknown or held item.
| Parameter | Type | Default |
|---|---|---|
serial | integer | |
editable | boolean |
Returns boolean.
set_pins
Section titled “set_pins”map.set_pins(serial, pins) -> booleanReplaces 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.
| Parameter | Type | Default |
|---|---|---|
serial | integer | |
pins | table |
Returns boolean.
set_protected
Section titled “set_protected”map.set_protected(serial, guarded) -> booleanSets 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.
| Parameter | Type | Default |
|---|---|---|
serial | integer | |
guarded | boolean |
Returns boolean.
Made with ❤️ by Tom
