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 


Script Does Nothing
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
microsoftv
Advanced Cheater
Reputation: 0

Joined: 07 Apr 2016
Posts: 82
Location: U.S

PostPosted: Fri May 06, 2016 6:11 pm    Post subject: Script Does Nothing Reply with quote

My script that i've been working on has been completed:
if(t ~= nil) then -- if script is already running then
timer_setEnabled(t, false) -- stop the script
object_destroy(t)
t = nil
end

tickrate = 50 -- 50ms is every 3 frames

function main ()
if isKeyPressed(VK_V) and readInteger(getAddress("[ballstate]+1c")) == 1 then
doKeyPress(VK_Z)
end
end

t = createTimer(nil, false) -- create a Timer object and assign it to variable t
timer_onTimer(t, main) -- When the timer ticks, call the function main
timer_setInterval(t, tickrate) -- Sets the tickrate of the timer in milliseconds
timer_setEnabled(t, true) -- Turns the timer on
but for some reason, whenever the two variables are filled and correct (Pointer/Integer == 1 and VK_V is pressed) it does nothing, would appreciate any help. Also, i'm a mostly noob CE person, sorry.


Last edited by microsoftv on Fri May 06, 2016 7:01 pm; edited 1 time in total
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Fri May 06, 2016 6:33 pm    Post subject: Reply with quote

There is no need to paste your script off-site.
Back to top
View user's profile Send private message
microsoftv
Advanced Cheater
Reputation: 0

Joined: 07 Apr 2016
Posts: 82
Location: U.S

PostPosted: Fri May 06, 2016 7:17 pm    Post subject: Reply with quote

++METHOS wrote:
There is no need to paste your script off-site.


Done
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4717

PostPosted: Fri May 06, 2016 8:00 pm    Post subject: Reply with quote

