Lua:speedhack setSpeed

From Cheat Engine
Jump to navigation Jump to search

<> Lua API Reference

function speedhack_setSpeed(speed) : void

Enables the speedhack if needed and sets the specified speed.

A speed value of 1.0 represents normal speed. Values above 1.0 speed the target up, while values below 1.0 slow it down.

Function Parameters[edit]

Parameter Type Description
speed Float The speedhack multiplier to apply. 1.0 is normal speed.

Returns[edit]

This function does not return a value.

Examples[edit]

Set normal speed[edit]

1 speedhack_setSpeed(1.0)

Speed up the target[edit]

1 speedhack_setSpeed(2.0)

Slow down the target[edit]

1 speedhack_setSpeed(0.5)

Set speed from a variable[edit]

1 local speed = 3.0
2 
3 speedhack_setSpeed(speed)

Toggle between normal and fast speed[edit]

1 local fast = true
2 
3 if fast then
4   speedhack_setSpeed(5.0)
5 else
6   speedhack_setSpeed(1.0)
7 end

Use with speedhack_getSpeed[edit]

1 local currentSpeed = speedhack_getSpeed()
2 
3 speedhack_setSpeed(currentSpeed + 0.5)

Ask for a speed value[edit]

1 local result, value = inputQuery("Speedhack", "Enter speed multiplier:", "1.0")
2 
3 if result then
4   local speed = tonumber(value)
5 
6   if speed ~= nil then
7     speedhack_setSpeed(speed)
8   end
9 end

Reset speed when disabling a script[edit]

1 [DISABLE]
2 {$lua}
3 speedhack_setSpeed(1.0)
4 {$asm}

Main Pages

Core Lua documentation entry points

Lua
Script Engine