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 


[REQ] script to remove and add value

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
C9Angelo
How do I cheat?
Reputation: 0

Joined: 01 Apr 2020
Posts: 8

PostPosted: Wed Apr 01, 2020 1:18 pm    Post subject: [REQ] script to remove and add value Reply with quote

hello, alle! i need some assistance creating a script>

Let's say that Badge A and Badge B share a common address. There are 5 states that a badge can be in: Off, Bronze, Silver, Gold, and Diamond. Badge A follows the following: Off:0, Bronze:8, Silver:16, Gold:24, Diamond:32. Badge B follows the following: Off:0, Bronze: 1, Silver:2, Gold:3, Diamond:4. The issue that I am running into is that if I try to change Badge B to Bronze, it will change the value to 1, meaning that I cannot also have Badge A as Bronze. The solution to this would be to have the options add and subtract from the initial value (0) as opposed to changing it to a direct number.

if anyone knows how to do this, please share it with me! thank you!

i also would like to note that these are in the form of a drop down. so i would go to the drop down list in Badge A, click on Diamond (which would make it 32), and then i could go to the drop down list on Badge B, click on Diamond and it would make it 36 as opposed to 4.
Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 55

Joined: 01 Oct 2008
Posts: 942

PostPosted: Wed Apr 01, 2020 3:44 pm    Post subject: Reply with quote

It should be make of bitfields,
A is from bit 0-bit2, (In CE make memory record of Binary type, set bit start 0, length 3),
B is bit 3-bit 7 (make nother memory record of same address, bit start 3 length 5).

They together make use of all 8 bit of the byte in the same address.

A part is simpler, we use directly the value.

0:off
1:Bronze
2:Silver
3:Gold
4:Diamond

B part need a bit modification, for from bitfields B's view,
the value 8 (bit 3 set in whole byte view) is bit 0,
when it set, it is 1 in view inside the B part bitfield,
so 8->1, 16->2, 32->4,64->8 in setting up the dropdown list
ie.
0:off
1:Bronze
2:Silver
4:Gold
8:Diamond

OOPS:
I overlook that 8,16,24,32 as 8,16,32,64
It should be similar, modified as
0:off
1:Bronze
2:Silver
3:Gold
4:Diamond

And bitfields B should set as bit start 3, length 3 (fixed).

_________________
- Retarded.
Back to top
View user's profile Send private message
C9Angelo
How do I cheat?
Reputation: 0

Joined: 01 Apr 2020
Posts: 8

PostPosted: Wed Apr 01, 2020 5:20 pm    Post subject: Reply with quote

panraven wrote:
It should be make of bitfields,
A is from bit 0-bit2, (In CE make memory record of Binary type, set bit start 0, length 3),
B is bit 3-bit 7 (make nother memory record of same address, bit start 3 length 5).

They together make use of all 8 bit of the byte in the same address.

A part is simpler, we use directly the value.

0:off
1:Bronze
2:Silver
3:Gold
4:Diamond

B part need a bit modification, for from bitfields B's view,
the value 8 (bit 3 set in whole byte view) is bit 0,
when it set, it is 1 in view inside the B part bitfield,
so 8->1, 16->2, 32->4,64->8 in setting up the dropdown list
ie.
0:off
1:Bronze
2:Silver
4:Gold
8:Diamond

OOPS:
I overlook that 8,16,24,32 as 8,16,32,64
It should be similar, modified as
0:off
1:Bronze
2:Silver
3:Gold
4:Diamond

And bitfields B should set as bit start 3, length 3 (fixed).


do you think you could add me on discord for a further explanation? it'd be greatly appreciated. angelo#1111
Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 55

Joined: 01 Oct 2008
Posts: 942

PostPosted: Wed Apr 01, 2020 10:43 pm    Post subject: Reply with quote

Have you try to make the 2 BINARY type memory record?

The purpose is to make the two memory record value INDEPENDENCE to each other, so that value change in one value doesn't affect other.
It is the same as any other independence memory record values,
where you specify ADDRESS in BYTE UNITs;
except that CE provide the Binary type we can specify ADDRESS (or where the value is) in BIT UNITs.

(I somehow mistaken A & B, please swap them ~_~)

Code:

bit      0  1  2  3  4  5  6  7  8           
BADGE A          [       ]
BADGE B [       ]
set value in BINARY type   
-- bit field view
BADGE A           0  0  1 == 4
BADGE B  0  0  1 == 4           
-- whole Byte view
BADGE A           0  0  1 == 32
BADGE B  0  0  1 == 4         
--> byte value = 4+ 32 == 36


