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 


Deactivating and activating a timer in Auto Assembly

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

Joined: 21 Nov 2015
Posts: 36

PostPosted: Mon Jan 30, 2017 3:00 pm    Post subject: Deactivating and activating a timer in Auto Assembly Reply with quote

Trying to make it so that when a box is enabled, tmer.enabled=True (my timer is named tmer, because I outright leeched the code from Zanzer), then when it's disabled tmer.Enabled=False. However, any time I do

Code:
[Enable]
luacall(tmer.Enabled=True)
[Disable]
luacall(tmer.Enabled=False)

which strikes me as the most obvious way to accomplish this, the timer gives up and dies. If I just manually enable it via the lua window by typing in tmer.Enabled=True, or disable it by doing the opposite, it works fine. Can luacall not interact with timers? It works for messing with variables.

I'll put the LUA script below in case it becomes relevant, but since the timer is just giving up and dying I assume I'm doing something wrong in the auto assembly.

Code:
TPEnabled = 1
tmer = createTimer(nil, false)
local i=1
tmer.OnTimer = function(timer)
  i = i + 1
  TPRestore()
  print ("Timer is Enabled. Tick number: ", i)
end
tmer.Interval = 2000
function TPRestore ()
--Below writes to Max TP
writeBytes("[citra-qt.exe+0032AB88]+E74",03,09)
writeBytes("[citra-qt.exe+0032AB88]+FE0",03,09)
writeBytes("[citra-qt.exe+0032AB88]+114C",03,09)
writeBytes("[citra-qt.exe+0032AB88]+12B8",03,09)
writeBytes("[citra-qt.exe+0032AB88]+1424",03,09)
writeBytes("[citra-qt.exe+0032AB88]+1590",03,09)
writeBytes("[citra-qt.exe+0032AB88]+16FC",03,09)
writeBytes("[citra-qt.exe+0032AB88]+1868",03,09)
writeBytes("[citra-qt.exe+0032AB88]+19D4",03,09)
writeBytes("[citra-qt.exe+0032AB88]+1B40",03,09)
writeBytes("[citra-qt.exe+0032AB88]+1CAC",03,09)
--Below writes to Current TP
writeBytes("[citra-qt.exe+0032AB88]+E9A",03,09)
writeBytes("[citra-qt.exe+0032AB88]+1006",03,09)
writeBytes("[citra-qt.exe+0032AB88]+1172",03,09)
writeBytes("[citra-qt.exe+0032AB88]+12DE",03,09)
writeBytes("[citra-qt.exe+0032AB88]+144A",03,09)
writeBytes("[citra-qt.exe+0032AB88]+15B6",03,09)
writeBytes("[citra-qt.exe+0032AB88]+1722",03,09)
writeBytes("[citra-qt.exe+0032AB88]+188E",03,09)
writeBytes("[citra-qt.exe+0032AB88]+19FA",03,09)
writeBytes("[citra-qt.exe+0032AB88]+1B66",03,09)
end


Note that the functions both work correctly when called via the script, so I'm not concerned with that; I just can't get the timer to respect my checkbox, and was hoping not to have it constantly ticking in the background if the cheats off.

Though, as a side question, the bytes immediately following Current TP are for exp; I was using writeinteger and constantly resetting my experience (d'oh) when it executed, because I guess writeinteger writes as a 4 byte? Is there a more intuitive way then manually writing in the bytes to equal 2307(it reads backwords, for some reason, in the memory; 03, 09 reads as 0903 in hex, which is 2307 (just... something absurdly high I used so that I'd know for a fact it was the cheat.)
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Mon Jan 30, 2017 3:45 pm    Post subject: Reply with quote

True is a variable name
true is a boolean value
Case kills

Alternatively:
Code:
{$lua}
[ENABLE]
-- this is now lua!
[DISABLE]
-- this too!

Code:
writeBytes(address, wordToByteTable(2307))
Back to top
View user's profile Send private message
Valatros
Cheater
Reputation: 1

Joined: 21 Nov 2015
Posts: 36

PostPosted: Mon Jan 30, 2017 6:40 pm    Post subject: Reply with quote

... oh my god. Okay, I feel silly. Thank you; was driving myself up a wall. Thanks for the tip on the lua via assembly, too; I assume doing it that way means whatever lua I put into "Enable" will run once (unless I go so far as to make a timer to make it repeat) whenever I enable? And the same for what I put under disable.
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