Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Custom address does not work in lua

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
mordax
Expert Cheater
Reputation: 1

Joined: 16 Apr 2010
Posts: 120

PostPosted: Sat Nov 12, 2016 12:33 pm    Post subject: Custom address does not work in lua Reply with quote

Hi, i'm sure it's been discussed somewhere here, but i honestly dont know what to even search for.

i try to describe my problem as best as i can.

NOTE that this is just sample script. the game i'm hacking is more complex and i'm doing more things, this is just to describe the problem, so please do not tell me that just make a hotkey for the address in cheat list, it would not work, because i need to increase more than 1 value at same time by multiplying the value with my own multiplier, simply adding a hotkey like (increase by 1.5) will NOT work, because values are always different and it will make things go crazy. Script first has to read the value and then multiply the xxx value with yyy and then write the output. So please focus on the issue at hand and do not suggest a "bypass" or "another method". i need this specific thing to work with my custom addresses.


so i have a script that finds player health based on AoB, then i use globalalloc like (_health,4) this and then i use _health as a pointer in cheat list and add necessary offset. For example base health is _health+154 and then health regeneration is like _health+188

It works great in cheat table, but I wanna make a hack so that health regeneration is way faster, i wrote a script in lua

Code:
function regenhack()
fastgen = 1.2
if (readBytes('_health') ~= nil) then
writeFloat ('_health+188', readFloat('_health+188')*fastgen)
end
createHotkey(regenhack, VK_F10)


but problem is that lua does not recognize my custom addresses. If i look in cheat list after game has been launched, then _health+188 takes me to like 845C332B address, if i use that address directly in my lua script, it works great! if i hit the button, health increases, but if i replace the address with my custom address (which works in cheat list), then it stops working.
Back to top
View user's profile Send private message
Filipe_Br
Master Cheater
Reputation: 3

Joined: 07 Jan 2016
Posts: 272
Location: My house

PostPosted: Sun Nov 13, 2016 9:37 am    Post subject: Re: Custom address does not work in lua Reply with quote

Maybe you should not put the names in ' '
_________________
...
Back to top
View user's profile Send private message
mordax
Expert Cheater
Reputation: 1

Joined: 16 Apr 2010
Posts: 120

PostPosted: Sun Nov 13, 2016 11:45 am    Post subject: Re: Custom address does not work in lua Reply with quote

Filipe_Br wrote:
Maybe you should not put the names in ' '


maybe you should not suggest things you have no idea about? You have no idea what you just said, do you?

if it would be issue with ' ' then why does it work with addresses that are registered / known to ce?


is there anyone who actually knows what the issue is? please no more replies from clowns who have no idea what they saying, thank you.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sun Nov 13, 2016 11:56 am    Post subject: Reply with quote

Maybe you shouldn't be hacking things you have no idea about?

One of two things is happening:
1. You're using an AOB to find an instruction and then populating _health with an address.
2. You're using an AOB to find the exact location of the health structure.

One of two things needs to happen:
1. Change your functions to use "[_health]+154"
2. Change your script to use label() and registersymbol() instead of globalalloc()

Either way, calm the fuck down!
Back to top
View user's profile Send private message
mordax
Expert Cheater
Reputation: 1

Joined: 16 Apr 2010
Posts: 120

PostPosted: Mon Nov 14, 2016 12:50 pm    Post subject: Reply with quote

Zanzer wrote:
Maybe you shouldn't be hacking things you have no idea about?

One of two things is happening:
1. You're using an AOB to find an instruction and then populating _health with an address.
2. You're using an AOB to find the exact location of the health structure.

One of two things needs to happen:
1. Change your functions to use "[_health]+154"
2. Change your script to use label() and registersymbol() instead of globalalloc()

Either way, calm the fuck down!


I'm calm lol. isn't this what the forum is for? ASKING HELP about things you don't understand? If i'd understand WHY this issue happens, i wouldn't ask.

Ok well i edited this post few times, but i got it working based on what you said, even tho it was very basic what you said, you pointed out few odd things that CE didn't like.
It still makes NO SENSE to me why it works, but it does, so thx for pointing it out.

now to those who also want to know the solution:

1. i replaced globalalloc with alloc(_health,4) and registersymbol(_health)
2. in lua, I added brackets [ ] on each side of the _health so it looks like [_health]+154

why it doesn't make sense, is cuz if i use normal address, it doesn't need [ ]. CE can be weird, but that's why i'm here asking for help :)
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Mon Nov 14, 2016 2:19 pm    Post subject: Reply with quote

Simpler example. This instruction will copy address of variable to eax register
Code:
mov eax,_health


This instruction will copy value of variable to eax register.
Code:
mov eax,[_health]


In your case, value kept in this variable is an address of health. So, it is a pointer.




_health - address of variable

[ _health ] - address of player health

readInteger(" [ _health ] ") - current player health value
or
readFloat(" [ _health ] ") - current player health value

_________________
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites