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 


injecting code and save ECX in a variable without use debug
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
danrevella
Master Cheater
Reputation: 2

Joined: 11 Jun 2008
Posts: 290

PostPosted: Sat Dec 19, 2015 2:39 pm    Post subject: Reply with quote

I have try till now......
Seems to be I have done all in the right way, my aa script I have incorporated to subst the demo you have put being executed, the table is populated with the right adress, but the table is NOT freezed...

I would like you try with my prog+my tables directelly.....
Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 55

Joined: 01 Oct 2008
Posts: 942

PostPosted: Sat Dec 19, 2015 3:23 pm    Post subject: Reply with quote

danrevella wrote:
I have try till now......
Seems to be I have done all in the right way, my aa script I have incorporated to subst the demo you have put being executed, the table is populated with the right adress, but the table is NOT freezed...

I would like you try with my prog+my tables directelly.....



The browser prevent me download the mtc127 for malicious detected.
Could you check the small test prog at https://www.virustotal.com/ and if safe, attach the files(prog + table, may zipped) in a cheat table .ct 's "table file" (menu>table>add file), and attach the *.ct in forum post?
Thanks~

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

Joined: 11 Jun 2008
Posts: 290

PostPosted: Sat Dec 19, 2015 3:53 pm    Post subject: Reply with quote

Il file è già stato analizzato

This file was last analysed by VirusTotal on 2015-12-11 12:57:18 UTC (1 settimana, 1 giorno ago) it was first analysed by VirusTotal on 2007-02-26 15:41:07 UTC.

Rapporto rilevamento: 0/54

Puoi dare un'occhiata all'ultima analisi oppure rianalizzare ora.

I think is a false positive...
Mtc127 was a program like CE for Win98, it does not run on modern version of windows, this may cause the fake positive.
BTW, I have just analized only the small test.exe I use, and on top of this post I have copied the analisys result.
Now prepare tables+file
Only a few minutes, please

here is the link for test.rar with test.exe + my AA and Lua table

https://www.sendspace.com/file/lknhzs
Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 55

Joined: 01 Oct 2008
Posts: 942

PostPosted: Sat Dec 19, 2015 8:21 pm    Post subject: Reply with quote

I modify the Lua script a bit, basically is to assure there is no error to stop timer.
Previous script cause error by using some 'nil' address, and the print-format-boxtofreeze statement.
Now, the write should be made only when the related address is valid.

Code:
t.OnTimer=function(t)
   ////   _myforce may point to nothing, which readInteger will return 'nil', need to assure this before further execute
    if readInteger("_myforce")~=nil and readInteger("_myforce") ~= 0 then
      t.Enabled = false
    --execute the rest of your lua here
print ("Now execute") --This is shoved also first time
AL = getAddressList()
boxtofreeze = AL.getMemoryRecordByDescription("[_myforce] tra parentesi")--nome tabella
print ("Now execute boxtofreeze") --This is shoved also first time

memoryrecord_unfreeze(boxtofreeze)

vartofreeze = readInteger("_myforce")  //// use readInteger to read content of _myforce,      getAddress will cause error if not valid
if vartofreeze ~= nil then   //// dont continue if no valid address, since it may cause error and stop the timer
  writeInteger(vartofreeze,98)
  print( string.format( '%s', memoryrecord_getValue(boxtofreeze)) );
//// print-format fixed
  memoryrecord_freeze(boxtofreeze)-- this is executed Only the second time i click on Execute scrip on Lua table
end
--boxtofreeze.Active = true

  end
end
t.Enabled=true

[DISABLE]
--//code from here till the end of the code will be used to disable the cheat
--{$LUA}
memoryrecord_unfreeze(boxtofreeze)

object_destroy(t)
t = nil    //// to kill the timer as we want


bye~

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

Joined: 11 Jun 2008
Posts: 290

PostPosted: Sun Dec 20, 2015 5:35 am    Post subject: Reply with quote

Hi!
Sorry but problem is still not solved:
value is upgraded to 98, but table is NOT freezed.

memoryrecord_freeze(boxtofreeze)-- this is executed Only the second time i click on Execute scrip on Lua table

I think we have to introduce also a check to see if boxtofreeze is valid, but I don't know how...

memoryrecord_freeze ??? How does work this function, give a return data we may control if it's valid? where is documented? I read main.lua but I don't found it....

WHY DON'T FREEZE??? grrrrrr Sad Sad Sad Crying or Very sad

But if I check the script to be executed a second time, it does work..

here is the Lua engine output:
-----first execution
Now execute
Now execute boxtofreeze
??
-----second execution
Now execute
Now execute boxtofreeze
98

Here is my edited table with your suggestions:


