Odd, I have the same code and mine does go back to 1x speed. Does it skip past 1?It seems you can't play the demo back at normal speeds if you alter it at any point. If I speed it up/slow it down, there's no way to go back to the base speed. PausePlayDemo command plays it back noticeably slower, and you can't correct it.
GlobalActionMap.bind(keyboard, "up", PlayDemo);
GlobalActionMap.bind(keyboard, "right", SpeedUpDemo);
GlobalActionMap.bind(keyboard, "left", SlowDownDemo);
GlobalActionMap.bind(keyboard, "down", PauseDemo);
Nope that won't do it. The reason is the fact that the up and down keys are trying to link to functions that aren't in the script. Replace the function entitled PausePlayDemo with this one. It will make it so when you press p (or whatever you have it set to) after slowing down or speeding up it will reset the speed back to 1.I guess it was just my eyes. Legions itself feels slower after watching the demos for some reason. Anyway to play demos at base speed with one press of the button, so there's a smoother transition? Was sorta hoping this worked, but alas it didn't. Currently if you're going fast/slow and press the PlayPause button it pauses first, then plays at base speed. I'd like to skip the Pause part.
Code:GlobalActionMap.bind(keyboard, "up", PlayDemo); GlobalActionMap.bind(keyboard, "right", SpeedUpDemo); GlobalActionMap.bind(keyboard, "left", SlowDownDemo); GlobalActionMap.bind(keyboard, "down", PauseDemo);
edit: Huh. Even removing the entire Pause function from democontrols.cs doesn't remove it.
function PausePlayDemo(%val)
{
if (!%val)
return;
if ($timeScale == 0)
demoQuit.onClick();
else if(demoSpeedText.getText() != 1)
{
demoSpeedText.setText(1);
demoSetSpeed.onClick();
return;
}
else
demoPause.onClick();
}
function SlowDownDemo(%val)
{
if(!%val)
return;
else if(demoSpeedText.getText() > 1)
{
demoSpeedText.setText(demoSpeedText.getText() - 1);
demoSetSpeed.onClick();
return;
}
if(demoSpeedText.getText() <= 1 && (demoSpeedText.getText() >= 0.05))
{
demoSpeedText.setText(demoSpeedText.getText() - 0.05);
demoSetSpeed.onClick();
return;
}
}
Imo, it would just be easier to make a new function. Paste this under the other mapings at the top of the file. Changing the key to what you want of course.What would these values have to be if I wanted to press just one button to get really slow playback (ala 300 fight-scenes or whatever)?
Code:function SlowDownDemo(%val) { if(!%val) return; else if(demoSpeedText.getText() > 1) { demoSpeedText.setText(demoSpeedText.getText() - 1); demoSetSpeed.onClick(); return; } if(demoSpeedText.getText() <= 1 && (demoSpeedText.getText() >= 0.05)) { demoSpeedText.setText(demoSpeedText.getText() - 0.05); demoSetSpeed.onClick(); return; } }
GlobalActionMap.bind(keyboard, "ctrl j", SuperSlowMotion);
function SuperSlowMotion(%val)
{
if(!%val)
return;
if(demoSetSpeed.getText() != 0.15)
{
demoSpeedText.setText(0.15);
demoSetSpeed.onClick();
return;
}
}
$demo_lastTimeScale = 1;
function LoadDemoKeyBindings()
{
if($demoMode)
{
GlobalActionMap.bind(keyboard, "up", PausePlayDemo);
GlobalActionMap.bind(keyboard, "right", SpeedUpDemo);
GlobalActionMap.bind(keyboard, "left", SlowDownDemo);
GlobalActionMap.bind(keyboard, "down", SuperSlowMo);
}
}
function GameHud::onWake(%this)
{
parent::onWake(%this);
LoadDemoKeyBindings();
}
function PausePlayDemo(%val)
{
if (!%val)
return;
if ($timeScale == 0)
demoQuit.onClick();
else if(demoSpeedText.getText() != 1)
{
demoSpeedText.setText(1);
demoSetSpeed.onClick();
return;
}
else
demoPause.onClick();
}
function SpeedUpDemo(%val)
{
if(!%val)
return;
else if(demoSpeedText.getText() >= 1)
{
demoSpeedText.setText(demoSpeedText.getText() + 1);
demoSetSpeed.onClick();
return;
}
if(demoSpeedText.getText() < 1 && (demoSpeedText.getText() >= 0))
{
demoSpeedText.setText(demoSpeedText.getText() + 0.05);
demoSetSpeed.onClick();
return;
}
}
function SlowDownDemo(%val)
{
if(!%val)
return;
else if(demoSpeedText.getText() > 1)
{
demoSpeedText.setText(demoSpeedText.getText() - 1);
demoSetSpeed.onClick();
return;
}
if(demoSpeedText.getText() <= 1 && (demoSpeedText.getText() >= 0.05))
{
demoSpeedText.setText(demoSpeedText.getText() - 0.05);
demoSetSpeed.onClick();
return;
}
}
function SuperSlowMotion(%val)
{
if(!%val)
return;
if(demoSetSpeed.getText() != 0.15)
{
demoSpeedText.setText(0.15);
demoSetSpeed.onClick();
return;
}
}
function demoPlay::onClick(%this)
{
$timeScale = $demo_lastTimeScale;
}
function demoPause::onClick(%this)
{
$demo_lastTimeScale = $timeScale;
$timeScale = 0;
}
function demoQuit::onClick(%this)
{
$timeScale = 1;
$demo_lastTimeScale = 1;
ServerConnection.stopDemo();
}
function demoSetSpeed::onClick(%this)
{
$timeScale = demoSpeedText.getText();
}
$demo_lastTimeScale = 1;
function LoadDemoKeyBindings()
{
if($demoMode)
{
GlobalActionMap.bind(keyboard, "up", PausePlayDemo);
GlobalActionMap.bind(keyboard, "right", SpeedUpDemo);
GlobalActionMap.bind(keyboard, "left", SlowDownDemo);
GlobalActionMap.bind(keyboard, "down", SuperSlowMo);
}
}
function GameHud::onWake(%this)
{
parent::onWake(%this);
LoadDemoKeyBindings();
}
function PausePlayDemo(%val)
{
if (!%val)
return;
if ($timeScale == 0)
demoPlay.onClick();
else if(demoSpeedText.getText() != 1)
{
demoSpeedText.setText(1);
demoSetSpeed.onClick();
return;
}
else
demoPause.onClick();
}
function SpeedUpDemo(%val)
{
if(!%val)
return;
else if(demoSpeedText.getText() >= 1)
{
demoSpeedText.setText(demoSpeedText.getText() + 1);
demoSetSpeed.onClick();
return;
}
if(demoSpeedText.getText() < 1 && (demoSpeedText.getText() >= 0))
{
demoSpeedText.setText(demoSpeedText.getText() + 0.05);
demoSetSpeed.onClick();
return;
}
}
function SlowDownDemo(%val)
{
if(!%val)
return;
else if(demoSpeedText.getText() > 1)
{
demoSpeedText.setText(demoSpeedText.getText() - 1);
demoSetSpeed.onClick();
return;
}
if(demoSpeedText.getText() <= 1 && (demoSpeedText.getText() >= 0.05))
{
demoSpeedText.setText(demoSpeedText.getText() - 0.05);
demoSetSpeed.onClick();
return;
}
}
function SuperSlowMotion(%val)
{
if(!%val)
return;
if(demoSetSpeed.getText() != 0.15)
{
demoSpeedText.setText(0.15);
demoSetSpeed.onClick();
return;
}
}
function demoPlay::onClick(%this)
{
$timeScale = $demo_lastTimeScale;
}
function demoPause::onClick(%this)
{
$demo_lastTimeScale = $timeScale;
$timeScale = 0;
}
function demoQuit::onClick(%this)
{
$timeScale = 1;
$demo_lastTimeScale = 1;
ServerConnection.stopDemo();
}
function demoSetSpeed::onClick(%this)
{
$timeScale = demoSpeedText.getText();
}