Page 1 of 1
How do you check to see if a value of an address has changed?
Posted: Sat Mar 24, 2018 7:51 pm
by Reclaimer Shawn
Let's say I want to have a function execute whenever a certain address value changes from one value to another(let's say address 0x80000000). I've tried setting readInteger("80000000") as a variable and then comparing it to itself, but that doesn't appear to work. How could I changing of an address via Lua?
Re: How do you check to see if a value of an address has changed?
Posted: Sat Mar 24, 2018 8:04 pm
by TimFun13
Not real sure but some thing like this might work, and the synchronized thread part is only needed if you want to mess with stuff on the UI thread.
Code: Select all
{$lua}
------------------------------ ENABLE ------------------------------
[ENABLE]
local address = 0x80000000
local function synchronizedLuaThread(thread)
if RunLuaThread then
-- Body for UI code.
end
checkSynchronize()
if thread ~= nil and type(thread.terminate) == 'function' then
thread.terminate()
end
end
local function luaThread(thread)
while RunLuaThread do
if readInteger(address) ~= LuaThreadLastValue then
LuaThreadLastValue = readInteger(address)
-- Body for non-UI code.
synchronize(synchronizedLuaThread)
end
sleep(0)
end
thread.terminate()
end
----------------------------------
if syntaxcheck then return end
RunLuaThread = true
LuaThreadLastValue = readInteger(address)
createThread(luaThread)
------------------------------ DISABLE ------------------------------
[DISABLE]
if syntaxcheck then return end
RunLuaThread = false
LuaThreadLastValue = nil
Re: How do you check to see if a value of an address has changed?
Posted: Sun Mar 25, 2018 12:58 am
by Reclaimer Shawn
ShyTwig16 wrote: ↑Sat Mar 24, 2018 8:04 pm
Not real sure but some thing like this might work, and the synchronized thread part is only needed if you want to mess with stuff on the UI thread.
Thanks for trying to help me, but I wasn't able to understand how to implement the above code. However, I ended up solving my issue anyways. I'd asked this because I needed to check whenever things in the game met a certain condition, and then set values based on that. I instead found an address that flags whenever the thing I wanted to record happened, and that was enough to do what I wanted. Thanks once again though!