View previous topic :: View next topic |
Author |
Message |
bknight2602 Grandmaster Cheater
Reputation: 0
Joined: 08 Oct 2012 Posts: 586
|
Posted: Mon Mar 14, 2022 12:15 pm Post subject: Finding mx values |
|
|
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 |
|
 |
LeFiXER Grandmaster Cheater Supreme
Reputation: 20
Joined: 02 Sep 2011 Posts: 1069 Location: 0x90
|
Posted: Mon Mar 14, 2022 1:06 pm Post subject: |
|
|
">>" means shr (bit shift right) it should be ">"
|
|
Back to top |
|
 |
bknight2602 Grandmaster Cheater
Reputation: 0
Joined: 08 Oct 2012 Posts: 586
|
Posted: Mon Mar 14, 2022 1:37 pm Post subject: |
|
|
Thanks, I have always been "errored" when the operator was not two characters.
|
|
Back to top |
|
 |
AylinCE Grandmaster Cheater Supreme
Reputation: 37
Joined: 16 Feb 2017 Posts: 1522
|
Posted: Mon Mar 14, 2022 2:04 pm Post subject: |
|
|
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
_________________
|
|
Back to top |
|
 |
bknight2602 Grandmaster Cheater
Reputation: 0
Joined: 08 Oct 2012 Posts: 586
|
Posted: Mon Mar 14, 2022 2:31 pm Post subject: |
|
|
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 |
|
 |
AylinCE Grandmaster Cheater Supreme
Reputation: 37
Joined: 16 Feb 2017 Posts: 1522
|
Posted: Mon Mar 14, 2022 3:45 pm Post subject: |
|
|
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) |
_________________
|
|
Back to top |
|
 |
bknight2602 Grandmaster Cheater
Reputation: 0
Joined: 08 Oct 2012 Posts: 586
|
Posted: Mon Mar 14, 2022 4:14 pm Post subject: |
|
|
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 |
|
 |
AylinCE Grandmaster Cheater Supreme
Reputation: 37
Joined: 16 Feb 2017 Posts: 1522
|
Posted: Mon Mar 14, 2022 4:45 pm Post subject: |
|
|
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.
_________________
|
|
Back to top |
|
 |
|