Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Extracting Line From Text Memo?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Majin
Advanced Cheater
Reputation: 0

Joined: 04 May 2016
Posts: 86

PostPosted: Thu May 18, 2017 11:52 am    Post subject: Extracting Line From Text Memo? Reply with quote

I've a script that should be fairly simple. It functions as follows:

When activated,
Find specific table entries by their description
Assign them to an array - arrayRecords
Assign their values to a string array - arrayRecordStrings
Write the string array to a memo
Show the memo

When deactivated,
Hide the memo
Assign the memo to a string array, line by line - arrayMemoRecordStrings
Write the array's string values to the table entries through the arrayRecords array.


It all works as intended, right up until the end of the script, where it writes the memo's lines to the memory records. The for loop will only run one time, and the script will be stuck in the activated state (can't click off the red cross in the table's checkbox). So I'm probably doing something wrong.

Here's the script, with the problem part in bold:

Quote:

[ENABLE]

{$lua}

--if not syntaxcheck then

windowMemo.memoRecordValues.Lines.Clear()

windowMemoFaceData.memoFaceData.Lines.Clear()

-- Get the memory records
listAddresses = getAddressList()

dwLastBonfire = listAddresses.getMemoryRecordByDescription('DWord - Last Bonfire')

strCharName = listAddresses.getMemoryRecordByDescription('String - Character Name')

byEmbered = listAddresses.getMemoryRecordByDescription('Byte - Embered')

dwNGCounter = listAddresses.getMemoryRecordByDescription('DWord - NG+ Counter')

dwCurrentCov = listAddresses.getMemoryRecordByDescription('DWord - Current Covenant')

byMaxReinforce = listAddresses.getMemoryRecordByDescription('Byte - Max Reinforce Level')

aobPlayerStats = listAddresses.getMemoryRecordByDescription('AOB - Player Stats')
aobPlayerAttr01 = listAddresses.getMemoryRecordByDescription('AOB - Player Attributes 01')
aobPlayerAttr02 = listAddresses.getMemoryRecordByDescription('AOB - Player Attributes 02')

byClass = listAddresses.getMemoryRecordByDescription('Byte - Class')

aobEquippedGear = listAddresses.getMemoryRecordByDescription('AOB - Equipped Gear')
aobEquippedSpells = listAddresses.getMemoryRecordByDescription('AOB - Equipped Spells')
aobEquippedGestures = listAddresses.getMemoryRecordByDescription('AOB - Equipped Gestures')
aobUnlockedGestures = listAddresses.getMemoryRecordByDescription('AOB - Unlocked Gestures')

aobUnlockedEstus = listAddresses.getMemoryRecordByDescription('AOB - Unlocked Max Estus')


--create arrays
arrayRecords = {
dwLastBonfire,
strCharName,
byEmbered,
dwNGCounter,
dwCurrentCov,
byMaxReinforce,
aobPlayerStats,
aobPlayerAttr01,
aobPlayerAttr02,
byClass,
aobEquippedGear,
aobEquippedSpells,
aobEquippedGestures,
aobUnlockedGestures,
aobUnlockedEstus
}

arrayRecordStrings = {
dwLastBonfire.Value,
strCharName.Value,
byEmbered.Value,
dwNGCounter.Value,
dwCurrentCov.Value,
byMaxReinforce.Value,
aobPlayerStats.Value,
aobPlayerAttr01.Value,
aobPlayerAttr02.Value,
byClass.Value,
aobEquippedGear.Value,
aobEquippedSpells.Value,
aobEquippedGestures.Value,
aobUnlockedGestures.Value,
aobUnlockedEstus.Value
}
iRecordStringsCount = 15 -- Easier to keep track of the array size


iCounter = 1

for iCounter = 1,iRecordStringsCount do -- Add the array values to a memo
windowMemo.memoRecordValues.Lines.Add(arrayRecordStrings[iCounter])
end

windowMemo.Show()



scriptFacegenBackup = listAddresses.getMemoryRecordByDescription('Script - Save + Restore Current FaceData')

aobFaceData01 = listAddresses.getMemoryRecordByDescription('AOB - Facedata 01')
aobFaceData02 = listAddresses.getMemoryRecordByDescription('AOB - Facedata 02')
aobFaceData03 = listAddresses.getMemoryRecordByDescription('AOB - Facedata 03')
aobFaceData04 = listAddresses.getMemoryRecordByDescription('AOB - Facedata 04')

arrayFaceRecords = {
aobFaceData01,
aobFaceData02,
aobFaceData03,
aobFaceData04
}


scriptFacegenBackup.Active = true -- enable the facegen backup script

arrayFaceRecordStrings = {
aobFaceData01.Value,
aobFaceData02.Value,
aobFaceData03.Value,
aobFaceData04.Value
}
iFaceDataRecordsCount = 4


for iCounter = 1,iFaceDataRecordsCount do
windowMemoFaceData.memoFaceData.Lines.Add(arrayFaceRecordStrings[iCounter])
end

windowMemoFaceData.Show()


--end
{$asm}

[DISABLE]

{$lua}

--if not syntaxcheck then

windowMemo.Hide()
windowMemoFaceData.Hide()

arrayMemoRecordStrings = windowMemo.memoRecordValues.Lines
arrayMemoFaceDataStrings = windowMemoFaceData.memoFaceData.Lines

for iCounter = 1,iRecordStringsCount do
sleep(0.05)
ShowMessage(arrayMemoRecordStrings[iCounter])
arrayRecords[iCounter].Value = arrayMemoRecordStrings[iCounter]
end


for iCounter = 1,iFaceDataRecordsCount do
sleep(0.05)
arrayFaceRecords[iCounter].Value = arrayMemoFaceDataStrings[iCounter]
end



scriptFacegenBackup.Active = false

windowMemo.memoRecordValues.Lines.Clear()

windowMemoFaceData.memoFaceData.Lines.Clear()


{$asm}
--end
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 332

Joined: 09 May 2003
Posts: 19631
Location: The netherlands

PostPosted: Fri May 19, 2017 5:28 am    Post subject: Reply with quote

execute that lua script inb the lua engine window after enabling the cheat entry
it may tell you what's wrong

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Back to top
View user's profile Send private message MSN Messenger
Majin
Advanced Cheater
Reputation: 0

Joined: 04 May 2016
Posts: 86

PostPosted: Fri May 19, 2017 1:29 pm    Post subject: Reply with quote

Dark Byte wrote:
execute that lua script inb the lua engine window after enabling the cheat entry
it may tell you what's wrong


It just says:

Code:
Error:"TestName" is an invalid float
Script Error


TestName being the name of the character. The message box shown in first execution of the for loop shows the name as well.

The weird part is that it shouldn't be trying to set the value of the name cheat entry on the first iteration. It should be setting the 4-byte value of dwLastBonfire, as that is the first value in the arrayRecords array variable.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites