Skip to content

Commit 8d86ce3

Browse files
committed
Add Slow-Mo Buy Menu global script
1 parent 40864dc commit 8d86ce3

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
function BuyMenuSlowMoScript:StartScript()
2+
self.SlowMo = false;
3+
self.Change = false;
4+
self.originalTimeScale = TimerMan.TimeScale
5+
self.originalDeltaTimeSecs = TimerMan.DeltaTimeSecs + 0
6+
end
7+
8+
function BuyMenuSlowMoScript:UpdateScript()
9+
local activity = ActivityMan:GetActivity();
10+
if activity then
11+
activity = ToGameActivity(activity);
12+
13+
-- Check if the buy menu is open
14+
if activity:IsBuyGUIVisible(-1) then
15+
if not self.SlowMo then
16+
self.SlowMo = true;
17+
self.Change = true;
18+
end
19+
else
20+
if self.SlowMo then
21+
self.SlowMo = false;
22+
self.Change = true;
23+
end
24+
end
25+
end
26+
27+
if self.Change then
28+
if self.SlowMo then
29+
-- Slow down time
30+
TimerMan.DeltaTimeSecs = self.originalDeltaTimeSecs * 0.05
31+
TimerMan.TimeScale = 0.1
32+
else
33+
-- Return time to normal
34+
TimerMan.DeltaTimeSecs = self.originalDeltaTimeSecs
35+
TimerMan.TimeScale = self.originalTimeScale
36+
end
37+
self.Change = false;
38+
end
39+
end

Data/Base.rte/Scripts/GlobalScripts.ini

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,11 @@ AddGlobalScript = GlobalScript
180180
Description = The currently active scene will autosave every three minutes. Can be loaded with the Ctrl+F9 key combo.
181181
ScriptPath = Base.rte/Scripts/Global/Autosave.lua
182182
LuaClassName = AutosaveScript
183-
LateUpdate = 1
183+
LateUpdate = 1
184+
185+
186+
AddGlobalScript = GlobalScript
187+
PresetName = Buy Menu Slow-Motion
188+
Description = Turns the game to slow-motion when you enter the Buy Menu.
189+
ScriptPath = Base.rte/Scripts/Global/BuyMenuSlowMo.lua
190+
LuaClassName = BuyMenuSlowMoScript

Source/Lua/LuaBindingsActivities.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ LuaBindingRegisterFunctionDefinitionForType(ActivityLuaBindings, GameActivity) {
132132
.def("GetLandingZone", &GameActivity::GetLandingZone)
133133
.def("SetActorSelectCursor", &GameActivity::SetActorSelectCursor)
134134
.def("GetBuyGUI", &GameActivity::GetBuyGUI)
135+
.def("IsBuyGUIVisible", &GameActivity::IsBuyGUIVisible)
135136
.def("GetEditorGUI", &GameActivity::GetEditorGUI)
136137
.def("LockControlledActor", &GameActivity::LockControlledActor)
137138
.def("OtherTeam", &GameActivity::OtherTeam)

0 commit comments

Comments
 (0)