Hope you get the idea.

_________________
- Retarded.
Back to top
View user's profile Send private message
C9Angelo
How do I cheat?
Reputation: 0

Joined: 01 Apr 2020
Posts: 8

PostPosted: Thu Apr 02, 2020 6:50 am    Post subject: Reply with quote

panraven wrote:
Have you try to make the 2 BINARY type memory record?

The purpose is to make the two memory record value INDEPENDENCE to each other, so that value change in one value doesn't affect other.
It is the same as any other independence memory record values,
where you specify ADDRESS in BYTE UNITs;
except that CE provide the Binary type we can specify ADDRESS (or where the value is) in BIT UNITs.

(I somehow mistaken A & B, please swap them ~_~)

Code:

bit      0  1  2  3  4  5  6  7  8           
BADGE A          [       ]
BADGE B [       ]
set value in BINARY type   
-- bit field view
BADGE A           0  0  1 == 4
BADGE B  0  0  1 == 4           
-- whole Byte view
BADGE A           0  0  1 == 32
BADGE B  0  0  1 == 4         
--> byte value = 4+ 32 == 36


Hope you get the idea.


nono, the information you gave me works perfectly, however i don't understand how you got the bit start 3 length 3. the issue is that not every single instance of a badge works the same - sometimes badge A will be 0, 16, 32, 48, 64 and badge B will be 0, 4, 8, 12, 16. i want to know how you got the bit start and length so that i can account for these.
Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 55

Joined: 01 Oct 2008
Posts: 942

PostPosted: Thu Apr 02, 2020 9:08 am    Post subject: Reply with quote

Are you sure they represent the same data?
For instance, it may be there are actually A/B/C/D badge,
where A/B is for common unit with A/B occupy <0-2bit><3-5bit>a byte at offset 0,
and while C/D is for elite unit occupy <2-4bit><5-7bit> at offset 1,
but A/B badge doesn't occur with C/D badge,
so the difference?

To get the bit start and length,
you can check the smallest and larges non-zero BIT value (power of 2) within the bitfield.
For instance 0,16,32,48,64 -> smallest 16 -> bit 4 (bit 0 is 1st bit, bit 4 is 5th),
largest 64->bit 6, length = (6 - 4) + 1 = 3.
In case of largest value is something like 127 (not power of 2), then its largest non-zero BIT value is still 64.

OOPS:
I found the value 16 (bit 4) appeared both in your
"badge A will be 0, 16, 32, 48, 64 and badge B will be 0, 4, 8, 12, 16"
They are not independent, are they the right value?
(ie. I'm wrong again in above C/D badge example, it should be bit4-6/bit2-4 , overlapped bit4)

_________________
- Retarded.
Back to top
View user's profile Send private message
C9Angelo
How do I cheat?
Reputation: 0

Joined: 01 Apr 2020
Posts: 8

PostPosted: Thu Apr 02, 2020 10:21 am    Post subject: Reply with quote

panraven wrote:
Are you sure they represent the same data?
For instance, it may be there are actually A/B/C/D badge,
where A/B is for common unit with A/B occupy <0-2bit><3-5bit>a byte at offset 0,
and while C/D is for elite unit occupy <2-4bit><5-7bit> at offset 1,
but A/B badge doesn't occur with C/D badge,
so the difference?

To get the bit start and length,
you can check the smallest and larges non-zero BIT value (power of 2) within the bitfield.
For instance 0,16,32,48,64 -> smallest 16 -> bit 4 (bit 0 is 1st bit, bit 4 is 5th),
largest 64->bit 6, length = (6 - 4) + 1 = 3.
In case of largest value is something like 127 (not power of 2), then its largest non-zero BIT value is still 64.

OOPS:
I found the value 16 (bit 4) appeared both in your
"badge A will be 0, 16, 32, 48, 64 and badge B will be 0, 4, 8, 12, 16"
They are not independent, are they the right value?
(ie. I'm wrong again in above C/D badge example, it should be bit4-6/bit2-4 , overlapped bit4)


sorry for the confusion

so i was saying Badge A and Badge B as theoretical examples. they're all seperate badges (Badge A and Badge B are in the same address, however Badge C and Badge D are in the same address but are in a seperate address from Badge A and Badge B) Badge C would follow 0, 16, 32, 48, 64 and Badge D would follow 0, 2, 4, 6, 8.
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 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