-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathboilerplate.lua
88 lines (76 loc) · 2.29 KB
/
boilerplate.lua
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
-- boilerplate begin
function getRequiredLuaVersion()
return 1
end
function isMapPreviewEnabled()
return false
end
local requiredFeature = 4
function checkVersion()
local featureLevel = rttr:GetFeatureLevel()
if featureLevel < requiredFeature then
rttr:MsgBox("LUA-Version Error", "Your Return to the Roots version is outdated. The required LUA-Feature level is " .. requiredFeature .. ", your version is " .. featureLevel .. ". The script can possibly crash or run unexpectedly!\n\nPlease update the game!", true)
end
end
local isLoading = false
function showMissionText(e)
if isLoading then return end
local msg = _('msg' .. tostring(e))
if msg ~= ('msg' .. tostring(e)) then
local msgh = _('msgh' .. tostring(e))
if msgh ~= ('msgh'.. tostring(e)) then
rttr:MissionStatement(0, _('Diary'), msg .. '\n\n\n\n' .. msgh)
rttr:SetMissionGoal(0, msgh)
else
rttr:MissionStatement(0, _('Diary'), msg)
end
else
rttr:Log("Error: no Translation found: " .. msg)
end
end
function enableBuilding(b)
rttr:GetPlayer(0):EnableBuilding(b, not isLoading)
end
function getAllowedChanges()
return
{
["addonsAll"] = false,
["ownNation"] = false,
["ownColor"] = false,
["ownTeam"] = false,
["aiNation"] = false,
["aiColor"] = false,
["aiTeam"] = false,
}
end
local activeEvents = {}
local eventHistory = {}
local timesTriggered = {}
function onSave(saveGame)
saveGame:PushInt(#eventHistory)
for i = 1, #eventHistory do
saveGame:PushInt(eventHistory[i])
end
return true
end
function onLoad(saveGame)
local n = saveGame:PopInt()
for i = 1, n do
eventHistory[i] = saveGame:PopInt()
end
return true
end
function onSettingsReady()
checkVersion()
rttr:Log("-----------------------\n lua loaded... \n-----------------------\n")
rttr:ResetAddons()
rttr:SetAddon(ADDON_CATAPULTS_ATTACK_ALLIES, true)
rttr:SetAddon(ADDON_FRONTIER_DISTANCE_REACHABLE, true)
rttr:SetGameSettings({
["fow"] = EXP_CLASSIC,
["teamView"] = false,
["lockedTeams"] = false
})
rttr:GetPlayer(0):SetNation(NAT_ROMANS)
rttr:GetPlayer(0):SetColor(0)
-- boilerplate end