docs
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
-- Manages game maps.
|
||||
|
||||
local _maps = {}
|
||||
|
||||
--- Gets all registered maps as an array.
|
||||
-- @return table An array of registered map data.
|
||||
function Map.get_maps_array()
|
||||
local maps_array = {}
|
||||
for _, map_data in pairs(_maps) do
|
||||
@@ -8,6 +12,8 @@ function Map.get_maps_array()
|
||||
return maps_array
|
||||
end
|
||||
|
||||
--- Registers a map definition.
|
||||
-- @param map_data table The map data table.
|
||||
function Map.register(map_data)
|
||||
if _maps[map_data.id] then
|
||||
trace("Warning: Overwriting map with id: " .. map_data.id)
|
||||
@@ -15,10 +21,15 @@ function Map.register(map_data)
|
||||
_maps[map_data.id] = map_data
|
||||
end
|
||||
|
||||
--- Gets a map by ID.
|
||||
-- @param map_id string The ID of the map.
|
||||
-- @return table The map data table or nil.
|
||||
function Map.get_by_id(map_id)
|
||||
return _maps[map_id]
|
||||
end
|
||||
|
||||
--- Draws a map.
|
||||
-- @param map_id string The ID of the map to draw.
|
||||
function Map.draw(map_id)
|
||||
local map_data = Map.get_by_id(map_id)
|
||||
if not map_data then
|
||||
@@ -32,4 +43,4 @@ function Map.draw(map_id)
|
||||
map_data.to_x,
|
||||
map_data.to_y
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user