Need Help on my Lua Script to force a certain Value permanently constantly
- dreamcactus
- Expert Cheater
- Posts: 144
- Joined: Sat Jul 06, 2019 12:21 pm
- Reputation: 0
Re: Need Help on my Lua Script to force a certain Value permanently constantly
ok so i tried it ...and no success , even set it up to autoload settings on startup per lua....nothing , dont work , damn it, also its saving is iffy , worked first time ...successive times it wont after exiting and loading and ive selected casual as save slot ...is it the changed lua? im confuse
check it out
[Link]
also havent figured out a autosave current settings on close of CT yet
i also havent seen the force/freeze value function anywhere included yet
check it out
[Link]
also havent figured out a autosave current settings on close of CT yet
i also havent seen the force/freeze value function anywhere included yet
Re: Need Help on my Lua Script to force a certain Value permanently constantly
You don't have any of your addresses starting with "AUTO SET:", so their state won't be saved. If you enable the "This script is not blacklisted ()->" script you'll see some addresses nested under it. Set the ones that have "AUTO SET:" in their descriptions, and their state will be saved.
Like I said, you'll either need to wait for the process to fully load, or use
But keep in mind CE might already be unattached from the process when the main forms on close function is called, if so the state of vales won't save correctly since the values will just return "??". Not really sure, you'll need to do some testing.
Like I said, you'll either need to wait for the process to fully load, or use
OnProcessOpened
. And you don't seem to have any code setup for auto saving, you need to hook the main form's onClose
function so you know when CE is being closed.Code: Select all
local mainForm_formClose = MainForm.OnClose
local function autoSaveOnClose_formClose(sender)
saveTableState('casual')
mainForm_formClose(sender)
end
mainForm.OnClose = autoSaveOnClose_formClose
- dreamcactus
- Expert Cheater
- Posts: 144
- Joined: Sat Jul 06, 2019 12:21 pm
- Reputation: 0
Re: Need Help on my Lua Script to force a certain Value permanently constantly
thanks man , ill get at it , sorry for being so fucking stupid about it all lols....
- dreamcactus
- Expert Cheater
- Posts: 144
- Joined: Sat Jul 06, 2019 12:21 pm
- Reputation: 0
Re: Need Help on my Lua Script to force a certain Value permanently constantly
ok putting Auto set: ..... in front of description did indeed save its state and enable it , BUT now im wondering , and it now autoenables cheats and sets values to said values saved previously , but there gotta be a better solution , else id have a ton of renaming work to do ....for all my CTs , there gotta be a way for it to simply autosave current settings when clickin save on profile without having to put in the Auto Set: prefix , about the autosave function ....get that you have a point about the values not being ok no more once the game exits since its all ??s
also i am yet to see the function for it to freeze values so they dont get changed willy nilly by game
also i am yet to see the function for it to freeze values so they dont get changed willy nilly by game
Re: Need Help on my Lua Script to force a certain Value permanently constantly
You could change the functions to not look for the prefix. Or use a script to add the prefix to the all memory records. But yes CTs require a bit of work.dreamcactus wrote: ↑Wed May 19, 2021 8:18 pmok putting Auto set: ..... in front of description did indeed save its state and enable it , BUT now im wondering , and it now autoenables cheats and sets values to said values saved previously , but there gotta be a better solution , else id have a ton of renaming work to do ....for all my CTs , there gotta be a way for it to simply autosave current settings when clickin save on profile without having to put in the Auto Set: prefix ,
...
Any memory record with the "AUTO SET:" prefix will get it's active state saved as well, so they need to be frozen when you save.dreamcactus wrote: ↑Wed May 19, 2021 8:18 pm...
also i am yet to see the function for it to freeze values so they dont get changed willy nilly by game
- dreamcactus
- Expert Cheater
- Posts: 144
- Joined: Sat Jul 06, 2019 12:21 pm
- Reputation: 0
Re: Need Help on my Lua Script to force a certain Value permanently constantly
ok ...so how do i change it then to not need the prefix then?
Re: Need Help on my Lua Script to force a certain Value permanently constantly
Look for the elseif statement and make it else i guess. But yeah there will likely be some debugging involved, so it's hard to say what the end result would be but that's where I'd start.
- dreamcactus
- Expert Cheater
- Posts: 144
- Joined: Sat Jul 06, 2019 12:21 pm
- Reputation: 0
Re: Need Help on my Lua Script to force a certain Value permanently constantly
uhhhh i dont see it and yes i need your help , im getting nowhere with this, sorry for that
Code: Select all
PROCESS_NAME = 'pcsx2.exe'
--------
-------- Auto Attach
--------
local autoAttachTimer = nil
local autoAttachTimerInterval = 100
local autoAttachTimerTicks = 0
local autoAttachTimerTickMax = 5000
local function autoAttachTimer_tick(timer)
if autoAttachTimerTickMax > 0 and autoAttachTimerTicks >= autoAttachTimerTickMax then
timer.destroy()
end
if getProcessIDFromProcessName(PROCESS_NAME) ~= nil then
timer.destroy()
openProcess(PROCESS_NAME)
getAddressList().getMemoryRecordByDescription("-[ Table States ]- ()->").active=true
getAddressList().getMemoryRecordByDescription("_[ Load Table State ]_").active=true
getAddressList().getMemoryRecordByDescription("Load Table State : Casual ()->").active=true
end
autoAttachTimerTicks = autoAttachTimerTicks + 1
end
autoAttachTimer = createTimer(MainForm)
autoAttachTimer.Interval = autoAttachTimerInterval
autoAttachTimer.OnTimer = autoAttachTimer_tick
Re: Need Help on my Lua Script to force a certain Value permanently constantly
That's not the CT state module, you need to modify it not your auto attach code. The module does the work so that's what has to change. You'll be looking for something like:
elseif mr.Type ~= vtAutoAssembler and mr.Description:sub(1, #svm) == svm then
- dreamcactus
- Expert Cheater
- Posts: 144
- Joined: Sat Jul 06, 2019 12:21 pm
- Reputation: 0
Re: Need Help on my Lua Script to force a certain Value permanently constantly
ok even removing if from elseif from that one line ...i get an error when clicking ok after that ...uhhhhh yeah , so needs some more figuring out please
- dreamcactus
- Expert Cheater
- Posts: 144
- Joined: Sat Jul 06, 2019 12:21 pm
- Reputation: 0
Re: Need Help on my Lua Script to force a certain Value permanently constantly
still would appreciate some help here , thanks
Re: Need Help on my Lua Script to force a certain Value permanently constantly
You need to change it from "elseif ... then" to just "else" with no condition to make it a proper lua if statement.
[Link]
[Link]
- dreamcactus
- Expert Cheater
- Posts: 144
- Joined: Sat Jul 06, 2019 12:21 pm
- Reputation: 0
Re: Need Help on my Lua Script to force a certain Value permanently constantly
ok that didnt work , this is how it looks>
Code: Select all
else mr.Type ~= vtAutoAssembler and mr.Description:sub(1, #svm) == svm
if mr.Value == '??' then
Logger:warnf('Memory record value not set: %d, %d, "%s", "%s"', mr.Index, mr.ID, mr.Description, mr.Value)
if I2CETState.PrintStatus then
printf('Memory record value not set: "%s", "%s"', mr.Description, mr.Value)
end
else
Logger:infof('Setting memory record: %d, %d, "%s", %s, %s', mr.Index, mr.ID, mr.Description, data[1], data[2])
if I2CETState.PrintStatus then
printf('Setting: "%s", %s', mr.Description, data[2])
end
AddressList.setSelectedRecord(mr)
mr.Value = data[2]
if data[3] == tostring(true) then
mr.Active = true
while mr.Async and mr.AsyncProcessing do
checkSynchronize()
MainForm.repaint()
sleep(0)
end
sleep(0)
end
end
end
else
Logger:errorf('Memory record not found: "%s", "%s", "%s"', data[1], data[2], v)
end
end
checkSynchronize()
end
Logger:infof('Table State Loaded: %s', stateName)
if I2CETState.PrintStatus then
printf('Table State Loaded: %s', stateName)
end
I2CETState.CurrentStateName = nil
end
local function loadTableStateThread(thread, stateName)
synchronize(loadTableStateThreadSynced, stateName)
thread.terminate()
end
function I2CETState.loadTableStateT(stateName)
Logger:trace()
I2CETState.CurrentStateName = stateName
createThread(loadTableStateThread, stateName)
end
function I2CETState.loadTableState(stateName)
Logger:trace()
return I2CETState.loadTableStateT(stateName)
end
loadTableState = I2CETState.loadTableState
function I2CETState.setAllScriptsToAsync()
Logger:trace()
for i = 0, AddressList.Count - 1 do
local mr = AddressList.getMemoryRecord(i)
if mr.Type == vtAutoAssembler and not mr.Async then
Logger:infof('Set memory record async: %d, %d, "%s"', mr.Index, mr.ID, mr.Description)
mr.Async = true
end
end
end
function I2CETState.setAllScriptsToNoAsync()
Logger:trace()
for i = 0, AddressList.Count - 1 do
local mr = AddressList.getMemoryRecord(i)
if mr.Type == vtAutoAssembler and mr.Async then
Logger:infof('Set memory record no async: %d, %d, "%s"', mr.Index, mr.ID, mr.Description)
mr.Async = false
end
end
end
------------------------------ DISABLE ------------------------------
[DISABLE]
Re: Need Help on my Lua Script to force a certain Value permanently constantly
ELSE in lua and most languages does not have a condition you still haven't removed the condition. You removed THEN but not the condition, use the link below to see how if statements work in Lua. So again:
- dreamcactus
- Expert Cheater
- Posts: 144
- Joined: Sat Jul 06, 2019 12:21 pm
- Reputation: 0
Re: Need Help on my Lua Script to force a certain Value permanently constantly
ok well that worked, but it wont save values nor enabled cheats now as i can see in the casual.ini ...its empty
and this is how the full code looks>
Code: Select all
else
if mr.Value == '??' then
Logger:warnf('Memory record value not set: %d, %d, "%s", "%s"', mr.Index, mr.ID, mr.Description, mr.Value)
if I2CETState.PrintStatus then
printf('Memory record value not set: "%s", "%s"', mr.Description, mr.Value)
end
else
Logger:infof('Setting memory record: %d, %d, "%s", %s, %s', mr.Index, mr.ID, mr.Description, data[1], data[2])
if I2CETState.PrintStatus then
printf('Setting: "%s", %s', mr.Description, data[2])
end
AddressList.setSelectedRecord(mr)
mr.Value = data[2]
if data[3] == tostring(true) then
mr.Active = true
while mr.Async and mr.AsyncProcessing do
checkSynchronize()
MainForm.repaint()
sleep(0)
end
sleep(0)
end
end
end
else
Logger:errorf('Memory record not found: "%s", "%s", "%s"', data[1], data[2], v)
end
end
checkSynchronize()
end
Logger:infof('Table State Loaded: %s', stateName)
if I2CETState.PrintStatus then
printf('Table State Loaded: %s', stateName)
end
I2CETState.CurrentStateName = nil
end
local function loadTableStateThread(thread, stateName)
synchronize(loadTableStateThreadSynced, stateName)
thread.terminate()
end
function I2CETState.loadTableStateT(stateName)
Logger:trace()
I2CETState.CurrentStateName = stateName
createThread(loadTableStateThread, stateName)
end
function I2CETState.loadTableState(stateName)
Logger:trace()
return I2CETState.loadTableStateT(stateName)
end
loadTableState = I2CETState.loadTableState
function I2CETState.setAllScriptsToAsync()
Logger:trace()
for i = 0, AddressList.Count - 1 do
local mr = AddressList.getMemoryRecord(i)
if mr.Type == vtAutoAssembler and not mr.Async then
Logger:infof('Set memory record async: %d, %d, "%s"', mr.Index, mr.ID, mr.Description)
mr.Async = true
end
end
end
function I2CETState.setAllScriptsToNoAsync()
Logger:trace()
for i = 0, AddressList.Count - 1 do
local mr = AddressList.getMemoryRecord(i)
if mr.Type == vtAutoAssembler and mr.Async then
Logger:infof('Set memory record no async: %d, %d, "%s"', mr.Index, mr.ID, mr.Description)
mr.Async = false
end
end
end
------------------------------ DISABLE ------------------------------
[DISABLE]
Code: Select all
{$lua}
if syntaxcheck then return end
------------------------------ ENABLE ------------------------------
[ENABLE]
local format = string.format
local strE = string.empty or STRING_EMPTY or ''
local t = translate
local printf = function(fmt, ...) return print(format(fmt, ...)) end
if AddressList == nil then
AddressList = getAddressList()
end
--
---- Logger
local Logger = {
LEVELS = {
OFF = 0,
FATAL = 1,
ERROR = 2,
WARN = 3,
INFO = 4,
DEBUG = 5,
TRACE = 6
},
Level = 0,
}
for k, v in pairs(Logger.LEVELS) do
if Logger.Level > 0 then
Logger[k:lower()] = function(self, msg, ex) return print(msg, ex) end
Logger[k:lower()..'f'] = function(self, msg, ... ) return print(string.format(msg, ... )) end
else
Logger[k:lower()] = function(...) return end
Logger[k:lower()..'f'] = function(...) return end
end
end
--
---- Helpers
local function split(s, delimiter)
result = {}
for match in (s .. delimiter):gmatch('(.-)' .. delimiter) do
table.insert(result, match)
end
return result
end
local function interp(s, tbl)
if s == nil then return end
return (s:gsub('($%b{})', function(w) return tbl[w:sub(3, -2)] or w end))
end
--
---- I2CETState
I2CETState = {
--
---- Settings
DefaultState = 'default',
NoneState = 'none',
SaveFileName = 'I2CETState.${StateName}.txt',
UseMemoryRecordDescriptions = false,
LineEnd = '\n',
DisableBeforeLoad = true,
PrintStatus = false,
SaveValueMatch = 'AUTO SET:',
LineDelimiter = '<SEP>',
ScriptID = 'I2CETStateSCRIPTID',
SaveHeaderStates = true,
HeaderID = 'I2CETStateHEADERID',
BlackList = {
['_[ I2CETState ]_'] = true,
['_[ Save Table State ]_'] = true,
['_[ Load Table State ]_'] = true,
['-[ Table States ]- ()->'] = true,
},
SaveTableStateScriptStart = 'Save Table State :',
LoadTableStateScriptStart = 'Load Table State :',
}
local function saveTableStateThread(thread, stateName)
synchronize(function()
Logger:trace()
return
end)
if stateName == I2CETState.NoneState then
synchronize(function()
Logger:infof('None State Used: %s', stateName)
return
end)
if I2CETState.PrintStatus then
synchronize(function()
getLuaEngine().show()
printf('None State Used: %s', stateName)
return
end)
end
return
end
synchronize(function()
Logger:infof('Saving Table State: %s', stateName)
return
end)
if I2CETState.PrintStatus and Logger.Level <= Logger.LEVELS.INFO then
synchronize(function()
getLuaEngine().show()
printf('Saving Table State: %s', stateName)
return
end)
end
local le = I2CETState.LineEnd
local ld = I2CETState.LineDelimiter
local sid = I2CETState.ScriptID
local svm = I2CETState.SaveValueMatch
local hid = I2CETState.HeaderID
if stateName == nil then
stateName = I2CETState.DefaultState
end
local fileName = interp(I2CETState.SaveFileName, { StateName = stateName, ClassName = CLASS_NAME } )
synchronize(function()
Logger:debugf('Using state file: "%s"', fileName)
return
end)
local fileStr = strE
for i = 0, AddressList.Count - 1 do
local mr = AddressList.getMemoryRecord(i)
local stss = I2CETState.SaveTableStateScriptStart
local ltss = I2CETState.LoadTableStateScriptStart
if I2CETState.BlackList[mr.Description] ~= true
and I2CETState.BlackList[mr.ID] ~= true
and mr.Description:sub(0, #stss) ~= stss
and mr.Description:sub(0, #ltss) ~= ltss then
local id = tostring(mr.ID)
if I2CETState.UseMemoryRecordDescriptions then
id = mr.Description
end
if mr.Type == vtAutoAssembler and mr.Active then
synchronize(function()
Logger:debugf('Saving script state: %d, %d, "%s"',
mr.Index, mr.ID, mr.Description)
return
end)
fileStr = fileStr..id..ld..sid..ld..tostring(mr.Active)..le
elseif mr.Description:sub(0, #svm) == svm and mr.Value ~= '??' then
synchronize(function()
Logger:debugf('Saving value state: %d, %d, "%s", %s',
mr.Index, mr.ID, mr.Description, mr.Value)
return
end)
fileStr = fileStr..id..ld..mr.Value..ld..tostring(mr.Active)..le
elseif I2CETState.SaveHeaderStates and mr.IsGroupHeader and mr.Active then
synchronize(function()
Logger:debugf('Saving header state: %d, %d, "%s"',
mr.Index, mr.ID, mr.Description)
return
end)
fileStr = fileStr..id..ld..hid..ld..tostring(mr.Active)..le
end
end
end
local f, err = io.open(fileName, 'w')
if err then
synchronize(function()
Logger:errorf('The file could not be opened, "%s", %s', fileName, err)
return
end)
elseif f and not err then
f:write(fileStr)
f:close()
end
synchronize(function()
Logger:debugf('Table State Saved: %s, "%s"', stateName, fileName)
return
end)
thread.terminate()
end
function I2CETState.saveTableStateT(stateName)
Logger:trace()
createThread(saveTableStateThread, stateName)
end
function I2CETState.saveTableState(stateName)
Logger:trace()
return I2CETState.saveTableStateT(stateName)
end
saveTableState = I2CETState.saveTableState
local function loadTableStateThreadSynced(stateName)
Logger:trace()
if I2CETState.PrintStatus then
getLuaEngine().show()
end
Logger:infof('Setting Table State: %s', stateName)
if I2CETState.PrintStatus then
getLuaEngine().show()
printf('Setting Table State: %s', stateName)
end
local le = I2CETState.LineEnd
local ld = I2CETState.LineDelimiter
local sid = I2CETState.ScriptID
local svm = I2CETState.SaveValueMatch
local hid = I2CETState.HeaderID
if stateName == nil then
stateName = I2CETState.DefaultState
end
local fileName = interp(I2CETState.SaveFileName, { StateName = stateName, ClassName = CLASS_NAME } )
Logger:debugf('Using state file name: "%s"', fileName)
local fileStr = nil
if stateName == I2CETState.NoneState then
fileStr = strE
else
local f, err = io.open(fileName, 'r')
if err then
Logger:infof('The local file could not be opened, "%s", %s', fileName, err)
local tableFile = findTableFile(fileName)
if tableFile == nil then
Logger:warnf('file not found, "%s"', fileName)
return
end
local stream = tableFile.getData()
local bytes = stream.read(stream.Size)
for i = 1, #bytes do
if fileStr == nil then
fileStr = strE
end
fileStr = fileStr .. string.char(bytes[i])
end
elseif f and not err then
fileStr = f:read('*all')
f:close()
else
Logger:errorf('The file could not be opened, "%s"', fileName)
end
end
if I2CETState.DisableBeforeLoad then
for i = AddressList.Count - 1, 0, -1 do
local mr = AddressList.getMemoryRecord(i)
local stss = I2CETState.SaveTableStateScriptStart
local ltss = I2CETState.LoadTableStateScriptStart
if I2CETState.BlackList[mr.Description] ~= true
and I2CETState.BlackList[mr.ID] ~= true
and mr.Description:sub(0, #stss - 1) ~= stss
and mr.Description:sub(0, #ltss - 1) ~= ltss then
if mr.Active then
Logger:infof('Disabling memory record: %d, %d, "%s"', mr.Index, mr.ID, mr.Description)
if I2CETState.PrintStatus then
printf('Disabling: %s', mr.Description)
end
AddressList.setSelectedRecord(mr)
mr.Active = false
while mr.Async and mr.AsyncProcessing do
checkSynchronize()
MainForm.repaint()
sleep(0)
end
sleep(0)
end
end
end
sleep(0)
end
if fileStr == nil then
Logger:info('File string was nil')
return
end
local lines = split(fileStr, I2CETState.LineEnd)
for i, v in ipairs(lines) do
if v ~= nil and v ~= strE then
local data = split(v, I2CETState.LineDelimiter)
local mr = nil
if I2CETState.UseMemoryRecordDescriptions then
mr = AddressList.getMemoryRecordByDescription(data[1])
else
mr = AddressList.getMemoryRecordByID(tonumber(data[1]))
end
if mr ~= nil then
if (mr.Active == false and data[3] == tostring(true))
and ( (mr.Type == vtAutoAssembler and data[2] == sid)
or (I2CETState.SaveHeaderStates and mr.IsGroupHeader and data[2] == hid) ) then
Logger:infof('Enabling memory record: %d, %d, "%s"', mr.Index, mr.ID, mr.Description)
if I2CETState.PrintStatus then
printf('Enabling: %s', mr.Description)
end
AddressList.setSelectedRecord(mr)
mr.Active = true
while mr.Async and mr.AsyncProcessing do
checkSynchronize()
MainForm.repaint()
sleep(0)
end
sleep(0)
else
if mr.Value == '??' then
Logger:warnf('Memory record value not set: %d, %d, "%s", "%s"', mr.Index, mr.ID, mr.Description, mr.Value)
if I2CETState.PrintStatus then
printf('Memory record value not set: "%s", "%s"', mr.Description, mr.Value)
end
else
Logger:infof('Setting memory record: %d, %d, "%s", %s, %s', mr.Index, mr.ID, mr.Description, data[1], data[2])
if I2CETState.PrintStatus then
printf('Setting: "%s", %s', mr.Description, data[2])
end
AddressList.setSelectedRecord(mr)
mr.Value = data[2]
if data[3] == tostring(true) then
mr.Active = true
while mr.Async and mr.AsyncProcessing do
checkSynchronize()
MainForm.repaint()
sleep(0)
end
sleep(0)
end
end
end
else
Logger:errorf('Memory record not found: "%s", "%s", "%s"', data[1], data[2], v)
end
end
checkSynchronize()
end
Logger:infof('Table State Loaded: %s', stateName)
if I2CETState.PrintStatus then
printf('Table State Loaded: %s', stateName)
end
I2CETState.CurrentStateName = nil
end
local function loadTableStateThread(thread, stateName)
synchronize(loadTableStateThreadSynced, stateName)
thread.terminate()
end
function I2CETState.loadTableStateT(stateName)
Logger:trace()
I2CETState.CurrentStateName = stateName
createThread(loadTableStateThread, stateName)
end
function I2CETState.loadTableState(stateName)
Logger:trace()
return I2CETState.loadTableStateT(stateName)
end
loadTableState = I2CETState.loadTableState
function I2CETState.setAllScriptsToAsync()
Logger:trace()
for i = 0, AddressList.Count - 1 do
local mr = AddressList.getMemoryRecord(i)
if mr.Type == vtAutoAssembler and not mr.Async then
Logger:infof('Set memory record async: %d, %d, "%s"', mr.Index, mr.ID, mr.Description)
mr.Async = true
end
end
end
function I2CETState.setAllScriptsToNoAsync()
Logger:trace()
for i = 0, AddressList.Count - 1 do
local mr = AddressList.getMemoryRecord(i)
if mr.Type == vtAutoAssembler and mr.Async then
Logger:infof('Set memory record no async: %d, %d, "%s"', mr.Index, mr.ID, mr.Description)
mr.Async = false
end
end
end
------------------------------ DISABLE ------------------------------
[DISABLE]
Who is online
Users browsing this forum: No registered users