Home > database >  Brackets For Function Name
Brackets For Function Name

Time:10-06

Hey guys This is my first lua script, its a speedhack for a game (offline dont worry) and i keep getting an error with the function name, im not sure what to fix exactly.

function Speedhack1()
boost = 1.5
if (readbytes{'[_speed]') `- nil) then
writeFloat ('[_speed] DC', readFloat('[_speed] DC')*boost)
writeFloat ('[_speed] E0', readFloat('[_speed] E0')*boost)
writeFloat ('[_speed] E4', readFloat('[_speed] E4')*boost)
end
end
createHotkey(speedhack1, VK_UP)

function Speedhack2()
boost = 0.5
if (readbytes{'[_speed]') `- nil) then
writeFloat ('[_speed] DC', readFloat('[_speed] DC')*boost)
writeFloat ('[_speed] E0', readFloat('[_speed] E0')*boost)
writeFloat ('[_speed] E4', readFloat('[_speed] E4')*boost)
end
end
createHotkey(speedhack2, VK_DOWN)

This is the error it throws back at me when trying to execute:

Error in script Script 1 : [string "function Speedhack1() ..."]:3: '}' expected near ')'

when i try to replace ")" with "}" it just yells at me the reverse. very confused lol

CodePudding user response:

I think the issue is the curly braces in "readbytes{". Could you please try to replace that with "("?

CodePudding user response:

The code that causes the error here is in line 3

if (readbytes{'[_speed]') `- nil) then

In Lua the argument you pass for a function must have an opening and ending of ( and ) respectively. Therefore as you can note in line 3 the argument you have passed for readbytes has an opening of { which is the cause of the error. In order to resolve this replace { with (

  • Related