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 


Hotkeys in lua

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

Joined: 16 Apr 2010
Posts: 121

PostPosted: Tue May 29, 2012 6:21 am    Post subject: Hotkeys in lua Reply with quote

pretty much what it says. i was asking in other topic, but i guess it went too much offtopic and i did not get reply.

i know that hotkey for button is like this
Code:
createHotkey(CEButton14Click, VK_INSERT)


but what if i want hotkey to set specific value and not press a button?
how could i do tht?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25281
Location: The netherlands

PostPosted: Tue May 29, 2012 8:01 am    Post subject: Reply with quote

Not really sure what you're asking and why you think this is button specific code. (CEButton14Click is just a functionname, not a button)

anyhow:
Code:

createHotkey(functionThatSetsSpecificValue, VK_INSERT)


example:
Code:

function functionThatSetsSpecificValue(sender)
  writeInteger("[[bla.exe+1234]+12]+13", 123456)
end

createHotkey(functionThatSetsSpecificValue, VK_INSERT)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
mordax
Expert Cheater
Reputation: 1

Joined: 16 Apr 2010
Posts: 121

PostPosted: Tue May 29, 2012 1:58 pm    Post subject: Reply with quote

thanks. i got it now. im just having problems understanding lua. it was quite stupid question really, but im all new to lua.

I have another question. what would be the function to toggle freeze of the value instead of specific value?
like if i want to write a hotkey function that freezes/unfreezes the value at specific address/pointer ?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25281
Location: The netherlands

PostPosted: Tue May 29, 2012 2:59 pm    Post subject: Reply with quote

3 methods
1: just toggle the freeze property of a memoryrecord

2: create a timer that sets the value every time it executes and then enable/disable the timer to freeze/unfreeze

3: create a thread in an infinite loop that sets the value to the address. Use a variable to determine if it should set or not

3b: same as 3 but instead of a thread use an infinite loop and use processMessages to prevent freezing (Stupid method)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
mordax
Expert Cheater
Reputation: 1

Joined: 16 Apr 2010
Posts: 121

PostPosted: Wed May 30, 2012 6:46 am    Post subject: Reply with quote

im still beginner in lua. can you plz show me example of whichever you think would work best?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25281
Location: The netherlands

PostPosted: Wed May 30, 2012 7:05 am    Post subject: Reply with quote

First two options work the best
3th one is a bit more complex and more cpu intensive

1: Just add a memoryrecord to your cheattable and assign it a toggle hotkey (rightclick, assign hotkey)
Alternatively, get the addresslist (getAddressList() ), then get the memoryrecord from the addresslist(e.g: addresslist_getMemoryRecordByDescription(addresslist, description), then call memoryrecord_freeze(memrec) to freeze and memoryrecord_unfreeze(memrec) to unfreeze

2:
Code:

function address1Freezer(timer)
  writeInteger(0x12345, 123)
end

function freezeAddress1()
  if (address1FreezeTimer==nil) then --first time init
    address1FreezeTimer=createTimer(nil,false)

    timer_setInterval(address1FreezeTimer,100) --set value every 100 milliseconds
    timer_onTimer(address1FreezeTimer, address1Freezer)
  end
  timer_setEnabled(address1FreezeTimer, true)
end

function unfreezeAddress1()
  if (address1FreezeTimer~=nil) then
    timer_setEnabled(address1FreezeTimer, false) --stop the freezer
  end
end

call freezeAddress1() to freeze and unfreezeAddress1() to unfreeze

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
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