-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmod.lua
186 lines (158 loc) · 7.85 KB
/
mod.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
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
local func = require "ust/func"
function data()
return {
info = {
severityAdd = "NONE",
minorVersion = 4,
severityRemove = "CRITICAL",
name = _("MOD_NAME"),
description = _("MOD_DESC"),
authors = {
{
name = "Enzojz",
role = "CREATOR",
text = "Idea, Scripting, Modeling",
steamProfile = "enzojz",
tfnetId = 27218,
}
},
tags = {"Train Station", "Station"},
},
postRunFn = function(settings, params)
local tracks = api.res.trackTypeRep.getAll()
local trackModuleList = {}
local trackIconList = {}
local trackNames = {}
for i, trackName in pairs(tracks) do
local track = api.res.trackTypeRep.get(api.res.trackTypeRep.find(trackName))
local trackName = trackName:match("(.+).lua")
local mod = api.type.ModuleDesc.new()
mod.fileName = ("station/rail/ust/tracks/%s.module"):format(trackName)
mod.availability.yearFrom = track.yearFrom
mod.availability.yearTo = track.yearTo
mod.cost.price = 0
mod.description.name = track.name
mod.description.description = track.desc
mod.description.icon = track.icon
mod.type = "ust_track"
mod.order.value = i + 1
mod.metadata = {
typeName = "ust_track",
isTrack = true,
width = track.trackDistance,
height = track.railBase + track.railHeight,
typeId = 1,
scriptName = "construction/station/rail/ust/struct/track",
preProcessAdd = "preProcessAdd",
preProcessRemove = "preProcessRemove",
slotSetup = "slotSetup",
preClassify = "preClassify",
postClassify = "postClassify",
gridization = "gridization"
}
mod.category.categories = {"ust_cat_track"}
mod.updateScript.fileName = "construction/station/rail/ust/struct/track.updateFn"
mod.updateScript.params = {
trackType = trackName .. ".lua",
trackWidth = track.trackDistance
}
mod.getModelsScript.fileName = "construction/station/rail/ust/struct/track.getModelsFn"
mod.getModelsScript.params = {}
api.res.moduleRep.add(mod.fileName, mod, true)
table.insert(trackModuleList, mod.fileName)
table.insert(trackIconList, track.icon)
table.insert(trackNames, track.name)
end
local bridges = api.res.bridgeTypeRep.getAll()
for index, bridgeName in pairs(bridges) do
local bridge = api.res.bridgeTypeRep.get(index)
local mod = api.type.ModuleDesc.new()
mod.fileName = ("station/rail/ust/bridges/%s.module"):format(bridgeName:match("(.+).lua"))
mod.availability.yearFrom = bridge.yearFrom
mod.availability.yearTo = bridge.yearTo
mod.cost.price = 0
mod.description.name = bridge.name
mod.description.description = ""
mod.description.icon = bridge.icon
mod.type = "ust_bridge"
mod.order.value = index
mod.metadata = {
typeName = "ust_bridge",
typeId = 25,
scriptName = "construction/station/rail/ust/struct/bridge",
preProcessAdd = "preProcessAdd",
slotSetup = "slotSetup",
addSlot = "addSlot",
classify = "classify"
}
mod.category.categories = {"ust_cat_bridge"}
mod.updateScript.fileName = "construction/station/rail/ust/struct/bridge.updateFn"
mod.updateScript.params = {
index = index,
name = bridgeName
}
mod.getModelsScript.fileName = "construction/station/rail/ust/struct/bridge.getModelsFn"
mod.getModelsScript.params = {}
api.res.moduleRep.add(mod.fileName, mod, true)
end
local tunnels = api.res.tunnelTypeRep.getAll()
for index, tunnelName in pairs(tunnels) do
local tunnel = api.res.tunnelTypeRep.get(index)
local mod = api.type.ModuleDesc.new()
mod.fileName = ("station/rail/ust/tunnels/%s.module"):format(tunnelName:match("(.+).lua"))
mod.availability.yearFrom = tunnel.yearFrom
mod.availability.yearTo = tunnel.yearTo
mod.cost.price = 0
mod.description.name = tunnel.name
mod.description.description = ""
mod.description.icon = tunnel.icon
mod.type = "ust_tunnel"
mod.order.value = index
mod.metadata = {
typeName = "ust_tunnel",
typeId = 26,
scriptName = "construction/station/rail/ust/struct/tunnel",
preProcessAdd = "preProcessAdd",
slotSetup = "slotSetup",
addSlot = "addSlot",
classify = "classify"
}
mod.category.categories = {"ust_cat_tunnel"}
mod.updateScript.fileName = "construction/station/rail/ust/struct/tunnel.updateFn"
mod.updateScript.params = {
index = index,
name = tunnelName
}
mod.getModelsScript.fileName = "construction/station/rail/ust/struct/tunnel.getModelsFn"
mod.getModelsScript.params = {}
api.res.moduleRep.add(mod.fileName, mod, true)
end
for index, name in pairs(api.res.moduleRep.getAll()) do
if name:match("station/rail/ust/data") then
api.res.moduleRep.setVisible(index, false)
end
end
local con = api.res.constructionRep.get(api.res.constructionRep.find("station/rail/ust/ust.con"))
con.createTemplateScript.fileName = "construction/station/rail/ust/ust.createTemplateFn"
con.createTemplateScript.params = {trackModuleList = trackModuleList}
local data = api.type.DynamicConstructionTemplate.new()
for n = 1, #con.constructionTemplates do
for i = 1, #con.constructionTemplates[n].data.params do
local p = con.constructionTemplates[n].data.params[i]
local param = api.type.ScriptParam.new()
param.key = p.key
param.name = p.name
if (p.key == "trackType") then
param.values = trackNames
else
param.values = p.values
end
param.defaultIndex = p.defaultIndex or 0
param.uiType = p.uiType
data.params[i] = param
end
con.constructionTemplates[n].data = data
end
end
}
end