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 


Script 'create/remove' mem_records behaves oddly... [Solved]

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Discussions
View previous topic :: View next topic  
Author Message
paul44
Expert Cheater
Reputation: 2

Joined: 20 Jul 2017
Posts: 190

PostPosted: Thu Oct 08, 2020 4:43 am    Post subject: Script 'create/remove' mem_records behaves oddly... [Solved] Reply with quote

Prenote: the script seems to do its job nicely, just a bit ackwardly. Meaning: just looking for some explanation and/or "clean up".

Anyways: see intro here: [ https://imgur.com/a/sT6PrrK ].
2 issues:
1. closing the script - using [ok] - gives me that error, but besides that, the script runs fine. I picked up most of the code from this forum, and can't seem to pinpoint the problem here. basically: would feel more comfortable if I can "remove" that error altogether (i am like that Cool)
2. the script does remove the mem-records upon disabling it, but does that in fases. and as long as an entry remains, the script does not disable.
Which I certainly do not mind, if no practical solution can be found. I already tell them that they can also manually delete those entries anyway...

ps: done for AC3/4/5 tables.


Last edited by paul44 on Tue Oct 13, 2020 12:50 am; edited 1 time in total
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 468

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

PostPosted: Thu Oct 08, 2020 7:46 am    Post subject: Reply with quote

when the script is checked if it works, the enable and disable lua scripts both get executed
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
panraven
Grandmaster Cheater
Reputation: 61

Joined: 01 Oct 2008
Posts: 958

PostPosted: Thu Oct 08, 2020 2:07 pm    Post subject: Reply with quote

When a memory record of index i is destroyed, its place will be replaced by memory record index i+1, and so is higher index.
Let's see what happened in your for-loop with 7 mr to destroy.
Code:

for-loop-Counter [index1] Description1 [index2] Description2
---
0 [0]mr1 [1]mr2 [2]mr3 [3]mr4 [4]mr5 [5]mr6 [6]mr7
1 [0]mr2 [1]mr3 [2]mr4 [3]mr5 [4]mr6 [5]mr7
2 [0]mr2 [1]mr4 [2]mr5 [3]mr6 [4]mr7
3 [0]mr2 [1]mr4 [2]mr6 [3]mr7
4 [0]mr2 [1]mr4 [2]mr6      --> mr[4] is nil, so mr[4].VarType cause the error.


Possible remedy,
1. count the for-loop from mr.Count-1 to 0, or
2. always destroy the 1st mr, ie. mr[0].Destroy() < ADDED, not applied to your case as there is other test >

_________________
- Retarded.
Back to top
View user's profile Send private message
paul44
Expert Cheater
Reputation: 2

Joined: 20 Jul 2017
Posts: 190

PostPosted: Fri Oct 09, 2020 2:29 am    Post subject: Both issues solved Reply with quote

thx to both. I will close this 'incident' once I got everything documented on "paper", and have updated this post accordingly...
@panraven: I have taken your 1st suggestion; 2nd one did not act as expected (surely because of the vtbyte entry, and the index value it has/gets)

I do have another request related to this:
aobscans tend to "hang" for several seconds (10-15s are no exception with x64 games, depending its specific task(s)). And all the while, gamer thinks s/he did something wrong?! hence my additional remarks in the table...
(it is not just "beginners": I then tend to open the script to get an idea about what it is trying to do here Shocked)
Anyway: I looked at the 'memoryrecord' again, and noticed the 'Options' property. I thought it to be an "on/off" flag, but that does not seem to be the case (or it is because I try to do this within the "executing script")?

My endgoal actually would/should be: [ https://imgur.com/a/esRx9Ni ]. Basically: upon enabling the script, it gets "unhidden" (this is already an indication to the gamer that the script is 'active'). Adding the additional "processing..." entry would just be the proverbial cherry Smile
Note: that this must execute BEFORE the aobscan, or it is all for naught...

ps: I have not tried that yet - just got the idea now - but it could work with a main "unhide" script; which then calls the 'ship battle' script...?
Back to top
View user's profile Send private message
paul44
Expert Cheater
Reputation: 2

Joined: 20 Jul 2017
Posts: 190

PostPosted: Tue Oct 13, 2020 12:49 am    Post subject: cleaning up... Reply with quote

as per suggestions:
1. checking if mr[i] is not nil, removes the [Ok] error.
2. deleting mr records "backwards" gets it done cleanly.

[code] for i=mr.Count-1,0,-1 do
-- check header line comment: do not delete
if (mr[i].VarType ~= 'vtByte') then
--memoryrecord_delete(mr[i])
if (mr[i] ~= nil) then
mr[i].destroy()
end
end
end[/code]
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Discussions 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