From 386d72965e4c13eac575c2dbed1b32e3724d835d Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Tue, 5 Apr 2016 02:50:32 +0100 Subject: [PATCH] Add documentation of data storage --- doc_data.md | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 doc_data.md diff --git a/doc_data.md b/doc_data.md new file mode 100644 index 0000000..eca89bd --- /dev/null +++ b/doc_data.md @@ -0,0 +1,80 @@ +# Data Formats + +This file documents the contents of ctf.txt +Values are added to the file using ctf.register_on_save and ctf.register_on_load. +Here are the default values: + +```lua +{ + players = ctf.players, + teams = ctf.teams, + diplo = ctf.diplo.diplo +} +``` + +## Players + +Commonly called tplayer (may be called data or player in old code). +Player name is commonly called name (but may be called other things in older code). + +```lua +ctf.players = { + username = (player_table) +} + +(player_table) = { + name = "username", + team = "teamname", + auth = false + -- true if the player is a team admin. Team admins can change team settings. + -- See ctf.can_mod() + -- Note that priv:ctf_admin can also change team settings +} +``` + +## Teams + +Commonly called team. +Team name is commonly called tname (but may be called team in old code). + +```lua +ctf.teams = { + teamname = (team_table) +} + +(team_table) = { + data = { + name = "teamname", + color = "teamcolor" -- see ctf_colors + }, + flags = { + (flag_table), (flag_table) + }, + players = { + username1 = (player_table), + username2 = (player_table) + }, + spawn = { x=0, y=0, z=0 } + -- fallback team spawn. Read by ctf.get_spawn() and overriding functions + -- Don't use directly, instead call ctf.get_spawn("teamname") +} + +(flag_table) = { + x=0, y=0, z=0, + flag_name = "Capital" -- human readable name +} +``` + +## Diplomacy + +```lua +ctf.diplo.diplo = { + (diplo_table), (diplo_table) +} + +(diplo_table) = { + one = "teamname1", + two = "teamname2", + state = "war" / "peace" / "alliance" +} +```