You're using deprecated functions.
If "ballstate" isn't a registered symbol, it will fail.
Make sure your pointer path is correct.
Your script could be optimized (i.e. getAddress isn't needed).
Using a hotkey is easier IMO.

This script works just fine for me:
Code:
if(t ~= nil) then
  t.destroy()
  t = nil
end

function main()
  if isKeyPressed(VK_V) and readInteger("[ballstate]+1c") == 1 then
    doKeyPress(VK_Z)
  end
end

t = createTimer()
t.Interval = 50
t.OnTimer = main

If it doesn't work for you, then I'd guess your call to readInteger is failing. Print it out in the Lua console and see if it works.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
microsoftv
Advanced Cheater
Reputation: 0

Joined: 07 Apr 2016
Posts: 82
Location: U.S

PostPosted: Fri May 06, 2016 8:09 pm    Post subject: Reply with quote

ParkourPenguin wrote:
You're using deprecated functions.
If "ballstate" isn't a registered symbol, it will fail.
Make sure your pointer path is correct.
Your script could be optimized (i.e. getAddress isn't needed).
Using a hotkey is easier IMO.

This script works just fine for me:
Code:
if(t ~= nil) then
  t.destroy()
  t = nil
end

function main()
  if isKeyPressed(VK_V) and readInteger("[ballstate]+1c") == 1 then
    doKeyPress(VK_Z)
  end
end

t = createTimer()
t.Interval = 50
t.OnTimer = main

If it doesn't work for you, then I'd guess your call to readInteger is failing. Print it out in the Lua console and see if it works.


Got it to work, but is there any way to make it react faster (other than changing timer ms/s?
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4717

PostPosted: Fri May 06, 2016 8:13 pm    Post subject: Reply with quote

Code this in assembly.
_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
microsoftv
Advanced Cheater
Reputation: 0

Joined: 07 Apr 2016
Posts: 82
Location: U.S

PostPosted: Sat May 07, 2016 1:31 pm    Post subject: Reply with quote

ParkourPenguin wrote:
Code this in assembly.

Ok, so I did it in AA, but it seems just as fast as it was before. Also, is there any way to make it search for a certain area of value, ie: 0-10000?
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4717

PostPosted: Sat May 07, 2016 1:56 pm    Post subject: Reply with quote

What do you mean by faster? Hand-coded assembly should be faster than Lua if you do it correctly.

0-10000 (inclusive):
Code:
-- Lua
function main()
  local v = readInteger("[ballstate]+1c")
  if isKeyPressed(VK_V) and v >= 0 and v <= 10000 then
    doKeyPress(VK_Z)
  end
end

Code:
// x86
mov eax,[ballstate]
mov eax,[eax+1c]
cmp eax,2710
ja skip
// code if true
skip:
// end of if statement

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
microsoftv
Advanced Cheater
Reputation: 0

Joined: 07 Apr 2016
Posts: 82
Location: U.S

PostPosted: Sat May 07, 2016 2:20 pm    Post subject: Reply with quote

ParkourPenguin wrote:
What do you mean by faster? Hand-coded assembly should be faster than Lua if you do it correctly.

0-10000 (inclusive):
Code:
-- Lua
function main()
  local v = readInteger("[ballstate]+1c")
  if isKeyPressed(VK_V) and v >= 0 and v <= 10000 then
    doKeyPress(VK_Z)
  end
end

Code:
// x86
mov eax,[ballstate]
mov eax,[eax+1c]
cmp eax,2710
ja skip
// code if true
skip:
// end of if statement

Code:

[ENABLE]
{$lua}
if(t ~= nil) then -- if script is already running then
    timer_setEnabled(t, false) -- stop the script
    object_destroy(t)
    t = nil
end

tickrate = 1 -- 50ms is every 3 frames

function main ()
if isKeyPressed(VK_V) and readBytes(getAddress("[ballstate]+128")) <= 10000 and readBytes(getAddress("[ballstate]+1c")) == 1 then
doKeyPress(VK_Z)
end
end

t = createTimer(nil, false)  -- create a Timer object and assign it to variable t
timer_onTimer(t, main)   -- When the timer ticks, call the function main
timer_setInterval(t, tickrate) -- Sets the tickrate of the timer in milliseconds
timer_setEnabled(t, true) -- Turns the timer on -- Lua code here
{$asm}
// other assembly code
[DISABLE]
// etc...


That's what I have
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4717

PostPosted: Sat May 07, 2016 2:44 pm    Post subject: Reply with quote

Of course nothing changed: you just copied and pasted your Lua script inside an AA script. In case you aren't aware, assembly (more specifically x86) isn't Lua; it's a different programming language.

I still don't know what you mean by faster.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
microsoftv
Advanced Cheater
Reputation: 0

Joined: 07 Apr 2016
Posts: 82
Location: U.S

PostPosted: Sat May 07, 2016 3:24 pm    Post subject: Reply with quote

ParkourPenguin wrote:
Of course nothing changed: you just copied and pasted your Lua script inside an AA script. In case you aren't aware, assembly (more specifically x86) isn't Lua; it's a different programming language.

I still don't know what you mean by faster.


Any place where I can learn x86?
Faster as in it checks the value faster and reacts faster to when it reaches that value.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4717

PostPosted: Sat May 07, 2016 3:30 pm    Post subject: Reply with quote

In this case, that's the sole purpose of the "Interval" property. Why would you want to go around it? Just lower it even more.

The doKeyPress is right after your check. It's not like you're doing any complicated arithmetic in it. It should react instantly from your perspective.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
microsoftv
Advanced Cheater
Reputation: 0

Joined: 07 Apr 2016
Posts: 82
Location: U.S

PostPosted: Sat May 07, 2016 3:51 pm    Post subject: Reply with quote

ParkourPenguin wrote:
In this case, that's the sole purpose of the "Interval" property. Why would you want to go around it? Just lower it even more.

The doKeyPress is right after your check. It's not like you're doing any complicated arithmetic in it. It should react instantly from your perspective.


So, I get the whole concept now, i'm just wondering how I would change all the stuff I have to work with x86.
Also, what does this do?
Code:
// x86
mov eax,[ballstate]
mov eax,[eax+128]
cmp eax,2710
ja skip
// code if true
skip:
// end of if statement
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4717

PostPosted: Sat May 07, 2016 4:01 pm    Post subject: Reply with quote

Code:
mov eax,[ballstate]  // moves the value at the address of the symbol "ballstate" into eax
mov eax,[eax+128]    // moves the value at eax + 128 into eax
cmp eax,2710         // compares eax against 0x2710 (10000 in decimal)
ja skip              // jumps to the label "skip" if eax is above 10000 (unsigned, so this includes negative numbers)
// code if true
skip:                // a label
// end of if statement

I think you should just stick with Lua for now. Learning assembly takes time, and you should start out with more simple things than this.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
microsoftv
Advanced Cheater
Reputation: 0

Joined: 07 Apr 2016
Posts: 82
Location: U.S

PostPosted: Sun May 08, 2016 11:44 am    Post subject: Reply with quote

ParkourPenguin wrote:
Code:
mov eax,[ballstate]  // moves the value at the address of the symbol "ballstate" into eax
mov eax,[eax+128]    // moves the value at eax + 128 into eax
cmp eax,2710         // compares eax against 0x2710 (10000 in decimal)
ja skip              // jumps to the label "skip" if eax is above 10000 (unsigned, so this includes negative numbers)
// code if true
skip:                // a label
// end of if statement

I think you should just stick with Lua for now. Learning assembly takes time, and you should start out with more simple things than this.


Hello again, I will gladly stick with Lua. I just have a problem that I need a little help with, as I have spent the literal full day trying to figure it out.
This is the code:
Code:
[ENABLE]
{$lua}
if(t ~= nil) then -- if script is already running then
    timer_setEnabled(t, false) -- stop the script
    object_destroy(t)
    t = nil
end

tickrate = 1 -- 50ms is every 3 frames

function main ()
hitstun_countdown = readInteger(getAddress("[ballstate]+128"))/1092
if readInteger(getAddress("[ballstate]+128"))/1092 > 120 then hitstun_countdown = 0
print(hitstun_countdown)
end
end

t = createTimer(nil, false)  -- create a Timer object and assign it to variable t
timer_onTimer(t, main)   -- When the timer ticks, call the function main
timer_setInterval(t, tickrate) -- Sets the tickrate of the timer in milliseconds
timer_setEnabled(t, true) -- Turns the timer on -- Lua code here
{$asm}
// other assembly code
[DISABLE]
// etc...

The problem with it is that, when printing it, it's not supposed to constantly become zero, because when the "ball" (which is what i am using this script to do stuff to) it in "hitstun_countdown" it isn't supposed to become 0 all the time, as in if the ball hits a wall, the countdown should print, lets say 3...2...1... (in frames), but instead when adding the line:
Code:
if readInteger(getAddress("[ballstate]+128"))/1092 > 120 then hitstun_countdown = 0 
It wants to make it always 0 even when the value is below 120. If you are able to remedee the problem, you might be the most wonderful person i've met, please... Also, the whole reason I have this specific line of code to be > 120 is because when the ball isn't hitting a wall, for some idiotic reason, the hitstun_countdown (or
Code:
readInteger(getAddress("[ballstate]+128"))/1092
) is like 30,000... so, if 120 = max frames/value that hitstun_countdown is supposed to be, then 30,000 should be 0 cause when the ball isn't hitting a wall, it's not in hitstun, therefor it SHOULD have a value of 0.
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 1, 2  Next
Page 1 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