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 


Hopefully simple script

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
jorty
How do I cheat?
Reputation: 0

Joined: 28 Feb 2018
Posts: 2

PostPosted: Wed Feb 28, 2018 4:51 pm    Post subject: Hopefully simple script Reply with quote

Hi everybody!

trying to make a (hopefully) simple script that will wait for a specific (4 bytes) address value to change from 0 to 1 and then force it to 4 then reset

what i have so far:
Code:
local a = readInteger(013EE448)
if a=0
repeat
until a=1
writeInteger(013EE448,4)
end


when i attempt to run it i get an error message about a malformed number near 013EE448.

Also, I don't think it will repeat, it is one run code at this point

I'm obviously doing something wrong, does anybody know what?

i have looked at the guides and stuff, but found them either lacking of examples on how to actually use the commands or full of extra stuff i don't think i need and I don't know enough to strip out the extra stuff
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Wed Feb 28, 2018 5:41 pm    Post subject: Reply with quote

  • Hexadecimal numeric literals must be prefixed by 0x or 0X
  • That code will only be run once (i.e. it will only make the replacement once)
  • There is no end to the first if statement
  • CE would get stuck in an infinite loop because the local "a" is never updated
  • That would block CE's main thread until it terminates
  • Use proper coding conventions (especially indentation)
I don't expect beginners to know CE's Lua API, but you should learn Lua before trying to do anything in CE with it.
Code:
if t then t.destroy(); t = nil end
t = createTimer()
t.Interval = getFreezeTimer().Interval

local oldValue

t.OnTimer = function(timer)
  local newValue = readInteger(0x00230100)
  if oldValue == 0 and newValue == 1 then
    writeInteger(0x00230100, 4)
    -- I don't know what you mean by "reset," but do that here I guess
  end
  oldValue = newValue
end

_________________
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
jorty
How do I cheat?
Reputation: 0

Joined: 28 Feb 2018
Posts: 2

PostPosted: Wed Feb 28, 2018 5:59 pm    Post subject: Reply with quote

Thank you!

your code does exactly what I wanted to get done, and I would not have figured that out on my own without a LOT more time spent on it...

I've dabbled with Lua (mostly with the computercraft mod for Minecraft) but this was a lot more complicated then I thought it would be...
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