Posted: Wed Feb 28, 2018 4:51 pm Post subject: Hopefully simple script
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
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.
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