function DestroyArray(tempExArray) --Destroy all elements in array and assign each of them a value of nil for i=1,#tempExArray do object_destroy(tempExArray[i]) tempExArray[i] = nil end return nil end function newTimer() --Create new timer in array Timers[TC] = createTimer(nil, false) Timers[TC].Interval = 1 Timers[TC].Enabled = true return Timers[TC] end function SwapE(v) --Change Little Endian to Big Endian return (((v & 0xFF) << 24) | ((v & 0xFF00) << 8) | ((v & 0xFF0000) >> 8 ) | (v >> 24)) end function BitwiseAnd(w) --Change Pointer to Offset w = SwapE(w) if w < 0x81000000 then return w & 0xFFFFFF else return w & 0xFFFFFFF end end function GetAddress(adr, AO, steps) --Address Offset, Additional Offset, Number of Steps local bit = 0 local s = 0 if StartAddress and (StartAddress ~= 0x1) then adr = readInteger(StartAddress+adr) if adr and (adr > 0) and steps then while s < (steps-1) do if adr and (adr > 0) then bit = BitwiseAnd(adr) adr = readInteger(StartAddress+bit+AO) else adr = 0x1 end s = s + 1 end if adr > 0x1 then bit = BitwiseAnd(adr) adr = StartAddress+bit else adr = 0x1 end else adr = 0x1 end else adr = 0x1 end return adr end function WriteSymbol(tempstring, value) --Register symbol unregisterSymbol(tempstring) registerSymbol(tempstring, value) return nil end function MakeNewEntry(tempSN, tempAdr, tempAddiOff, tempSteps) --Most important function single address local address = 0x1 newTimer().OnTimer = function(timer) address = GetAddress(tempAdr, tempAddiOff, tempSteps) WriteSymbol(tempSN, address) end Symbols[SC] = tempSN SC = SC + 1 TC = TC + 1 return nil end function MakeNewEntryArray(tempSN, tempAdr, tempAddiOffOne, tempAddiOffTwo, tempArySize, tempSteps) --Most important function multiple addresses local tempArray = {} local tempFirstOffset = 0 newTimer().OnTimer = function(timer) tempFirstOffset = tempAddiOffOne for i=1,tempArySize do tempArray[i] = GetAddress(tempAdr, tempFirstOffset, tempSteps) tempFirstOffset = tempFirstOffset + tempAddiOffTwo WriteSymbol(tempSN .. i, tempArray[i]) end end for i=1,tempArySize do Symbols[SC] = tempSN .. i SC = SC + 1 end TC = TC + 1 return nil end if CalculateStart then CalculateStart.destroy() end --Calculate and set start of RAM CalculateStart = createTimer(nil, false) CalculateStart.Interval = 1000 CalculateStart.Enabled = true CalculateStart.OnTimer = function(timer) if (not StartAddress) or (readString(StartAddress) ~= "G8MJ01") or (not Start) then if readInteger(0x7FFF0000) and (readString(0x7FFF0000) == "G8MJ01") then StartAddress = 0x7FFF0000 elseif readInteger(0x2580000000) and (readString(0x2580000000) == "G8MJ01") then StartAddress = 0x2580000000 elseif readInteger(0x180040000) and (readString(0x180040000) == "G8MJ01") then StartAddress = 0x180040000 elseif readInteger(0x180020000) and (readString(0x180020000) == "G8MJ01") then StartAddress = 0x180020000 elseif readInteger(0x1802C0000) and (readString(0x1802C0000) == "G8MJ01") then StartAddress = 0x1802C0000 else StartAddress = 0x1 end WriteSymbol("Start", StartAddress) end end if messageDialog("Do you want to run the additional Lua scripts for Dynamic Addresses? \ \ Note: There seems to be some sort of memory leak in the Dynamic Addresses scripts that I can't figure out how to fix, so running them will use a lot of memory. You can re-execute the main script at any time to disable them and preserve memory, although the memory already being used will not be returned.", mtConfirmation, mbYes, mbNo) == mrYes then Input = "Y" else Input = "N" end if Input == "Y" then if Timers then DestroyArray(Timers) --Destroy any timers that exist else Timers = {} end if Symbols then DestroyArray(Symbols) --Destroy any symbols that exist else Symbols = {} end TC = 1 SC = 1 --MakeNewEntry(Script name, Address offset, Additional offset, Number of Steps) --MakeNewEntryArray(Script name, Address offset, Additional offset one, Additional offset two, Amount of addresses to make, Number of Steps) MakeNewEntryArray("EnemyHPInScript", 0x418970, 0x24, 0x4, 10, 2) MakeNewEntry("CrowdSPRefillScript", 0x418970, 0, 1) MakeNewEntry("CurrentTextboxScript", 0x817108, 0, 3) MakeNewEntry("CurrentTextOptionStart", 0x3E18E8, 0, 1) MakeNewEntry("MenuCurserTextboxScript", 0xB296BC, 0, 1) MakeNewEntry("CameraPointerScript", 0x3C5868, 0, 1) --Additional entries go here else if Timers then DestroyArray(Timers) --Destroy any timers that exist end if Symbols then --Register symbols with address 0x1 for i=1,#Symbols do WriteSymbol(Symbols[i], 0x1) end end end