Code:
{$LUA}
[ENABLE]
--//code from here to '[DISABLE]' will be used to enable the cheat
if syntaxcheck then return end
t=createTimer(nil, false)
t.Interval=1000
t.OnTimer=function(t)
   --////   _myforce may point to nothing, which readInteger will return 'nil', need to assure this before further execute
    if readInteger("_myforce")~=nil and readInteger("_myforce") ~= 0 then
      t.Enabled = false
    --execute the rest of your lua here
print ("Now execute") --This is shoved also first time
AL = getAddressList()
boxtofreeze = AL.getMemoryRecordByDescription("[_myforce] tra parentesi")--nome tabella
print ("Now execute boxtofreeze") --This is shoved also first time

memoryrecord_unfreeze(boxtofreeze)

vartofreeze = readInteger("_myforce") -- //// use readInteger to read content of _myforce,      getAddress will cause error if not valid
if vartofreeze ~= nil then   --//// dont continue if no valid address, since it may cause error and stop the timer
  writeInteger(vartofreeze,98)
  print( string.format( '%s', memoryrecord_getValue(boxtofreeze)) );
--//// print-format fixed
  memoryrecord_freeze(boxtofreeze)-- this is executed Only the second time i click on Execute scrip on Lua table
end
--boxtofreeze.Active = true

  end
end
t.Enabled=true

[DISABLE]
--//code from here till the end of the code will be used to disable the cheat
--{$LUA}
memoryrecord_unfreeze(boxtofreeze)

object_destroy(t)
t = nil    --//// to kill the timer as we want
Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 55

Joined: 01 Oct 2008
Posts: 942

PostPosted: Sun Dec 20, 2015 7:44 am    Post subject: This post has 1 review(s) Reply with quote

danrevella wrote:
Hi!
Sorry but problem is still not solved:
value is upgraded to 98, but table is NOT freezed.

memoryrecord_freeze(boxtofreeze)-- this is executed Only the second time i click on Execute scrip on Lua table

I think we have to introduce also a check to see if boxtofreeze is valid, but I don't know how...

memoryrecord_freeze ??? How does work this function, give a return data we may control if it's valid? where is documented? I read main.lua but I don't found it....

WHY DON'T FREEZE??? grrrrrr Sad Sad Sad Crying or Very sad

But if I check the script to be executed a second time, it does work..

here is the Lua engine output:
-----first execution
Now execute
Now execute boxtofreeze
??
-----second execution
Now execute
Now execute boxtofreeze
98

Here is my edited table with your suggestions:


Code:
{$LUA}
[ENABLE]
...
t.Interval=1000
t.OnTimer=function(t)
   --////   _myforce may point to nothing, which readInteger will return 'nil', need to assure this before further execute
    if readInteger("_myforce")~=nil and readInteger("_myforce") ~= 0 then
////     t.Enabled = false
    --execute the rest of your lua here
print ("Now execute") --This is shoved also first time
AL = getAddressList()
...


I guess 't.Enabled = false' need to be comment out.

The idea is for the timer continually run until manually de-activated.

The timer check if the target address is valid, or may added that if the value at target address met some condition, eg. at least 98. If under some condition, the timer act accordingly.

For example,
if address is not valid, do nothing;
if address is valid, but value is below 98, then write 98 to the address;
if address is valid, value is equal or more than 98, then do nothing;
etc.

Given this continuing timer/checker setup, you don't need to 'freeze' the target address. What 'freeze' means is CE will set a fixed value into a valid address periodically, which more or less same as our timer do, but not as flexible as our self-made timer with custom conditional check and action.

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

Joined: 11 Jun 2008
Posts: 290

PostPosted: Sun Dec 20, 2015 9:06 am    Post subject: Reply with quote

panraven wrote:

Given this continuing timer/checker setup, you don't need to 'freeze' the target address. What 'freeze' means is CE will set a fixed value into a valid address periodically, which more or less same as our timer do, but not as flexible as our self-made timer with custom conditional check and action.

Many thanks for all your patience!!!
There's no doubt, your is a clever argoument, I agree, and in future I'll work in that direction, many thanks.
BTW,
CE is not only a software for advanced user, but also newbie may utilize it, so why is so difficult take care of a (not so advanced) task involving the follows:
-i have found the address of my data base of game parameter
-i only request that my relative table are auto-filled and auto-freezed
Even worse:
why memoryrecord_unfreeze is not documented in main.lua?

About this argoument BTW, I'll open a new thread as soon I'll be able in replicate the problem with the CE "Tutorial-i386.exe", so people may be able in experiment directelly.

Thank you!!
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sun Dec 20, 2015 11:47 am    Post subject: Reply with quote

Different approach. I added Lua scripts separately.

"freeze/unfreeze all (with lua timer)"
It waits for symbol 'myforce' and checks the first memoryrecord (ShieldUp) for valid value.
Code:
if ShieldUpMR.Value=='??' then return end



