 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
cd& Newbie cheater
Reputation: 0
Joined: 08 Apr 2023 Posts: 20
|
Posted: Wed Apr 19, 2023 5:57 am Post subject: in function, how to handle arguments |
|
|
function f1(offset,vector)
vector={0, 0, 0}
vector[1]=readFloat(readPointer("game.exe+01016E44")+offset+0x30)
end
vector1={0, 0, 0}
offset1=0x630
f1(offset1,vctor1)
→it doesn't work as I intend
experiment:
function f2(offset,vector)
vector={0, 0, 0}
vector[1]=readFloat(readPointer("game.exe+01016E44")+offset+0x30)
print(vector[1])
print(vector1[1])
end
vector1={0, 0, 0}
offset1=0x630
f2(offset1,vector1)
→
0.086963586509228 (this float is as I intend)
0 (this float is not as I intend)
function f3(offset,vector)
vector[1]=readFloat(readPointer("game.exe+01016E44")+offset+0x30)
end
vector1={0, 0, 0}
offset1=0x630
f1(offset1,vctor1)
→it works as I intend
in function, why must not I do "vector={0, 0, 0}"
|
|
| Back to top |
|
 |
Frouk Grandmaster Cheater
Reputation: 5
Joined: 22 Jun 2021 Posts: 510
|
Posted: Fri Apr 21, 2023 9:05 am Post subject: Re: in function, how to handle arguments |
|
|
| cd& wrote: | function f1(offset,vector)
vector={0, 0, 0}
vector[1]=readFloat(readPointer("game.exe+01016E44")+offset+0x30)
end
vector1={0, 0, 0}
offset1=0x630
f1(offset1,vctor1)
→it doesn't work as I intend
experiment:
function f2(offset,vector)
vector={0, 0, 0}
vector[1]=readFloat(readPointer("game.exe+01016E44")+offset+0x30)
print(vector[1])
print(vector1[1])
end
vector1={0, 0, 0}
offset1=0x630
f2(offset1,vector1)
→
0.086963586509228 (this float is as I intend)
0 (this float is not as I intend)
function f3(offset,vector)
vector[1]=readFloat(readPointer("game.exe+01016E44")+offset+0x30)
end
vector1={0, 0, 0}
offset1=0x630
f1(offset1,vctor1)
→it works as I intend
in function, why must not I do "vector={0, 0, 0}" |
because it overrides the variable with new value, to check if argument was given nil, you need to do | Code: | | vector = vector or {0, 0, 0} |
of course, you doing it on raw vector(no libraries or files to include to have a full vector structure)
|
|
| Back to top |
|
 |
cd& Newbie cheater
Reputation: 0
Joined: 08 Apr 2023 Posts: 20
|
Posted: Sat Apr 22, 2023 9:18 am Post subject: |
|
|
| ok,thank you.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|