blob: b6fe345350649eed263714bdb9e8eda427675c59 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
-- Config.lua
-- Implements the cConfig class that holds the general plugin configuration
cConfig = {
m_Wand = cItem(E_ITEM_STICK, 1, 1); -- The item to be used as the selection wand
m_AllowInteractNoArea = true; -- If there's no area, is a player allowed to build / dig?
};
--- Initializes the cConfig object, loads the configuration from an INI file
function InitializeConfig()
local ini = cIniFile("ProtectionAreas.ini");
if (not(ini:ReadFile())) then
LOGINFO(PluginPrefix .. "Cannot read ProtectionAreas.ini, all plugin configuration is set to defaults");
end
local WandItem = cItem();
if (
StringToItem(ini:GetValueSet("ProtectionAreas", "WandItem", ItemToString(cConfig.m_Wand)), WandItem) and
IsValidItem(WandItem.m_ItemType)
) then
cConfig.m_Wand = WandItem;
end
cConfig.m_AllowInteractNoArea = ini:GetValueSetB("ProtectionAreas", "AllowInteractNoArea", cConfig.m_AllowInteractNoArea);
ini:WriteFile();
end
--- Returns true if a_Item is the wand tool item
function cConfig:IsWand(a_Item)
return (
(a_Item.m_ItemType == self.m_Wand.m_ItemType) and
(a_Item.m_ItemDamage == self.m_Wand.m_ItemDamage)
);
end
--- Returns the wand tool item as a cItem object
function cConfig:GetWandItem()
return self.m_Wand;
end
|