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 


Problem with script

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
16-Bit
Newbie cheater
Reputation: 0

Joined: 17 Jan 2012
Posts: 21

PostPosted: Thu Jan 19, 2012 3:53 am    Post subject: Problem with script Reply with quote

Hi CE

This is my first attempt at a script using Cheat Engine and I'm having problems getting this code right.

Code:
function heal()
InputHP=3000
keyID=115
var=readInteger("xxx.exe+43E1B4")
  if(var <= InputHP) then
  keyDown(keyID)
  keyUp(keyID)
  end
end

t=createTimer(nil);
timer_setInterval(t,400)
timer_onTimer(t,heal)
timer_setEnabled(t,false)

function start()
timer_setEnabled(t,true)
end

function stop()
timer_setEnabled(t,false)
end

createHotkey("start", VK_NUMPAD5)
createHotkey("stop", VK_NUMPAD6)


The code is based off the topic found here:
h ttp://forum.cheatengine.org/viewtopic.php?t=546035 <-- remove space


The script monitors the health by checking every 400ms and executes a key stroke to replenish the health. The script is turned on by pushing 5 and ends by pushing 6.

The issue I have with this script is that its based off a timer and tends to cause issues within the game such as pushing the hotkey twice, or tends to be too slow to initiate.

Is there any way to script this such that it only initiates when the value is changed - without the need for a timer. Similarly is there a better way to execute the on/off feature of the script.

Looking forward to reading the suggestions! Thanks
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Thu Jan 19, 2012 6:06 pm    Post subject: Reply with quote

Try increasing the speed of the timer (lower interval) and keep track when the last time was when you pressed the key.
If the time of last press is too small, don't press the key.

Hmm,not sure if lua provides time functions...
After pressing the key disable the timer and activate another timer that when it's timer triggers activates the main timer and disables itself till next keypressemu

_________________
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