View previous topic :: View next topic |
Author |
Message |
icsmoke+ Cheater Reputation: 0
Joined: 31 Aug 2020 Posts: 29
|
Posted: Tue Jan 25, 2022 2:46 am Post subject: [ask] how to write arithmetic properly [solved] |
|
|
hello there, just want to ask how to write arithmetic properly base from address?
here is my code
Code: |
al = getAddressList()
warposition = al.getMemoryRecordByDescription('warposition')
wararea={ 'warposition+1','warposition+2','warposition+3','warposition+4',
'warposition+5','warposition*1+2','warposition+5*5'}
function byNameandArea()
if tonumber(mr('NPC1').getValue()) == wararea -- so i can use it here
tostring(mr('NPCName1').getValue()) == nppcname
then
mr('catchme').setValue(mr('NPC1').getValue()+a)
clickme()
elseif tonumber(mr('NPC2').getValue()) == wararea --and here
tostring(mr('NPCName2').getValue()) == npcname
then
mr('catchme').setValue(mr('NPC1').getValue()+a)
clickme()
end
end
|
thanks in advance[/code]
Last edited by icsmoke+ on Tue Jan 25, 2022 9:13 am; edited 1 time in total |
|
Back to top |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1065 Location: 0x90
|
Posted: Tue Jan 25, 2022 4:31 am Post subject: |
|
|
You haven't really said what the base address is, but arithmetic is straightforward.
No offence but, your code is pretty messy. It's nested within if..then statements that have lines based on conditions that aren't enclosed within if..then statements and because I don't have the game I can't really say what logic is supposed to be applied here. Perhaps if you can better explain what's supposed to be happening then I can help you more.
|
|
Back to top |
|
|
icsmoke+ Cheater Reputation: 0
Joined: 31 Aug 2020 Posts: 29
|
Posted: Tue Jan 25, 2022 6:53 am Post subject: |
|
|
Thanks for replying, what i want is limit movement by area, which is describe on warposition, what i am asking for, is it corect i write only warposition+1 or warposition+2 and so on, and yes the main problem only on writing aritmethic from address variable for example if warposition value is 10 so the result should be 11 if i write warposition+1 and 12 for warposition+2, sorry my english is not good enough to describe my problem
|
|
Back to top |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1065 Location: 0x90
|
Posted: Tue Jan 25, 2022 7:50 am Post subject: |
|
|
I'll explain something
Code: |
al = getAddressList()
warposition = al.getMemoryRecordByDescription('warposition')
|
This retrieves the memory record object, not the value. What you'll want is to get the value of warposition like so:
Code: |
wararea = {tonumber(warposition.value) + 1',
tonumber(warposition.value) + 2',
tonumber(warposition.value) + 3',
tonumber(warposition.value) + 4',
tonumber(warposition.value) + 5',
tonumber(warposition.value) * 1 + 2',
tonumber(warposition.value) + 5 * 5,}
|
Then you can access the indices like so; wararea[0] through to wararea[6].
Code: |
function byNameandArea()
local NPC1 = al.getMemoryRecordByDescription('NPC1')
local NPC1Name = al.getMemoryRecordByDescription('NPCName1')
local NPC2 = al.getMemoryRecordByDescription('NPC2')
local NPC2Name = al.getMemoryRecordByDescription('NPCName2')
local catchme = al.getMemoryRecordByDescription('catchme')
local a = 10 -- arbitrary value
if NPC1.value == wararea[x] and NPC1Name.value == npcname then -- where x is the index of the value you want to compare against
catchme.value = NPC1.value + a -- I'm not sure what you want a to be but you can set its value at the beginning of the function
clickme()
elseif NPC2.value == wararea[x] and NPC2Name.value == npcname then -- again, x is the index of the wararea table you want to compare against
catchme.value = NPC1.value + a
clickme()
end
end
|
Perhaps something like this is what you need.
|
|
Back to top |
|
|
icsmoke+ Cheater Reputation: 0
Joined: 31 Aug 2020 Posts: 29
|
Posted: Tue Jan 25, 2022 9:13 am Post subject: [ask] how to write arithmetic properly [solved] |
|
|
yes exactly what i want, thank you more
|
|
Back to top |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1065 Location: 0x90
|
Posted: Tue Jan 25, 2022 9:40 am Post subject: |
|
|
Sure! If I helped please give rep .
|
|
Back to top |
|
|
|