Then it sets value to 999 and freeze memoryrecords below.
Code:
   ShieldUpMR.Value = 999
   ShieldUpMR.Active = true
   ShieldDownMR.Value = 999
   ShieldDownMR.Active = true
   PowerLaserUpMR.Value = 999
   PowerLaserUpMR.Active = true
   PowerLaserDownMR.Value = 999
   PowerLaserDownMR.Active = true




You can copy and paste Lua blocks to your script, enable section to enable section, disable section to disable section.

The only thing you have to do is to adjust some blocks if you need more records.
(look for "-- adjust those" comments)





There is also "(with lua thread)" version I made just for fun. Does the same thing.



XWINGALLIANCE.CT
 Description:

Download
 Filename:  XWINGALLIANCE.CT
 Filesize:  5.14 KB
 Downloaded:  803 Time(s)


_________________
Back to top
View user's profile Send private message MSN Messenger
danrevella
Master Cheater
Reputation: 2

Joined: 11 Jun 2008
Posts: 290

PostPosted: Sun Dec 20, 2015 1:05 pm    Post subject: Reply with quote

mgr.inz.Player wrote:
Different approach. I added Lua scripts separately.

"freeze/unfreeze all (with lua timer)"
It waits for symbol 'myforce' and checks the first memoryrecord (ShieldUp) for valid value.
Code:
if ShieldUpMR.Value=='??' then return end


Thanks for this different approach, but the problem is that I don't know what value I have to put coz the game may always start-restart with an unknow value.
Or maybe (as always Wink ) I have miserestand your info?
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sun Dec 20, 2015 4:21 pm    Post subject: Reply with quote

you wrote:
Quote:
My problem is not so complicate (in theory).
I have found that my AA script is able in retrieving the beginning of a data structure ("myforce" is where begin), so I have setted a certain number of CE tables that simple point to "myforce". f.e.
shield up = [myforce]+2
shield down = [myforce]+4
power laser up = [myforce]+8
power laser down = [myforce]+0a
etc........
All I want is that when my AA script being activate, and the game land on it ----> "myforce" assume the right value, so now:
I would like that in automatich these tables:
shield up = [myforce]+2 ------------- --->auto set to: 9999
shield down = [myforce]+4 -------------->auto set to: 9999
power laser up = [myforce]+8----------->auto set to: 45
power laser down = [myforce]+0a------>auto set to: 45
Then ALL these table have to be freezed




"so I have setted a certain number of CE tables that simple point to "myforce""
you meant
"so I have setted a certain number of memory records that simple point to "myforce""



""myforce" assume the right value, so now: I would like that in automatich these tables"
you meant
""myforce" assume the right value (myforce exist and is not zero), so now: I would like that in automatich these memory records"



"Then ALL these table have to be freezed"
you meant
"Then ALL these memory records have to be freezed"



panraven and mine scripts just do this.



Well, mine sets all to 999, you wanted 9999 and 45, but, you can edit it.

_________________
Back to top
View user's profile Send private message MSN Messenger
danrevella
Master Cheater
Reputation: 2

Joined: 11 Jun 2008
Posts: 290

PostPosted: Sun Dec 20, 2015 5:07 pm    Post subject: Reply with quote

This is enough clear mate,
but in your Lua Timer based script you wrote:
Code:
FreezeTimerFunc =
 function (timer)
   if ShieldUpMR.Value=='??' -- adjust this line
   then return end           -- (the first memrec should be fine)

-- (the first memrec should be fine)
here I don't understand value of first memrec, is it the value the memory location does assume inside the game? But if it is so I'm unable in know it, at least withot f.e. pause the game (but this game may not be paused coz it crash) or other....

BTW, after solved this problem, I even need you came to my home to play the game with me........ coz even with unlimited shield and missiles I'm unable in complete the mission..... Crying or Very sad

How much were simples the time of dos...... Wink
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Mon Dec 21, 2015 3:15 am    Post subject: Reply with quote

Code:
if ShieldUpMR.Value=='??' -- adjust this line

You were right, it is not clear enough.


I meant, adjust the bold text, in case you want to use my script in other games and you have different memory records:
if ShieldUpMR.Value=='??' -- adjust this line


Maybe you noticed that memory records shows ?? when pointer base not exists, or is not set, or has wrong value. So, here is the trick, I use "memoryrecord.value" check instead of a few "readInteger('myforce')" checks.

_________________
Back to top
View user's profile Send private message MSN Messenger
danrevella
Master Cheater
Reputation: 2

Joined: 11 Jun 2008
Posts: 290

PostPosted: Mon Dec 21, 2015 3:59 am    Post subject: Reply with quote

Ok, in fact while was experimented lua code I have seen the (non) value "??"
A clever trick!!!

Now it is all clear.

BTW, my dream will be a real debugger for LUA, the actual is much limited..
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Tue Dec 22, 2015 4:32 am    Post subject: Reply with quote

Simple Lua debugger is in Lua Engine window. It is limited, but, you can copy paste some part of code and test it there.
_________________
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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