How do you check to see if a value of an address has changed?

Feb 23, 2018
14
0
1
#1
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?
 

TheyCallMeTim13

Wiki Monster
Talents
Fearless Donors
Mar 3, 2017
406
44
28
#2
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:
{$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
 
Feb 23, 2018
14
0
1
#3
TheyCallMeTim13 post_id=39178 time=1521921870 user_id=91 said:
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!
 
Top Bottom