Capture the Flag is a Luanti (formerly Minetest) game. The following API doc covers the various mods which make up the game. If you have any difficulty in understanding this, please read Programming in Lua.
If you see a deficiency in the API, feel free to attempt to add the functionality in the engine and API, and to document it here. All mods are contained in the /mods/ folder. If you are unsure of the implementation of the function, please search for the function in the repository. If you see that something is undocumented you're more than welcome to make a PR documenting it, try to fit it with the style of the rest of the document though.
- api
- ctf_gui
- ctf_settings
- hud_events
- physics
- mhud
- rawf
- mtg
- redef
- ctf_changes
- pvp
- dropondie
- grenades
- other
- afkkick
- chat_bg
- crafting
- darkness nerf
- hpbar
- hpbar_hud
- lib_chatcmdbuilder
- playertag
- poison_water
- random_messages
- real suffocation
- select item
- skybox
- sprint
- throwable snow
- wield3d
- ctf
- ctf_api
- ctf_chat
- ctf_combat
- ctf_core
- ctf_cosmetics
- ctf_landmine
- ctf_map
- ctf_modebase
- ctf_modes
- ctf_player
- ctf_rankings
- ctf_report
- ctf_teams
This folder contains a collection of mods with the main goal of providing an API
A tool for easily creating basic CTF-themed GUIs. This mod was reworked at one point, but a few mods still use the old code, so it was left in. You can read the old api docs here
This mod adds a 'Settings' tab to the player's inventory. Mods can use the ctf_settings API to add buttons/fields to the Settings tab that can be used to customize the mod's functionality per-player.
namestring: Name of setting to registerdeftable: Setting properties, see below
ctf_settings.register("my_setting", {
type = "bool" || "list",
label = "Setting name/label", -- not used for list
description = "Text in tooltip",
list = {i1, i2, i3, i4}, -- used for list, remember to formspec escape contents
default = "default value/index",
on_change = function(player, new_value)
<...>
end
})playerPlayerObj: The player whos setting you want to setsettingsstring: The name of the setting you want to setvalue(bool | list index) as string: The value you want to set, dependent on what the setting's type is
playerPlayerObj: The player whos setting you want to getsettingstring: The name of the setting you want to get
- returns (bool | list index) as string: Returns the player's current setting value, the default given at setting registration, or if both are unset, an empty string:
""
This mod allows for quick hud events to allow for quick popup messages.
playerPlayerObj: The player who you want to show the event to.defstring|table: Event properties, see below.
hud_events.new(player,"Simple HUD Event")hud_events.new(player, {
text= "HUD Event",
channel=1 -- 1 by default
color= "primary" -- 0x00D1FF by default.
quick=true -- false by default
})List of all HUD Colors
primary = 0x0D6EFD,
secondary = 0x6C757D,
success = 0x20bf5c,
info = 0x0DCAF0,
warning = 0xFFC107,
danger = 0xDC3545,
light = 0xF8F9FA,
dark = 0x212529,
By default, all hud events are shown for 3 seconds, while quick ones are shown for 2 sec, and there is a gap of 0.6 seconds between each event.
A simple wrapper mod for overriding player physics. Only allows overriding of speed, speed_crouch, jump, gravity.
namestring: Player name.layerstring: Layer. e.g "sprint:sprint"modifierstable: A table of modifiers. Eg.{speed=2,speed_crouch=2,jump=1,gravity=2}By default overrides are as follows: speed=1.1, jump = 1.1, speed_crouch = 1, gravity = 1. Any table entries missing, will take the default values.
namestring: Player name.layerstring: The name of the layer you want to remove
A wrapper for more easily managing Minetest HUDs. See the API reference here
A ranged weapon framework for Minetest. See the API reference here
This folder contains the Minetest Game, along with redefinitions and overrides for the CTF Game. This folder doesnt expose any new APIs on its own. Please follow the Minetest Game API Reference for the same here.
This folder contains parts of game mechanics involving pvp and combat.
This mod drops all items on the ground, once a player dies. It is automatically invoked on a player's death or if a player leaves the game.
playerPlayerObj: The player you want to drop all items of.
Adds an API that allows for easily making grenades.
grenades.register_grenade("name", { -- Name of the grenade (Like 'smoke' or 'flashbang')
description = "", -- A short description of the grenade.
image = "", -- The name of the grenade's texture
collide_with_objects = false, -- (Default: false) Controls whether the grenade collides with objects. Grenade will never collide with thrower regardless of this setting
throw_cooldown = 0, -- How often player can throw grenades, in seconds
on_explode = function(def, obj, pos, name)
-- This function is called when the grenade 'explodes'
-- <def> grenade object definition
-- <obj> the grenade object
-- <pos> the place the grenade 'exploded' at
-- <name> the name of the player that threw the grenade
end,
on_collide = function(def, obj, name, moveresult)
-- This function is called when the grenade collides with a surface
-- <def> grenade object definition
-- <obj> the grenade object
-- <name> the name of the player that threw the grenade
-- <moveresult> table with collision info
-- return true to cause grenade explosion
-- return false to stop the grenade from moving
end,
clock = 3, -- Optional, controls how long until grenade detonates. Default is 3
particle = { -- Adds particles in the grenade's trail
image = "grenades_smoke.png", -- The particle's image
life = 1, -- How long (seconds) it takes for the particle to disappear
size = 4, -- Size of the particle
glow = 0, -- Brightens the texture in darkness
interval = 5, -- How long it takes before a particle can be added
}
})This folder contains a collection of some misc mods, adding smaller functionalities and objects to game.
This mod kicks players after they are AFK for an amount of time. By default, players are kicked after five minutes, although this can be configured. No APIs are exposed by this mod.
This mod changes the default chat background. No APIs are exposed by this mod.
This mod adds semi-realistic crafting with unlockable recipes to Minetest, and removes the craft grid. It aims to make crafting less of a learning curve by making it as easy as clicking a button, and also by hiding recipes that the player has not learned about yet. Please refer to API Docs here
This mods fixes darkness, by providing a minimum glow of 3 to players, and 8 to all entities of __builtin:item. No APIs are exposed by this mod.
This mod allows players to email each other. No APIs are exposed by this mod.
This mod shows an HP bar over the players head.
playerPlayerObj: Player to be shown over.texturetexture: Texture to be shown beside the HP Bar.
This mod allows to easily create complex chat commands with no pattern matching. The API documentation is here
This mod hides the existing tags, and adds entity based tags that are only as visible as the player.
playerPlayerObj: Player the nametag will be associated with.typeinteger: By default set it asplayertag.TYPE_ENTITYcolorColor: The color of the text.extrastable: (Optional) field.- returns a table consisting of lua entities,
{entity:, nametag_entity:, symbol_entity:}
playerPlayerObj: Player the nametag will be associated with.- returns a table consisting of lua entities,
{entity:, nametag_entity:, symbol_entity:}
- returns the entire players table.
This mod adds posionous water to the game. Poisonous water is a liquid that causes damage to entities standing in it. No APIs are exposed by this mod.
This mod sends random messages from a list of messages, providing insights and tips. No APIs are exposed by this mod.
This mod adds suffocation. Suffocation is basically the same as drowning, but it is for being stuck inside solid blocks. No APIs are exposed by this mod.
This mod provides a simple dialog for players to select an item from. The API Reference is here
Provides a basic API for modifying a player sky box in a coherent fashion.
- Reverts the player skybox setting to the default.
playerPlayerObj: Player the skybox will be shown to.
- Sets the skybox to the
numberin the list of current skyboxes. playerPlayerObj: Player the skybox will be shown to.numbernumber: Choose the skybox from the list of skyboxes.
- Reverts the player skybox to the last
skybox.set()value. - Other skybox mods can properly restore the player's custom skybox.
playerPlayerObj: Player the skybox will be reverted for.
- Add a new skybox with skyboxdef to the list of available skyboxes.
skyboxdefSkyBoxDef : New Skybox definition.
skyboxdef = {
[1] -- Base name of texture. The 6 textures you need to
-- provide need to start with this value, and then
-- have "Up", "Down", "Front", "Back", "Left" and
-- "Right", Followed by ".jpg" as the file name.
[2] -- Sky color (colorstring)
[3] -- Day/Night ratio value (float - [0.0, 1.0])
Example SkyboxDef
{"DarkStormy", "#1f2226", 0.5, { density = 0.5, color = "#aaaaaae0", ambient = "#000000",
height = 64, thickness = 32, speed = {x = 6, y = -6},}},- Get a list of availiable skyboxes
This mod, allows the player to sprint by either double tapping w or pressing e. No APIs are exposed by this mod.
This mod, allows snow balls to be thrown at other players as projectiles.
throwerPlayerObj: Player who threw the snow.playerPlayerObj: Player on whom it hit. Override this function, if you want to change what happens on snow hit.
This mod makes hand wielded items visible to other players. No APIs are exposed by this mod.
The main engine of Capture The Flag game. The following folder consists of the collection of mods, which powers the entire game.
This mod registers the functions to be executed when certain key events happen. The following functions exist, all of which take a func Function as its parameter.
ctf_api.registered_on_mode_start(func)ctf_api.registered_on_new_match(func)ctf_api.registered_on_match_start(func)ctf_api.registered_on_match_end(func)ctf_api.registered_on_respawnplayer(func)- Requires a return type of PlayerObjctf_api.registered_on_flag_take(func)- Requires a return type of a tuple havingtakerPlayerObj andflag_teamstringctf_api.registered_on_flag_capture(func)- Requires a return type of a tuple havingcapturerPlayerObj andflagteamslist(string) (list of the teams of the flags taken)
This mod overrides the build in chat commands, and introduces a few new chat commands. No APIs are exposed by this mod.
This modpack consists of multiple mods.
playerPlayerObj: Player who was killed.hitterPlayerObj: Player killed theplayerweapon_imagestring: Path to weapon_image.time: number: Amount of time(in sec) to show for.
playerPlayerObj: Player who was healed..healerPlayerObj: Player who healed theplayertime: number: Amount of time(in sec) to show for.
playerPlayerObj: Player.- returns a tuple of
last_hitterPlayerObj, andweapon_imagestring
playerPlayerObj: Player.last_hitterPlayerObj: Player who hit theplayerlast.- returns a table/list of players list(PlayerObj)
playerPlayerObj: Player.- returns a table/list of healers list(PlayerObj)
playerPlayerObj: Player who was killed.hitterPlayerObj: Player killed theplayer- returns boolean
playerPlayerObj: Playertimeinteger: Time. ???
playerPlayerObj: Player- returns boolean
playerPlayerObj: Player
funcFunction: function to execute on healing.load_firstboolean: true if function has to be loaded first, before all other functions.
namestring: Item name of the bandage.defItemDef: Item definition. (Needed:description,inventory_image,inventory_overlay,wield_image)
playerPlayerObj: Player- returns
boolean
killerPlayerObj: Player who killed.victimPlayerObj: Player killed bykillerweapon_imagestring: Path to image of weapon used to kill.commentstring: comment. (such as "Combat Log")
namestring: Item name of the sword.defItemDef: Item definition. (Needed:description,inventory_image,inventory_overlay,wield_image,full_punch_interval,damage_groups)
namestring: Item name of the sword.defItemDef: Item definition. (Needed:description,inventory_image,inventory_overlay,wield_image,full_punch_interval,damage_groups,tool_capabilities,damage_groups)- ??? Difference between the two?
playerPlayerObj: Playernamestring: Player name- returns boolean
- can be overriden for custom behavior.
namestring: Item name of the gun.defItemDef: Item definition. (Needed:description,texture,rounds,type,inventory_image,inventory_overlay,wield_image,full_punch_interval,damage_groups,rightclick_func)
namestring: Player nameitem_namestring: Item namefov_multinteger: FOV Multiplier.
namestring: Player name
- returns a table of
players(table) and functionsset,get.
posPosition: position.radiusinteger: Radius to check from the position.teamlessboolean: If true then returns the players in your team, and iffalsegives an empty table.
???
inputany: Converts any input into proper readable string format.
???
posposition: Position to checkpos1position: One corner to check inpos2position: Other corner- returns boolean
namestring: Original command.aliasstring: Alias name for commanddefFuncDef: Command Definition.
pathstring: Path to file- returns boolean
numberany: data to be converted to number.
areastring: Category where error occured.msgstring: Error message
areastring: Category where log originated.msgstring: Log message
areastring: Category where action occured.msgstring: Action message
areastring: Category where warning originated.msgstring: Warning message
...multiple_params: List of files to be included/ executed along with theinit.lua. Runsdofileon the same. For example,
ctf_core.include_files(
"helpers.lua",
"privileges.lua",
"cooldowns.lua"
)playerPlayerObj: Playercolorstring: Color of the skin. (Default: white)
playerPlayerObj: Player
playerPlayerObj: Playerclothingstring: Type of clothing
playerPlayerObj: Playerextra_clothing???
playerPlayerObj: Player
No APIs exposed in this mod.
pnamestring: Player nameteamnamestring: Team nameposposition: Position of flag
playerPlayerObj: Player to show the editor.
playerPlayerObj: Player to show the editor.scroll_pos???
subdirstring: Folder to check if skybox exists.
idxinteger: Index of the mapdirnamestring: Path to map folder.
mapmetaMapMeta: Map metadata to be saved on computer.
mapMapMeta: Map to be announced
mapmetaMapMeta: Map to be placed.callbackFunction: Function to be executed after map is placed.
mapmetaMapMeta: Map to be removed barrier of.callbackFunction: Function to be executed after map barrier is removed.
???
- returns
stringrepresenting time elapsed after map start_time.
dirnamestring: directory namepath_to_mapstring: By default "/".<path_to_map>/<dirname>
path_to_mapstring: By default "/".<path_to_map>/<dirname>
matchstring: Map commandfuncFunction: function to be executed.
namestring: Name of map.pos1Position: Position 1pos2Position: Position 2callbackFunction: Callback functionprogress???
namestring: Player nameamount???donefunc: Function to execute after function executes.
funcFunction function to be executed on report. The functionfuncneeds to have arguments ofname,message.
msgstring Display message to all staff.
playerstring|PlayerObj: Player Name|Player
playerstring|PlayerObj: Player Name|Playernew_teamstring: New team colorforceboolean: Force allocate into new team.
playerstring|PlayerObj: Player Name|Player- returns
nil|stringrepresenting player's team.
playerstring|PlayerObj: Player Name|Player- returns
nil|stringrepresenting player's team.
playerstring|PlayerObj: Player Name|Player- returns
nil|stringrepresenting player's team. - (just gets the team that player should be joined to, and doesnt set the team)
playerstring|PlayerObj: Player Name|Playerforceboolean: Force allocate into new team.- returns
nil|stringrepresenting player's team.
teamstable: Table of teams.- (should be called at match start)
teamnamestring: Team name- returns `boolean| pos1,pos2* false or positions representing the region of the team.
teamnamestring: Team name - All players in that team will recieve the message.messagemessage: Message
- returns a
tableof connected players but leaves players which arent in a team,
listname???stacktable(ItemDef): Item to be put into chest.playerPlayerObj: Player
funcFunction: function to be executed after allocating a team to player.
- returns
rankings()
funcFunction: function to be executed after ranking reset.
playerPlayerObj: Player
Depending on the database used, such as redis or modstorage/default defines common interface to handle with database.
pnamestring: Player name- returns
rank_strstring
pnamestring: Player namenewrankingsstring New rankings of playererase_unsetboolean ???- returns
rank_strstring
pnamestring: Player namescorenumber: Score
pnamestring: Player name
- returns ???
playerstring: Player namescorenumber: Score
playerstring: Player name- returns
placeinteger
countinteger: Count of no of players.- returns
list(string)of players whose rank is less thancount
playerstring: Player namekillerstring: Killer player name- returns
rewardsinteger (bonus score to be given to killer)
- reassigns the bounties.
- reassigns the timer, after which the bounties should be re-assigned.
- returns
tableof{bounty_kills = 1, score = x}
team_memberstable : Team members.- returns string with playername of random team member in table.
team_memberstable : Team members.- returns table of team members with highest kd's.
pnamestring: Player bounty put over.- returns
tableof{bounty_kills = 1, score = x}
build_timeinteger: Build time in seconds.
- called after build_time elapses.
namestring: Name of mode.- locks all crafts not supported by the mode.
playerPlayerObj: Player- returns boolean
playerPlayerObj: Playerrespawn_timerinteger: Amount of time to give immunity to player
playerPlayerObj: Player
- Remove immunity and return true if it's respawn immunity, return false otherwise.
playerPlayerObj: Player- returns boolean
???
mapMapDef: Map...???
???
modestring: Game mode (classic/nade_fight/classes)
playerPlayerObj: Player- returns the
teamstring which player has to join.
playerPlayerObj: Playerteamnamestring: Team whose flag is being taken.- returns boolean
playerPlayerObj: Playerteamnamestring: Team whose flag is being taken.
playerPlayerObj: Playerteamnameslist(string): Team whose flag is being taken.pteamstring: Player's team
playerPlayerObj: Playerteamnameslist(string): Team whose flag is being taken.
playerPlayerObj: Playerteamnamestring: Team where player is being joined to.
playerPlayerObj: Player
playerPlayerObj: Playerreasonstring: Reason for death.
playerPlayerObj: Player
pnamestring: Player name
playerPlayerObj: PlayerhitterPlayerObj: Hitterdamageinteger: Damage recieved_* ???tool_capabilities???
playerPlayerObj: Player(Healer)patientPlayerObj: Patient
pnamestring: Player namemsgstring: MessageposPosition: Position to put marker atno_notifyboolean: Iffalse, informs teammates about placed marker in chat.specific_playerstring: Marker placed for a specific player.
pnamestring: Player nameno_notifyboolean: Iffalse, informs teammates about removed marker in chat.
mapMapDef: Map chosen to be played.
- Starts the next match after map vote.
delayinteger: Delay of x seconds before match start.
- starts vote, to select how matches to play.
- ends vote, queue's a mode change.
playerPlayerObj: Playersoft???
playerPlayerObj: Player
playerPlayerObj: Player
playerPlayerObj: Player
playerPlayerObj: Player
playerPlayerObj: Player- this is used to update skyboxes, shadows and physics.
playerPlayerObj: Player- returns boolean
playerPlayerObj: Playeramountslist(table(string,integer)):no_hudboolean: If true then no hud will be shown.
playerPlayerObj: Player
playerPlayerObj: Player
- returns
rankings_playertable
- returns
teamstable
playerPlayerObj: Player- prepare player for respawn and start respawn delay.
invInventoryTable: Chest Inventorymap_treasurestable: Allowed map treasures.
strstring: String of form:name ; min_count ; max_count ; max_stacks ; rarity ;;
treasurestable: treasures to string form.
pinvInventoryTable: Player inventoryitemItem: item
???
pnamestring : Player name
playerPlayerObj : Player- handles team huds showing flag status.
playerPlayerObj : Playertimeinteger: Amount of time in seconds to track flag for.
playerPlayerObj : Player
playerPlayerObj : Player
puncherPlayerObj : PlayernodeposPosition: Position of node.nodeNodeDef: Node clicked on.
namestring: Mode NamedefmodeDef: Definition of mode. (Checkclassesmode def for example)
- returns boolean on wheter the mode has ended or not.
- to be run when a new mode starts. Runs all functions that are scheduled to be called on new mode.
- to be run when a new match is supposed to start. Runs all functions that are scheduled to be called on new match.
- to be run when a new match starts. Runs all functions that are scheduled to be called on new match.
- to be run when a match ends. Runs all functions that are scheduled to be called on match end.
playerPlayerObj: Player- Runs all functions that are scheduled to be called when a player respawns.
...???- Defines behavior when the flag is clicked with the right mouse key.
capturerPlayerObjflagteamslist(string) (list of the teams of the flags taken)
- ???
- Start the skipping match process.
- End the skip match process. Appropriately skip the match or abstain based on the votes.
- Increment holding flag count.
countint: Current flag count- If flag count falls to zero, and skip vote has chosen match to skip, then skip the map.
count int: Current flag count
- If flag has been captured, then remove the skip vote timer and end the match.
prevboolean: Whether previous rankings to be shown.- Returns a
tablewith the relevant match summary.
iint: int
namestring: Player namerankingstable: Recent rankings to show in the guirank_valuestable: Example:{_sort = "score", "captures" "kills"}formdeftable: table for customizing the formspec
namestring: Player namerankingstable: Recent rankings to show in the guirank_valuestable: Example:{_sort = "score", "captures" "kills"}formdeftable: table for customizing the formspec
And thats the end of the api docs. If anything is missing, or something needs to be updated, feel free to make a PR.