FrameworkZ 4.4.2
Provides a framework for Project Zomboid with various systems.
Loading...
Searching...
No Matches
Factions.lua
Go to the documentation of this file.
1--! \page global_variables Global Variables
2--! \section Factions Factions
3--! FrameworkZ.Factions\n
4--! See Factions for the module on factions.\n\n
5--! FrameworkZ.Factions.List\n
6--! A list of all instanced factions in the game and their online members.
7
8FrameworkZ = FrameworkZ or {}
9
10--! \brief Factions module for FrameworkZ. Defines and interacts with FACTION object.
11--! \class FrameworkZ.Factions
12FrameworkZ.Factions = {}
13FrameworkZ.Factions.__index = FrameworkZ.Factions
14FrameworkZ.Factions.List = {}
15FrameworkZ.Factions = FrameworkZ.Foundation:NewModule(FrameworkZ.Factions, "Factions")
16
17--! \brief Faction class for FrameworkZ.
18--! \class FACTION
19local FACTION = {}
20FACTION.__index = FACTION
21
22--! \brief Initialize a faction.
23--! \return \string faction ID
24function FACTION:Initialize()
25 return FrameworkZ.Factions:Initialize(self.name, self)
26end
28--! \brief Create a new faction object.
29--! \param name \string Faction name.
30--! \return \table The new faction object.
31function FrameworkZ.Factions:New(name)
32 local object = {
33 id = name,
34 name = name,
35 description = "No description available.",
36 limit = 0,
37 members = {}
38 }
39
40 setmetatable(object, FACTION)
41
42 return object
43end
44
45--! \brief Initialize a faction.
46--! \param data \table The faction object's data.
47--! \param name \string The faction's name (i.e. ID).
48--! \return \string The faction ID.
49function FrameworkZ.Factions:Initialize(id, object)
50 FrameworkZ.Factions.List[id] = object
51
52 return id
53end
54
55--! \brief Get a faction by their ID.
56--! \param factionID \string The faction's ID
57--! \return \table The faction's object.
58function FrameworkZ.Factions:GetFactionByID(factionID)
59 local faction = FrameworkZ.Factions.List[factionID] or nil
60
61 return faction
62end
63
64--! \brief Get a faction's name by their ID. Useful for getting a faction's actual name if the initialized faction ID differs from the name field.
65--! \param factionID \string The faction's ID.
66--! \return \string The faction's name.
67function FrameworkZ.Factions:GetFactionNameByID(factionID)
68 local faction = FrameworkZ.Factions.List[factionID] or nil
69
70 return faction and faction.name
71end
void Factions()
void name()
void FrameworkZ()
Faction class for FrameworkZ.
Definition Factions.lua:13
string Initialize()
Initialize a faction.
FACTION __index
Definition Factions.lua:15
Factions module for FrameworkZ. Defines and interacts with FACTION object.
Definition Factions.lua:25
FrameworkZ Factions List
Definition Factions.lua:29
string GetFactionNameByID(factionID)
Get a faction's name by their ID. Useful for getting a faction's actual name if the initialized facti...
table GetFactionByID(factionID)
Get a faction by their ID.
string Initialize(id, object)
Initialize a faction.
table New(name)
Create a new faction object.
FrameworkZ Factions __index
Definition Factions.lua:27
FrameworkZ global table.