Difference between revisions of "Resource:Mapmanager"

From Multi Theft Auto: Wiki
Jump to: navigation, search
(Need opinions on this)
 
(Updated)
Line 1: Line 1:
This page describes an implementation for the map manager, the resource which will take care of map listing and gamemode/map interactions.
+
The map manager lists maps and manages gamemode and gamemode map loading.
  
 
==Usage==
 
==Usage==
The manager will assume all map and gamemode resources are correctly tagged as such in the meta file.
+
You have to tag the '''gamemode resource''' with the correct type in its info tag:
 
 
 
<syntaxhighlight lang="xml"><info description="A gamemode" type="gamemode" /></syntaxhighlight>
 
<syntaxhighlight lang="xml"><info description="A gamemode" type="gamemode" /></syntaxhighlight>
  
Map resources can optionally specify the gamemodes for which they have been designed in a comma-separated list:
+
'''Map resources''' also need the ''type="map"'' tag, plus a ''gamemodes'' tag listing the gamemode resources they're compatible with in a comma-separated list ''without spaces''.
 
<syntaxhighlight lang="xml"><info description="A gamemode map" type="map" gamemodes="ctv,koth" /></syntaxhighlight>
 
<syntaxhighlight lang="xml"><info description="A gamemode map" type="map" gamemodes="ctv,koth" /></syntaxhighlight>
  
There can be only one gamemode and one gamemode map loaded at once. When a map resource is started via ''start'', the manager will check if any of the gamemodes it is compatible with is loaded, and change the current gamemode map in that case. Else, it will just be loaded as a normal map.
+
There can be only one gamemode and one gamemode map loaded at once.
 +
 
 +
==Commands==
 +
'''changemap newmap [newgamemode]''' (changes the gamemode map to a new one, optionally changing the gamemode as well)
 +
 
 +
'''gamemode newgamemode [newmap]''' (changes to a new gamemode, optionally starting a map with it)
  
The map manager will also provide special commands to start a map running a specific gamemode (for example ''startmap map_mall -g copsnrobbers'') or the other way around (''gamemode copsnrobbers -m map_mall'').
+
'''maps [gamemode]''' (lists all maps in the server, optionally all maps compatible with a gamemode)
  
There should be a web interface, with a tree of maps registered under each gamemode and start/stop controls.
+
'''gamemodes''' (lists all gamemodes)
  
 
==Exported functions==
 
==Exported functions==
<syntaxhighlight lang="lua">
+
<syntaxhighlight lang="lua">bool changeGamemode ( resource newGamemode, [ resource mapToLoadWith ] )</syntaxhighlight>
bool changeGamemode ( resource gamemode )
+
Changes the gamemode to a new one, optionally specifying an initial map for it (will load without a map by default).
bool changeGamemodeMap ( resource map, [ resource gamemode ] )
+
<syntaxhighlight lang="lua">bool changeGamemodeMap ( resource newMap, [ resource gamemodeToChangeTo ] )</syntaxhighlight>
bool stopGamemode ( )
+
Changes the GM map to a new one, optionally specifying a gamemode to change to before loading it (will load with the current gamemode by default).
bool stopGamemodeMap ( )
+
<syntaxhighlight lang="lua">bool stopGamemode ( )</syntaxhighlight>
resource getRunningGamemode ( )
+
Stops the current gamemode and its map.
resource getRunningGamemodeMap ( )
+
<syntaxhighlight lang="lua">bool stopGamemodeMap ( )</syntaxhighlight>
table getMapsCompatibleWithGamemode ( resource gamemode )
+
Stop the current GM map.
</syntaxhighlight>
+
<syntaxhighlight lang="lua">resource getRunningGamemode ( )</syntaxhighlight>
 +
Returns the currently running gamemode's resource pointer.
 +
<syntaxhighlight lang="lua">resource getRunningGamemodeMap ( )</syntaxhighlight>
 +
