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 


CE losing game process after reboot
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Tue Jan 09, 2018 9:11 am    Post subject: Reply with quote

No you don't have to write the process id, CE provides it to the function (though it's not actually used in this case)

Quote:
they count always 0. Would be great to use this fact and create term like this "When 'first' value 0 - clear clipboard from old value"
simple enough, full code:

Code:
onOpenProcess = function(pid)
  reinitializeSymbolhandler()
  local al = getAddressList()
  al.disableAllWithoutExecute()
  al.getMemoryRecordByDescription('enable on attach').Active = true
  swapValueBackup = nil -- part of restore script
end

local getmr = getAddressList().getMemoryRecordByDescription
local first = getmr('first')
local second = getmr('second')

-- OnGetDisplayValue called when value in CE GUI changes
-- alternative would be a timer that constantly reads memory...
first.OnGetDisplayValue = function(mr, newvalue)
  if newvalue == '0' then
    swapValueBackup = nil
  end
end

-- see defines.lua and https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
swapValueBackup = nil -- needs to be reset when process is closed since the value is random
local swapValuesHotKeyKeys = {VK_F5}

swapValuesHotKey = createHotkey(function()
  if not swapValueBackup then
    swapValueBackup = first.Value
    first.Value = second.Value
  else
    first.Value = swapValueBackup
  end
end, swapValuesHotKeyKeys)
Back to top
View user's profile Send private message
!BEWARE!
!BEWARE! Deletes post on answer
Reputation: 0

Joined: 26 Jun 2013
Posts: 56
Location: !BEWARE!

PostPosted: Tue Jan 09, 2018 10:41 am    Post subject: Reply with quote

Auto execute script still dont work, must hit button manual
and after game reboot have lua error:
Code:
Error:[string "onOpenProcess = function(pid)
..."]:4: attempt to call a nil value (field 'disableAllWithoutExecute')
Notice I dont use "Select a process to open" after start CE but load it auto in Generall settings "automaticlly attach to processes name [game.exe]" and "Even autoattach when another process has already been selected"

Hotkey dont work in circle mode, can use only two times. "On" and "off". third time to turn "On" its not response

And clear clipboard dont work, still loading old value, maybe its cause by this lua error above.
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Tue Jan 09, 2018 4:24 pm    Post subject: Reply with quote

Hm, not sure why you'd get that error... even if the getAddressList somehow returned nil I'd expect something different. Though it may not be entirely necessary to call al.disableAllWithoutExecute(), I did it more as a "just in case, it can't hurt" kind of thing.

Not sure why the script wouldn't enable at the start either unless you normally can't enable it immediately.

And if you're wanting to toggle it on and off even when the value isn't set to 0 (or the process restarted) then you'd need to modify the code since it's based purely on the backup value being set

Code:
swapValuesHotKey = createHotkey(function()
  if not swapValueBackup then
    swapValueBackup = first.Value
    first.Value = second.Value
  else
    first.Value = swapValueBackup
    swapValueBackup = nil -- reset so it can be toggle again
  end
end, swapValuesHotKeyKeys)
Back to top
View user's profile Send private message
!BEWARE!
!BEWARE! Deletes post on answer
Reputation: 0

Joined: 26 Jun 2013
Posts: 56
Location: !BEWARE!

PostPosted: Tue Jan 09, 2018 5:52 pm    Post subject: Reply with quote

So if i good understand. Cant make third swap because Clipboard is bussy?
Created graph to make all clear:

Quote:
______________|__after game__|_after load_|first swap_|II_ swap|III_swap|
______________|___reboot____|game match|_turn_ON_|turn_OFF|turn_ON|
|__CLIPBOARD__|_____?_______|____?____|____1____|___1___|___1___|<Bussy from I swap]
|_FIRST_VALUE_|_____0_______|____1____|____2____|___1___|___2___|
|SECOND_VALUE|_____0_______|____2____|____2____|___2___|___2___|


I thought clipboard every turn on going be overwritten.
How in your script reset clipboard? must restart aplication Cheat Engine?
Maybe make turn on/off on two keys. Off key could be instantly clear clipboard value. And then turn on/off process could be loop
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
!BEWARE!
!BEWARE! Deletes post on answer
Reputation: 0

Joined: 26 Jun 2013
Posts: 56
Location: !BEWARE!

PostPosted: Wed Jan 10, 2018 4:22 pm    Post subject: Reply with quote

I did some tests and game dont crashing when i add first value to second.
So it can be simple swap both values so that 1 becomes 2 and 2 becomes 1
Could you convert this script to loop in two sides?
Code:
-- see defines.lua and https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
local swapValuesHotKeyKeys = {VK_F12}
swapValuesHotKey = createHotkey(function()
  local getmr = getAddressList().getMemoryRecordByDescription
  local first = getmr('first') -- gets memory record with name/description 'first'
  local second = getmr('second') -- ^ but 'second'
  first.Value = second.Value
end, swapValuesHotKeyKeys)
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Wed Jan 10, 2018 4:51 pm    Post subject: This post has 1 review(s) Reply with quote

Quote:
So it can be simple swap both values so that 1 becomes 2 and 2 becomes 1
That's a simple change


Code:
-- see defines.lua and https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
local swapValuesHotKeyKeys = {VK_F12}
swapValuesHotKey = createHotkey(function()
  local getmr = getAddressList().getMemoryRecordByDescription
  local first = getmr('first') -- gets memory record with name/description 'first'
  local second = getmr('second') -- ^ but 'second'
  first.Value, second.Value = second.Value, first.Value -- swap values
end, swapValuesHotKeyKeys)
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 All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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