Lua:speedhack setSpeed

From Cheat Engine
Revision as of 00:45, 27 June 2026 by Leunsel (talk | contribs) (Major overhaul of the post.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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

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

Returns

This function does not return a value.

Examples

Set normal speed

1 speedhack_setSpeed(1.0)

Speed up the target

1 speedhack_setSpeed(2.0)

Slow down the target

1 speedhack_setSpeed(0.5)

Set speed from a variable

1 local speed = 3.0
2 
3 speedhack_setSpeed(speed)

Toggle between normal and fast speed

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

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

Ask for a speed value

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

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

Main Pages

Core Lua documentation entry points

Lua
Script Engine