forked from Tria-Studio/Tria-OS-Docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFE2-TRIA-Converter.lua
156 lines (137 loc) · 3.46 KB
/
FE2-TRIA-Converter.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
---------------------------------------------
---- Flood Escape 2 to TRIA.os converter ----
---------------------------------------------
function valueToAttribute(value)
if value:IsA("ValueBase") then
local par = value.Parent
par:SetAttribute(value.Name, value.Value)
value:Destroy()
end
end
return function(oldMap, options)
local map = oldMap:Clone()
map.Name = map.Name.."_Converted"
map.Parent = oldMap.Parent
-- Convert settings --
local newSettingsFolder = Instance.new("Folder")
local main = Instance.new("Configuration")
main.Name = "Main"
main.Parent = newSettingsFolder
local lighting = Instance.new("Configuration")
lighting.Name = "Lighting"
lighting.Parent = newSettingsFolder
local button = script.Button:Clone()
button.Parent = newSettingsFolder
local liquidTypes = Instance.new("Folder")
liquidTypes.Name = "Liquids"
liquidTypes.Parent = newSettingsFolder
for _,v in next, map.Settings:GetChildren() do
if v:IsA("ValueBase") then
v.Parent = main
end
end
for _,v in next, map.Settings.Lighting:GetChildren() do
v.Parent = lighting
valueToAttribute(v)
end
newSettingsFolder.Name = "Settings"
map.Settings:Destroy()
newSettingsFolder.Parent = map
main.BGM.Name = "Music"
main.MapName.Name = "Name"
main.MapImage.Name = "Image"
main:SetAttribute("MusicVolume", 0.5)
for _,v in next, main:GetChildren() do
valueToAttribute(v)
end
local es = map:FindFirstChild("EventString")
if es then
local s = Instance.new("Script", map)
s.Name = "EventScript"
s.Source = es.Value
es:Destroy()
end
-- Convert map objects --
map.EventScript.Name = "MapScript"
local les = map:FindFirstChild("LocalEventScript")
if les then
les.Name = "LocalMapScript"
end
local renames = {
_Appear = "_Show",
_Fade = "_Destroy"
}
for i,v in next, map:GetDescendants() do
for o,p in next, renames do
if v.Name:find(o) then
v.Name = p .. v.Name:sub(#o+1,#v.Name)
end
end
if v.Name:find("_Water") then
v.Name = v.name:gsub("_Water","_Liquid")
v:SetAttribute("Type", v:FindFirstChild("State") and v.State.Value or "water")
elseif v.Name == "_Wall" then
v.Name = "_WallJump"
elseif v.Name == "AirTank" then
if v:FindFirstChild("Hitbox") then
v.PrimaryPart = v.Hitbox
local newAirTank = script.AirTank:Clone()
newAirTank:SetPrimaryPartCFrame(v:GetPrimaryPartCFrame())
newAirTank.Parent = v.Parent
v:Destroy()
end
elseif v.Name:find("_Button") then
--v:SetAttribute("Group", (v:FindFirstChild("Group") and true or false))
end
end
-- Convert map script --
local s = map.MapScript.Source
s = s:gsub(
"workspace%.Multiplayer%.GetMapVals%:Invoke%(%)",
"game.GetMapLib:Invoke()()"
)
s = s:gsub(
"Lib%.Button:connect%(function%(p, bNo%) if Lib%.btnFuncs%[bNo%] then Lib%.btnFuncs%[bNo%]%(bNo, p%) end end%)",
""
)
s = s:gsub(
"--Has: Map, Script, Button, btnFuncs",
""
)
s = s:gsub(
"Lib%.Button",
"Lib.ButtonPressed"
)
s = s:gsub(
"_Water",
"_Liquid"
)
local a
repeat
a = true
s = s:gsub(
"Lib%.Script%.moveWater(%b())",
function(args)
a = false
if args:find(",.*true") then
args = args:gsub(",%s*true", "")
return "Lib:MovePartLocal"..args..""
else
return "Lib:MovePart"..args..""
end
end
)
until a
repeat
a = true
s = s:gsub(
"Lib%.Script%.setWaterState%((.*),(.*)%)",
function(...)
a = false
local args = {...}
return "Lib:SetLiquidType("..args[1]..","..args[2]..")"
end
)
until a
map.MapScript.Source = s
end