Returns the currently running GM map's resource pointer.
 +
<syntaxhighlight lang="lua">table getMapsCompatibleWithGamemode ( [ resource theGamemode ] )</syntaxhighlight>
 +
Returns a table of compatible map resource pointers. If the gamemode is left blank, it returns all maps which aren't compatible with any gamemode.
 +
<syntaxhighlight lang="lua">table getGamemodes ( )</syntaxhighlight>
 +
Returns a table of all gamemode resource pointers.
 +
<syntaxhighlight lang="lua">table getMaps ( )</syntaxhighlight>
 +
Returns a table of all map resource pointers.
  
 
==Fired events==
 
==Fired events==
<syntaxhighlight lang="lua">
+
''(For all these events, "source" is the resource's root element.)''
onGamemodeStart ( resource gamemode )
+
<syntaxhighlight lang="lua">onGamemodeStart ( resource startedGamemode )</syntaxhighlight>
onGamemodeStop ( resource gamemode )
+
Fired before a gamemode starts.
onGamemodeMapStart ( resource map )
+
<syntaxhighlight lang="lua">onGamemodeStop ( resource startedGamemode )</syntaxhighlight>
onGamemodeMapStop ( resource map )
+
Fired before a gamemode is stopped.
</syntaxhighlight>
+
<syntaxhighlight lang="lua">onGamemodeMapStart ( resource startedMap )</syntaxhighlight>
 +
Fired before a GM map starts.
 +
<syntaxhighlight lang="lua">onGamemodeMapStop ( resource startedMap )</syntaxhighlight>
 +
Fired before a GM map is stopped.

Revision as of 12:11, 9 July 2007

The map manager lists maps and manages gamemode and gamemode map loading.

Usage

You have to tag the gamemode resource with the correct type in its info tag:

<info description="A gamemode" type="gamemode" />

Map resources also need the type="map" tag, plus a gamemodes tag listing the gamemode resources they're compatible with in a comma-separated list without spaces.

<info description="A gamemode map" type="map" gamemodes="ctv,koth" />

There can be only one gamemode and one gamemode map loaded at once.

Commands

changemap newmap [newgamemode] (changes the gamemode map to a new one, optionally changing the gamemode as well)

gamemode newgamemode [newmap] (changes to a new gamemode, optionally starting a map with it)

maps [gamemode] (lists all maps in the server, optionally all maps compatible with a gamemode)

gamemodes (lists all gamemodes)

Exported functions

bool changeGamemode ( resource newGamemode, [ resource mapToLoadWith ] )

Changes the gamemode to a new one, optionally specifying an initial map for it (will load without a map by default).

bool changeGamemodeMap ( resource newMap, [ resource gamemodeToChangeTo ] )

Changes the GM map to a new one, optionally specifying a gamemode to change to before loading it (will load with the current gamemode by default).

bool stopGamemode ( )

Stops the current gamemode and its map.

bool stopGamemodeMap ( )

Stop the current GM map.

resource getRunningGamemode ( )

Returns the currently running gamemode's resource pointer.

resource getRunningGamemodeMap ( )

Returns the currently running GM map's resource pointer.

table getMapsCompatibleWithGamemode ( [ resource theGamemode ] )

Returns a table of compatible map resource pointers. If the gamemode is left blank, it returns all maps which aren't compatible with any gamemode.

table getGamemodes ( )

Returns a table of all gamemode resource pointers.

table getMaps ( )

Returns a table of all map resource pointers.

Fired events

(For all these events, "source" is the resource's root element.)

onGamemodeStart ( resource startedGamemode )

Fired before a gamemode starts.

onGamemodeStop ( resource startedGamemode )

Fired before a gamemode is stopped.

onGamemodeMapStart ( resource startedMap )

Fired before a GM map starts.

onGamemodeMapStop ( resource startedMap )

Fired before a GM map is stopped.