-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtraintest.lua
More file actions
158 lines (155 loc) · 5.99 KB
/
Copy pathtraintest.lua
File metadata and controls
158 lines (155 loc) · 5.99 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
-- local startPoint = trigger.misc.getZone("start-train").point
-- local endPoint = trigger.misc.getZone("end-train").point
-- local endRadius = trigger.misc.getZone("end-train").radius
-- local groupTable = {
-- ["visible"] = false,
-- ["lateActivation"] = false,
-- ["tasks"] = {},
-- ["uncontrollable"] = false,
-- ["task"] = "Ground Nothing",
-- ["taskSelected"] = true,
-- ["route"] =
-- {
-- ["spans"] =
-- {
-- }, -- end of ["spans"]
-- ["points"] =
-- {
-- [1] =
-- {
-- ["alt"] = 444,
-- ["type"] = "On Railroads",
-- ["ETA"] = 0,
-- ["alt_type"] = "BARO",
-- ["formation_template"] = "",
-- ["y"] = startPoint.z,
-- ["x"] = startPoint.x,
-- ["ETA_locked"] = false,
-- ["speed"] = 100,
-- ["action"] = "On Railroads",
-- ["task"] =
-- {
-- ["id"] = "ComboTask",
-- ["params"] =
-- {
-- ["tasks"] = {},
-- }, -- end of ["params"]
-- }, -- end of ["task"]
-- ["speed_locked"] = true,
-- }, -- end of [1]
-- [2] =
-- {
-- ["alt"] = 290,
-- ["type"] = "On Railroads",
-- ["ETA"] = 2552.2416366473,
-- ["alt_type"] = "BARO",
-- ["formation_template"] = "",
-- ["y"] = endPoint.z,
-- ["x"] = endPoint.x,
-- ["ETA_locked"] = false,
-- ["speed"] = 100,
-- ["action"] = "On Railroads",
-- ["task"] =
-- {
-- ["id"] = "ComboTask",
-- ["params"] =
-- {
-- ["tasks"] = {},
-- }, -- end of ["params"]
-- }, -- end of ["task"]
-- ["speed_locked"] = true,
-- }, -- end of [2]
-- }, -- end of ["points"]
-- ["routeRelativeTOT"] = false,
-- }, -- end of ["route"]
-- ["groupId"] = 1,
-- ["hidden"] = false,
-- ["units"] =
-- {
-- [1] =
-- {
-- ["skill"] = "Average",
-- ["coldAtStart"] = false,
-- ["type"] = "Train",
-- ["unitId"] = 1,
-- ["y"] = startPoint.z,
-- ["x"] = startPoint.x,
-- ["name"] = "Ground-1-1",
-- ["heading"] = 5.2535949800736,
-- ["playerCanDrive"] = false,
-- ["wagons"] =
-- {
-- [6] = "Coach a tank blue",
-- [2] = "Coach a tank blue",
-- [3] = "Coach a tank blue",
-- [1] = "Locomotive",
-- [4] = "Coach a tank blue",
-- [5] = "Coach a tank blue",
-- [7] = "Coach a tank blue",
-- [8] = "Coach a tank blue",
-- [9] = "Coach a tank blue",
-- }, -- end of ["wagons"]
-- }, -- end of [1]
-- }, -- end of ["units"]
-- ["y"] = startPoint.z,
-- ["x"] = startPoint.x,
-- ["name"] = "Train",
-- ["start_time"] = 0,
-- } -- end of [1]
-- local countryId = country.id.CJTF_BLUE
-- local groupType = 4
-- local groupName = coalition.addGroup(countryId, groupType, groupTable):getName()
-- function trackTrain(groupName)
-- local trainPoint = Group.getByName(groupName):getUnit(1):getPoint()
-- local vec = {x = trainPoint.x - endPoint.x, y = 0, z = trainPoint.z - endPoint.z}
-- local trainDistance = (vec.x^2 + vec.y^2 + vec.z^2)^0.5
-- trigger.action.outText("Train is " .. trainDistance .."m away from destination", 10, false)
-- trigger.action.outText("Train health: " .. Group.getByName(groupName):getUnit(1):getLife(), 10, false)
-- trigger.action.outText("Train group size: " .. Group.getByName(groupName):getSize(), 10, false)
-- trigger.action.outText("Train: " .. dump(Group.getByName(groupName):getUnit(1):getDesc()), 10, false)
-- if trainDistance > endRadius then
-- timer.scheduleFunction(trackTrain, groupName, timer:getTime() + 15)
-- else
-- trigger.action.outText("ARRIVED", 60, false)
-- --trigger.action.explosion(trainPoint, 1000)
-- timer.scheduleFunction(cleanjunk, nil, timer:getTime() + 15)
-- end
-- end
-- function cleanjunk()
-- trigger.action.outText("removing junk", 10, false)
-- local removeJunkPoint = { x = endPoint.x, y = land.getHeight({x = endPoint.x, y = endPoint.z}), z = endPoint.z}
-- local junkSphere = {
-- id = world.VolumeType.SPHERE,
-- params = {
-- point = removeJunkPoint,
-- radius = 1200
-- }
-- }
-- world.removeJunk(junkSphere)
-- end
-- function dump(o)
-- if o == nil then
-- return "~nil~"
-- elseif type(o) == 'table' then
-- local s = '{ '
-- for k,v in pairs(o) do
-- if type(k) ~= 'number' then k = '"'..k..'"' end
-- s = s .. '['..k..'] = ' .. dump(v) .. ','
-- end
-- return s .. '} '
-- else
-- return tostring(o)
-- end
-- end
-- trackTrain(groupName)
local startPoint = trigger.misc.getZone("start-train").point
local endPoint = trigger.misc.getZone("end-train").point
local locoType = "Locomotive"
locoType = "ES44AH"
local groupWaypoints = SpawnFuncs.createWPListFromPoints({[1] = startPoint, [2] = endPoint}, 100)
local cpyGroupTable = SpawnFuncs.createGroupTableFromListofUnitTypes(1, 4, {[1] = "Train"}, groupWaypoints)
cpyGroupTable["units"][1]["wagons"][1] = locoType
cpyGroupTable["units"][1]["wagons"][2] = locoType
cpyGroupTable["units"][1]["wagons"][#cpyGroupTable["units"][1]["wagons"]-1] = locoType
cpyGroupTable["units"][1]["wagons"][#cpyGroupTable["units"][1]["wagons"]] = locoType
coalition.addGroup(80+(2-1), 4, cpyGroupTable)