Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --New entries are entered in the DTimer section near the bottom of the script
- function cycleFullCompact() --Compact menu stuff 1
- local state = not(compactmenuitem.Caption == 'Compact View Mode')
- compactmenuitem.Caption = state and 'Compact View Mode' or 'Full View Mode'
- getMainForm().Splitter1.Visible = state
- getMainForm().Panel4.Visible = state
- getMainForm().Panel5.Visible = state
- end
- function addCompactMenu() --Compact menu stuff 2
- if compactmenualreadyexists then return end
- local parent = getMainForm().Menu.Items
- compactmenuitem = createMenuItem(parent); parent.add(compactmenuitem)
- compactmenuitem.Caption = 'Compact View Mode'
- compactmenuitem.OnClick = cycleFullCompact
- compactmenualreadyexists = 'yes'
- end
- function newTimer(tempTI) --Create new timer -> newTimer(Timer interval in milliseconds)
- local Timer = createTimer(nil, false)
- Timer.Interval = tempTI
- Timer.Enabled = true
- return Timer
- end
- function BitwiseAnd(w) --Change Pointer to Offset -> BitwiseAnd(Address)
- w = ((w & 0xFF) << 24) | ((w & 0xFF00) << 8) | ((w & 0xFF0000) >> 8 ) | (w >> 24) --Change Little Endian to Big Endian
- return w & 0x1FFFFFF
- end
- function GetAddress(adr, AO, steps) --GetAddress(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 > 0x1) then
- while s < (steps - 1) do
- if adr and (adr > 0x1) 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 -> WriteSymbol(Script Name, Address to write)
- unregisterSymbol(tempstring)
- registerSymbol(tempstring, value)
- end
- function MakeNewEntry(tempSN, tempAdr, tempAdiOff, tempSteps) --Most important function single address -> MakeNewEntry(Script name, Address offset, Number of Steps)
- local address = GetAddress(tempAdr, tempAdiOff, tempSteps)
- WriteSymbol(tempSN, address)
- Symbols[SC] = tempSN
- SC = SC + 1
- end
- function MakeNewEntryArray(tempSN, tempAdr, tempAddiOffOne, tempAddiOffTwo, tempAddToAdr, tempArySize, tempSteps) --Multiple addresses -> MakeNewEntryArray(Script name, Address offset, Additional offset one, Additional offset two, Offset to add to address each time, Amount of addresses to make, Number of Steps)
- for i=1,tempArySize do
- MakeNewEntry(tempSN .. i, tempAdr, tempAddiOffOne, tempSteps)
- tempAdr = tempAdr + tempAddToAdr
- tempAddiOffOne = tempAddiOffOne + tempAddiOffTwo
- end
- end
- if not CM then --Add compact menu and open Dolphin in Cheat Engine it not open already
- addCompactMenu()
- --Open Dolphin in Cheat Engine if it's not already (Note: Makes script execution slightly slower)
- if (getOpenedProcessID() ~= getProcessIDFromProcessName('Dolphin.exe')) and getProcessIDFromProcessName('Dolphin.exe') then
- openProcess('Dolphin.exe')
- end
- CM = 1
- end
- --Calculate and set start of RAM
- if CalculateStart then --Destroy timer if it exists
- object_destroy(CalculateStart)
- CalculateStart = nil
- end
- CalculateStart = newTimer(5000) --Runs every 5 second(s)
- CalculateStart.OnTimer = function(timer)
- if (not StartAddress) or (readString(StartAddress) ~= "G8MP01") or (not Start) then
- --Dolphin 5.0-3981+
- StartAddress = readPointer("[[[[THREADSTACK0-0x228]+0xB8]+0x220]+0x280]+0x60") --Normal
- if (StartAddress == nil) or (readString(StartAddress) ~= "G8MP01") then
- StartAddress = readPointer("[[[[THREADSTACK0-0x9E0]+0x28]+0x268]+0x6B0]+0x50") --Debug
- end
- if (StartAddress == nil) or (readString(StartAddress) ~= "G8MP01") then
- if readInteger(0x7FFF0000) and (readString(0x7FFF0000) == "G8MP01") then
- StartAddress = 0x7FFF0000
- elseif readInteger(0x2580000000) and (readString(0x2580000000) == "G8MP01") then
- StartAddress = 0x2580000000
- elseif readInteger(0x180040000) and (readString(0x180040000) == "G8MP01") then
- StartAddress = 0x180040000
- elseif readInteger(0x180020000) and (readString(0x180020000) == "G8MP01") then
- StartAddress = 0x180020000
- elseif readInteger(0x1802C0000) and (readString(0x1802C0000) == "G8MP01") then
- StartAddress = 0x1802C0000
- else
- StartAddress = nil
- end
- end
- if StartAddress ~= nil then
- WriteSymbol("Start", StartAddress)
- end
- end
- end
- getMainForm().setCaption("TTYD PAL Table Version 1.851")
- if SetTableData then --Destroy timer if it exists
- object_destroy(SetTableData)
- SetTableData = nil
- end
- if TD then --Destroy TD if it exists
- object_destroy(TD)
- TD = nil
- end
- SetTableData = newTimer(5000) --Runs every 5 second(s)
- SetTableData.OnTimer = function(timer)
- if (StartAddress ~= nil) and ((not TD) or (tempStartAddress and (tempStartAddress ~= StartAddress))) then
- getMainForm().fromAddress.text = string.format("%X",StartAddress)
- getMainForm().toAddress.text = string.format("%X",StartAddress+0x1800000)
- tempStartAddress = StartAddress
- TD = 1
- end
- end
- if messageDialog("Do you want to run the additional Lua scripts for Dynamic Addresses?", mtConfirmation, mbYes, mbNo) == mrYes then
- Input = "Y"
- else
- Input = "N"
- end
- if Input == "Y" then
- if (not CG) or (CG == 0) then --Adjust Garbage Collection to be aggressive and fast enough to work properly
- collectgarbage("setpause",120)
- collectgarbage("setstepmul",400)
- CG = 1
- end
- if not Symbols then
- Symbols = {}
- end
- SC = 1
- if DTimer then --Destroy timer if it exists
- object_destroy(DTimer)
- DTimer = nil
- end
- DTimer = newTimer(1) --Runs every 1 millisecond(s)
- DTimer.OnTimer = function(timer)
- --MakeNewEntry(Script name, Address offset, Number of Steps)
- --MakeNewEntryArray(Script name, Address offset, Additional offset one, Additional offset two, Offset to add to address each time, --Amount of addresses to make, Number of Steps)
- MakeNewEntryArray("EnemyHPInScript", 0x42B4B0, 0x24, 0x4, 0x0, 10, 2)
- MakeNewEntryArray("CurrentTextboxScript", 0x85BC28, 0x0, 0x0, 0x48, 7, 3)
- MakeNewEntry("BattleAddressesScript", 0x42B4B0, 0x0, 1)
- --MakeNewEntry("MenuCurserTextboxScript", 0xB72F5C, 0x0, 1)
- --MakeNewEntry("CameraPointerScript", 0x3D5448, 0x0, 1)
- --MakeNewEntry("FirstStrikeTextDisplayScript", 0xB408A8, 0x0, 1)
- --Additional entries go here
- SC = 1
- end
- else
- if DTimer then --Destroy timer if it exists
- object_destroy(DTimer)
- DTimer = nil
- end
- if Symbols then --Register symbols with address 0x1
- for i=1,#Symbols do
- WriteSymbol(Symbols[i], 0x1)
- end
- end
- if CG and (CG == 1) then --Reset Garbage Collection to default values
- collectgarbage("setpause",200)
- collectgarbage("setstepmul",200)
- CG = 0
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement