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 


Increase the value of an address by 1

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Gou
Newbie cheater
Reputation: 0

Joined: 02 Oct 2017
Posts: 19

PostPosted: Wed Nov 01, 2017 3:34 pm    Post subject: Increase the value of an address by 1 Reply with quote

Hello guys!
I need some help with a script.
So, when enabled i want it to change the value of an address from 0 to 1,
and then increase the value of an other address by 1. When disabled, i want it to do the opposite.
I am sure that information about this already exists, but i can't seem to find it.
What would be the code for this?
I do not want to set a value. I just want to increase it by 1.
If it matters, they are both bytes.
Thanks in advance!

That's where i am right now. The only thing missing is the increase value code that i asked for

Code:

[ENABLE]
20799800:
db 1

[DISABLE]
20799800:
db 0
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 120

Joined: 09 Jun 2013
Posts: 3260

PostPosted: Wed Nov 01, 2017 4:54 pm    Post subject: Reply with quote

Code:
[ENABLE]
20799800:
db 1
{$lua}
writeBytes(0x2079990,readBytes(0x2079990,1,false)+1)
{$asm}

[DISABLE]
20799800:
db 0
{$lua}
writeBytes(0x2079990,readBytes(0x2079990,1,false)-1)
{$asm}
Back to top
View user's profile Send private message
Gou
Newbie cheater
Reputation: 0

Joined: 02 Oct 2017
Posts: 19

PostPosted: Wed Nov 01, 2017 5:05 pm    Post subject: Reply with quote

Hello Zanzer!
Thanks for the reply.
Using your code i ended up with this script
Code:
[ENABLE]
20799800:
db 1
{$lua}
writeFloat(20642EE0,readFloat(20642EE0,1,false)+1)
{$asm}

[DISABLE]
20799800:
db 0
{$lua}
writeFloat(20642EE0,readFloat(20642EE0,1,false)-1)
{$asm}

But i get this message(attached pic) when i click execute, and i cannot activate the script.
Also, looking at the addresses again, i just now noticed that i made a mistake. Only the first one is a byte. The second one(that i want to increase) is a float. Thats why the code that pasted says writeFloat
I am sorry.
Thanks for the reply once again!



123.PNG
 Description:
 Filesize:  5.61 KB
 Viewed:  743 Time(s)

123.PNG




Last edited by Gou on Wed Nov 01, 2017 8:27 pm; edited 2 times in total
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 120

Joined: 09 Jun 2013
Posts: 3260

PostPosted: Wed Nov 01, 2017 7:14 pm    Post subject: Reply with quote

In Lua, hex values are preceded by "0x", as in my examples.
Code:
writeFloat(0x20642EE0,readFloat(0x20642EE0)+1
Back to top
View user's profile Send private message
Gou
Newbie cheater
Reputation: 0

Joined: 02 Oct 2017
Posts: 19

PostPosted: Wed Nov 01, 2017 7:29 pm    Post subject: Reply with quote

I did try it, since i originally copy pasted your code. But i got the same error.
I removed it at some point just to check. Of course it didn't work.
Just to be sure that i am not that stupid, i retyped 0x on all of the addresses, and i am still getting the same error.

Edit: Ok, so i removed the ",1,false" part from your original code, and it now works like a charm. What is it's purpose? Is it wrong to have it missing?
I know that my english skills are kinda terrible and you are probably wondering what i mean. Let me show you Razz

Code that did not work:
Code:
writeFloat(0x20642EE0,readFloat(0x20642EE0,1,false)+1)

Code that works:
Code:
writeFloat(0x20642EE0,readFloat(0x20642EE0)+1)


Thanks for your help anyway! I am grateful!
Back to top
View user's profile Send private message
ParkourPenguin
Grandmaster Cheater Supreme
Reputation: 54

Joined: 06 Jul 2014
Posts: 1814
Location: Arcadian Suburbia

PostPosted: Wed Nov 01, 2017 8:05 pm    Post subject: Reply with quote

The function readBytes has three parameters: an address, the number of bytes to read, and whether or not those bytes should be returned as a table.

readFloat has only one parameter: an address. The second and third parameters of readBytes don't make sense for readFloat because a float is always 4 bytes long and the function is only suppose to read one float.

Why did you say both values were bytes if one of them was a float?

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Gou
Newbie cheater
Reputation: 0

Joined: 02 Oct 2017
Posts: 19

PostPosted: Wed Nov 01, 2017 8:25 pm    Post subject: Reply with quote

Oh i see! It's a very similar command, and such difference wasn't listed in the cewiki. So assumed that it's the same syntax. But yeah, it makes sense that this isn't the case because its float.
I am sorry, but i am new Very Happy

Yes i did make a mistake. I didn't double check before posting, and i remembered that they were both bytes.
I am sorry once again Very Happy

Zanzer's original code should have worked(not with positive results because the byte/float thing), but it didn't. Just in case you are wondering why, it was because i did not open the process before saving the script on the cheat table.

So to summarize, 100% of my issues were caused by my ignorance.
I need to follow a LUA tutorial for sure. I recently started learning C++, VB, PHP and SQL at college and it's already pretty tough for a newcomer like me. I am afraid that starting to learn LUA on top of those is gonna melt my brain Very Happy

Thanks once again!
Back to top
View user's profile Send private message
Prehistoricman
Advanced Cheater
Reputation: 0

Joined: 02 Aug 2016
Posts: 76

PostPosted: Thu Nov 02, 2017 7:07 am    Post subject: Reply with quote

Don't trust the wiki. It's best to use the celua.txt documentation in the cheat engine folder.
_________________
Er, hi
Back to top
View user's profile Send private message
Gou
Newbie cheater
Reputation: 0

Joined: 02 Oct 2017
Posts: 19

PostPosted: Thu Nov 02, 2017 2:55 pm    Post subject: Reply with quote

Wow i had no idea!
There is so much stuff in here!
Thanks man!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine 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