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 


What's wrong with this timer script?

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

Joined: 06 Jul 2015
Posts: 65
Location: Poland

PostPosted: Tue Aug 16, 2016 8:37 am    Post subject: What's wrong with this timer script? Reply with quote

Hey. I'm working on some stuff (dodge system to Gothic 3 via cheat engine, Autohotkey software is too laggy), and I've created some timer script (to be honest copy-pasted-edited it Embarassed)

Code:

function d1(sender)
  getAddressList().getMemoryRecordByDescription("back-dash").Value=2500
    getAddressList().getMemoryRecordByDescription("side-dash").Value=2500
     getAddressList().getMemoryRecordByDescription("forward-dash").Value=2500
end
createHotkey(d1, 16)

function d2(sender)
  getAddressList().getMemoryRecordByDescription("back-dash").Value=280
    getAddressList().getMemoryRecordByDescription("side-dash").Value=280
     getAddressList().getMemoryRecordByDescription("forward-dash").Value=400
end

t=createTimer(nil, false)
timer_onTimer(t, d2)
timer_setInterval(t, 260)

t.Enabled=true
createHotkey(function () timer_setEnabled(t,true) end, 16)


So, I want that effect:
when I press shift, 3 values from my adress list will change to 2500 (function d1), after 260 miliseconds from shift press, those values will automatically change to values from d2 function (btw those are default in-game values).

I get only half success - indeed it works, but not all the time... Sometimes values gets changed with delay, sometimes values are not even changing after key is pressed, or even after "spamming" shift key - it's not acceptable for usage of this script.

So question is, is there something wrong in that script?
Thanks
Back to top
View user's profile Send private message Send e-mail Visit poster's website
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Tue Aug 16, 2016 12:09 pm    Post subject: This post has 1 review(s) Reply with quote

Would recommend using script to setup hotkey (http://forum.cheatengine.org/viewtopic.php?p=5679193#5679193).
This should work
Code:
local getmr = getAddressList().getMemoryRecordByDescription;
function d1(sender)
   getmr("back-dash").Value=2500
   getmr("side-dash").Value=2500
   getmr("forward-dash").Value=2500
end
function d2(sender)
   getmr("back-dash").Value=280
   getmr("side-dash").Value=280
   getmr("forward-dash").Value=400
end

local tRevert = createTimer(nil,false)
tRevert.Interval = 260;
tRevert.onTimer = function(self)
   d2();
   self.enabled = false;
end
function DoMagic()
   d1()
   tRevert.Enabled = true;
end
hk = (hk and hk.destroy() or createHotkey(DoMagic,VK_SHIFT)) -- avoid having hotkey duplicates

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
squerol
Advanced Cheater
Reputation: 2

Joined: 06 Jul 2015
Posts: 65
Location: Poland

PostPosted: Tue Aug 16, 2016 3:37 pm    Post subject: Reply with quote

DaSpamer wrote:
Would recommend using script to setup hotkey (http://forum.cheatengine.org/viewtopic.php?p=5679193#5679193).
This should work


And indeed, it works PERFECTLY, seriously - finally I won't get annoyed by failed dodges caused by input lag anymore, thank You very much for quick and accurate help, DaSpamer. Wink
Rep up of course Smile
I love helpfullness of some people on this forum Smile

Here is what evolved from that cheat table and simple auto hotkey script (normally there aren't any dodge system in this game)
https://youtu.be/JrNULOZEXBQ
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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