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 


Finding mx values

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 586

PostPosted: Mon Mar 14, 2022 12:15 pm    Post subject: Finding mx values Reply with quote

The function doesn't appear to be correct
Code:

function EqualExp(sender)
local AL = getAddressList()
           OneExp = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "1st Exp G")))
           print(OneExp.." one")
           MaxExp = OneExp
           TwoExp = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "2nd Exp G")))
           print(TwoExp,, " two")
                  if TwoExp >> MaxExp then
                  print("two greater")
                     MaxExp = TwoExp
                  end
           ThreeExp = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "3rd Exp G")))
           print(ThreeExp.." three")
                  if ThreeExp >> MaxExp then
                  print("three greater")
                     MaxExp = ThreeExp
                  end
           FourExp = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "4th Exp G")))
           print(FourExp.." four")
                  if FourExp >> MaxExp then
                     print("four greater")
                     MaxExp = FourExp
                  print(MaxExp.." set to four")
                  end
           FiveExp = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "5th Exp G")))
           print(FiveExp  " five")
                  if FiveExp >> MaxExp then
                  print("five greater")
                  print(MaxExp.." maxexp")
                     MaxExp = FiveExp
                  end
           SixExp = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "6th Exp G")))
           print(SixExp.." six")
                  if SixExp >> MaxExp then
                  print("six greater")
                     MaxExp = SixExp
                  end
                  print(MaxExp.." Max Exp")
end

The output of the prints

2840549 one
2840549 two
two greater --this should not be executed as two=max
2840549 three
three greater --this should not be executed as three=max
2967999 four
four greater
2967999 set to four
2840549 five
2967999 maxexp
five greater --this should not be executed as five<max
2967999 maxexp --still ok
2840549 six
six greater --this should not be executed as six<max
2840549 Max Exp --max set to lower value set in if

What is incorrect in the code?
Back to top
View user's profile Send private message Yahoo Messenger
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1069
Location: 0x90

PostPosted: Mon Mar 14, 2022 1:06 pm    Post subject: Reply with quote

">>" means shr (bit shift right) it should be ">"
Back to top
View user's profile Send private message
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 586

PostPosted: Mon Mar 14, 2022 1:37 pm    Post subject: Reply with quote

Thanks, I have always been "errored" when the operator was not two characters.
Back to top
View user's profile Send private message Yahoo Messenger
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1522

PostPosted: Mon Mar 14, 2022 2:04 pm    Post subject: Reply with quote

Code:
TwoExp=2800 --or 1900
MaxExp=1900 --or 2800
max=math.max(TwoExp,MaxExp) -- max value
-- or
--min=math.min(TwoExp,MaxExp) -- min value

print("max: " .. max)

if math.max(TwoExp,MaxExp)==MaxExp then
print(1)
MaxExp=MaxExp
else
print(2)
MaxExp=TwoExp
end

print("MaxExp: " .. MaxExp)


print :
max: 2800
2
MaxExp: 2800

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 586

PostPosted: Mon Mar 14, 2022 2:31 pm    Post subject: Reply with quote

Actually, I initially wanted to make a table of the six values and then let math.max pick the correct one, however I didn't know how to make the table to use in math.max.
Back to top
View user's profile Send private message Yahoo Messenger
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1522

PostPosted: Mon Mar 14, 2022 3:45 pm    Post subject: Reply with quote

bknight2602 wrote:
Actually, I initially wanted to make a table of the six values and then let math.max pick the correct one, however I didn't know how to make the table to use in math.max.


Code:
function EqualExp()
 mxTbl={}
 tblIndex=0
local AL = getAddressList()
           OneExp = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "1st Exp G")))
            tblIndex=tonumber(tblIndex) + 1
            mxTbl[tblIndex]=OneExp -- or tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "1st Exp G")))

           --TwoExp = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "2nd Exp G")))
            tblIndex=tonumber(tblIndex) + 1
            mxTbl[tblIndex]=tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "2nd Exp G")))

           ThreeExp = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "3rd Exp G")))
            tblIndex=tonumber(tblIndex) + 1
            mxTbl[tblIndex]=ThreeExp

           FourExp = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "4th Exp G")))
            tblIndex=tonumber(tblIndex) + 1
            mxTbl[tblIndex]=FourExp

           FiveExp = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "5th Exp G")))
            tblIndex=tonumber(tblIndex) + 1
            mxTbl[tblIndex]=FiveExp

           SixExp = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "6th Exp G")))
            tblIndex=tonumber(tblIndex) + 1
            mxTbl[tblIndex]=SixExp
  table.sort(mxTbl)
  return mxTbl[tblIndex]
