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 


How to recalculate addresses inside Auto Assemble scripts

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

Joined: 29 May 2015
Posts: 52

PostPosted: Thu Mar 19, 2020 1:14 pm    Post subject: How to recalculate addresses inside Auto Assemble scripts Reply with quote

Hey guys

I have a bunch of auto assemble scripts that change each game update, and I have to manually update each one each time. Is there a way to recalculate them as with normal addresses?

The scripts are identical, bar the values:
Code:
[ENABLE]
urw.exe+A2947CC:
  dw #816 // dd #816
urw.exe+A2EF070:
  dw #1507 // dd #1507
[DISABLE]

or
Code:
[ENABLE]
urw.exe+A2947CC:
  dw #856 // dd #856
urw.exe+A2EF070:
  dw #1444 // dd #1444
[DISABLE]

or
Code:
[ENABLE]
urw.exe+A2947CC:
  dw #322 // dd #322
urw.exe+A2EF070:
  dw #507 // dd #507
[DISABLE]


I suspect I have to predefine them in lua and call them in the AA scripts? And update only the lua each time I need that.

Can I do something like this, predefine address1 and address2 in lua, and then use something like:
Code:
[ENABLE]
address1:
  dw #816 // dd #816
address2:
  dw #1507 // dd #1507
[DISABLE]

so I only have to update address1 and address2 in the LUA?

Thank you
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 153

Joined: 06 Jul 2014
Posts: 4734

PostPosted: Thu Mar 19, 2020 5:01 pm    Post subject: Reply with quote

Code:
if not getAddressSafe'address1' then
  registerSymbol('address1', 'urw.exe+A2947CC', true)
end
if not getAddressSafe'address2' then
  registerSymbol('address2', 'urw.exe+A2EF070', true)
end

_________________
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
FanFanStef
Advanced Cheater
Reputation: 0

Joined: 29 May 2015
Posts: 52

PostPosted: Thu Mar 19, 2020 5:18 pm    Post subject: Reply with quote

Thank you. I get this error when starting the table:
Code:
"Error:Failure determining what urw.exe+A2967CC means."

Any thoughts? THanks.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 153

Joined: 06 Jul 2014
Posts: 4734

PostPosted: Thu Mar 19, 2020 5:22 pm    Post subject: Reply with quote

Attach to the game first.
_________________
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
FanFanStef
Advanced Cheater
Reputation: 0

Joined: 29 May 2015
Posts: 52

PostPosted: Thu Mar 19, 2020 5:26 pm    Post subject: Reply with quote

This is the full lua, it first attaches to the exe: https://prnt.sc/rjbdva
Code:
function cycleFullCompact()
  local state = not(compactmenuitem.Caption == 'Compact View Mode')
  compactmenuitem.Caption = state and 'Compact View Mode' or 'Full View Mode'
  getMainForm().Splitter1.Visible = state
  getMainForm().Panel4.Visible    = state
  getMainForm().Panel5.Visible    = state
end

function addCompactMenu()
  if compactmenualreadyexists then return end
  local parent = getMainForm().Menu.Items
  compactmenuitem = createMenuItem(parent); parent.add(compactmenuitem)
  compactmenuitem.Caption = 'Compact View Mode'
  compactmenuitem.OnClick = cycleFullCompact
  compactmenualreadyexists = 'yes'
end

addCompactMenu()

PROCESS_NAME = 'urw.exe'
--------
-------- Auto Attach
--------
local autoAttachTimer = nil ---- variable to hold timer object
local autoAttachTimerInterval = 1000 ---- Timer intervals are in milliseconds
local autoAttachTimerTicks = 0 ---- variable to count number of times the timer has run
local autoAttachTimerTickMax = 5000 ---- Set to zero to disable ticks max
local function autoAttachTimer_tick(timer) ---- Timer tick call back
        ---- Destroy timer if max ticks is reached
   if autoAttachTimerTickMax > 0 and autoAttachTimerTicks >= autoAttachTimerTickMax then
      timer.destroy()
   end
        ---- Check if process is running
   if getProcessIDFromProcessName(PROCESS_NAME) ~= nil then
      timer.destroy() ---- Destroy timer
      openProcess(PROCESS_NAME) ---- Open the process
   end
   autoAttachTimerTicks = autoAttachTimerTicks + 1 ---- Increase ticks
end
autoAttachTimer = createTimer(getMainForm()) ---- Create timer with the main form as it's parent
autoAttachTimer.Interval = autoAttachTimerInterval ---- Set timer interval
autoAttachTimer.OnTimer = autoAttachTimer_tick ---- Set timer tick call back

if not getAddressSafe'address1' then
  registerSymbol('address1', 'urw.exe+A2967CC', true)
end
if not getAddressSafe'address2' then
  registerSymbol('address2', 'urw.exe+A2F1070', true)
end


EDIT: It works if I click manually execute, and that is fine for me, probably it's too quick to work upon load. So thank you very much.
EDIT2: I tried adding a sleep(5000) before the IF, but it still gives that error and I have to execute it manually. Nevertheless is cool for me.
Kalabunga!!
EDIT3: Solved it by wrapping it into a function and calling the function in an AAS. Thanks!
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 153

Joined: 06 Jul 2014
Posts: 4734

PostPosted: Thu Mar 19, 2020 6:50 pm    Post subject: Reply with quote

Timer creation is non-blocking. The rest of the script will still run before CE has attached to the game.

I think openProcess blocks until it's done, so you might be able to put it immediately after that. You could also define MainForm.OnProcessOpened:
Code:
oldOnProcessOpened = MainForm.OnProcessOpened

MainForm.OnProcessOpened = function(processid, processhandle, caption)
  if oldOnProcessOpened then oldOnProcessOpened() end

  if not getAddressSafe'address1' then
    registerSymbol('address1', 'urw.exe+A2947CC', true)
  end
  if not getAddressSafe'address2' then
    registerSymbol('address2', 'urw.exe+A2EF070', true)
  end
end

I'm not sure if symbols would be ready in either scenario. If not, wrap the if statements in a timer with a low interval (e.g. 10) and destroy the timer when it runs.

PS: the auto attach list is a thing that exists:
Code:
getAutoAttachList().add'urw.exe'

_________________
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
FanFanStef
Advanced Cheater
Reputation: 0

Joined: 29 May 2015
Posts: 52

PostPosted: Fri Mar 20, 2020 3:18 am    Post subject: Reply with quote

Thanks again Very Happy
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