FrameworkZ 10.8.3
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
27
28function FACTION:GetColor()
29 return self.color
30end
31
32--! \brief Create a new faction object.
33--! \param name \string Faction name.
34--! \return \table The new faction object.
35function FrameworkZ.Factions:New(name)
36 local object = {
37 id = name,
38 name = name,
39 description = "No description available.",
40 color = {r = 1, g = 1, b = 1, a = 1},
41 limit = 0,
42 members = {}
43 }
44
45 setmetatable(object, FACTION)
47 return object
48end
49
50--! \brief Initialize a faction.
51--! \param data \table The faction object's data.
52--! \param name \string The faction's name (i.e. ID).
53--! \return \string The faction ID.
54function FrameworkZ.Factions:Initialize(id, object)
55 FrameworkZ.Factions.List[id] = object
56
57 return id
58end
59
60--! \brief Get a faction by their ID.
61--! \param factionID \string The faction's ID
62--! \return \table The faction's object.
63function FrameworkZ.Factions:GetFactionByID(factionID)
64 local faction = FrameworkZ.Factions.List[factionID] or nil
65
66 return faction
67end
68
69--! \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.
70--! \param factionID \string The faction's ID.
71--! \return \string The faction's name.
72function FrameworkZ.Factions:GetFactionNameByID(factionID)
73 local faction = FrameworkZ.Factions.List[factionID] or nil
74
75 return faction and faction.name
76end
void FrameworkZ()
void local name()
Faction class for FrameworkZ.
Definition Factions.lua:46
void GetColor()
string Initialize()
Initialize a faction.
FACTION __index
Definition Factions.lua:48
Factions module for FrameworkZ. Defines and interacts with FACTION object.
Definition Factions.lua:13
FrameworkZ Factions List
Definition Factions.lua:17
FrameworkZ Factions __index
Definition Factions.lua:15