end

--use
function EqualExp()
 mxTbl={}
 tblIndex=0
           OneExp = 2840549
            tblIndex=tonumber(tblIndex) + 1
            mxTbl[tblIndex]=OneExp
           TwoExp = 1840549
            tblIndex=tonumber(tblIndex) + 1
            mxTbl[tblIndex]=TwoExp
           ThreeExp = 2849549
            tblIndex=tonumber(tblIndex) + 1
            mxTbl[tblIndex]=ThreeExp
           FourExp = 3967999
            tblIndex=tonumber(tblIndex) + 1
            mxTbl[tblIndex]=FourExp
           FiveExp = 6967999
            tblIndex=tonumber(tblIndex) + 1
            mxTbl[tblIndex]=FiveExp
           SixExp = 5967999
            tblIndex=tonumber(tblIndex) + 1
            mxTbl[tblIndex]=SixExp
  table.sort(mxTbl)
  return mxTbl[tblIndex] -- :6967999 or table min value = mxTbl[1] : 1840549
end

MaxExp = EqualExp()
print(MaxExp)

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 586

PostPosted: Mon Mar 14, 2022 4:14 pm    Post subject: Reply with quote

AylinCE wrote:
bknight2602 wrote:
Actually, I initially wanted to make a table of the six values and then let math.max pick the correct one, however I didn't know how to make the table to use in math.max.


Code:
function EqualExp()
 mxTbl={}
 tblIndex=0
local AL = getAddressList()
           OneExp = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "1st Exp G")))
            tblIndex=tonumber(tblIndex) + 1
            mxTbl[tblIndex]=OneExp -- or tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "1st Exp G")))

           --TwoExp = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "2nd Exp G")))
            tblIndex=tonumber(tblIndex) + 1
            mxTbl[tblIndex]=tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "2nd Exp G")))

           ThreeExp = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "3rd Exp G")))
            tblIndex=tonumber(tblIndex) + 1
            mxTbl[tblIndex]=ThreeExp

           FourExp = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "4th Exp G")))
            tblIndex=tonumber(tblIndex) + 1
            mxTbl[tblIndex]=FourExp

           FiveExp = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "5th Exp G")))
            tblIndex=tonumber(tblIndex) + 1
            mxTbl[tblIndex]=FiveExp

           SixExp = tonumber(memoryrecord_getValue(addresslist_getMemoryRecordByDescription(AL, "6th Exp G")))
            tblIndex=tonumber(tblIndex) + 1
            mxTbl[tblIndex]=SixExp
  table.sort(mxTbl)
  return mxTbl[tblIndex]
end

--use
function EqualExp()
 mxTbl={}
 tblIndex=0
           OneExp = 2840549
            tblIndex=tonumber(tblIndex) + 1
            mxTbl[tblIndex]=OneExp
           TwoExp = 1840549
            tblIndex=tonumber(tblIndex) + 1
            mxTbl[tblIndex]=TwoExp
           ThreeExp = 2849549
            tblIndex=tonumber(tblIndex) + 1
            mxTbl[tblIndex]=ThreeExp
           FourExp = 3967999
            tblIndex=tonumber(tblIndex) + 1
            mxTbl[tblIndex]=FourExp
           FiveExp = 6967999
            tblIndex=tonumber(tblIndex) + 1
            mxTbl[tblIndex]=FiveExp
           SixExp = 5967999
            tblIndex=tonumber(tblIndex) + 1
            mxTbl[tblIndex]=SixExp
  table.sort(mxTbl)
  return mxTbl[tblIndex] -- :6967999 or table min value = mxTbl[1] : 1840549
end

MaxExp = EqualExp()
print(MaxExp)


Hmm not much in the saving of steps, but thanks.
Speaking of tables did you see my questions on how to start the function(s) to move addresses into header?
Back to top
View user's profile Send private message Yahoo Messenger
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1522

PostPosted: Mon Mar 14, 2022 4:45 pm    Post subject: Reply with quote

bknight2602 wrote:

Speaking of tables did you see my questions on how to start the function(s) to move addresses into header?


Unfortunately, there are many unordered topics and I cannot follow them.

When an issue is resolved, you should leave a "[SOLVED]" tag in the title. I guess question within question may not be useful for archive.

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website 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