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 


lua value of type "double" help need

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

Joined: 15 Jan 2014
Posts: 60
Location: Croatia

PostPosted: Mon Feb 24, 2014 12:33 pm    Post subject: lua value of type "double" help need Reply with quote

i am read and search all day on forum and i cant figured how to make Lua script from this:

-Scan Type: Exact Value
-Value Type: Double
-Writeable : is Unchecked
-Value example: 1.0
-After First Scan all address marked and change value to "0" (zero)

thank you for help.
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 Feb 24, 2014 5:37 pm    Post subject: Reply with quote

and rounding type ?


For scanning you need:
- MemScan object, created with createMemScan()
firstScan method (from MemScan )
nextScan method (from MemScan ) (if needed)



- FoundList object, created with createFoundList()
waitTillDone() method (from MemScan )
initialize() method (from FoundList )


at the end you need "for-do-end" loop.

_________________
Back to top
View user's profile Send private message MSN Messenger
hondafrik
Advanced Cheater
Reputation: 0

Joined: 15 Jan 2014
Posts: 60
Location: Croatia

PostPosted: Tue Feb 25, 2014 2:47 am    Post subject: Reply with quote

ok bro thx,you show me what i need and i will try combinate commands from here:
Code:
http://cheat-engine.googlecode.com/svn/trunk/Cheat%20Engine/bin/main.lua


Edit:
i am combinate code somehow,and i get error and i dont understand where i put zero to change value of results:
Code:
CEToLua = createForm()
   CEToLua.height = 100
   CEToLua.width = 240
   CEToLua.caption = "Double scan"
   CEToLua.centerScreen()
   CEToLuaButton = createButton(CEToLua)
   CEToLuaButton.caption = "Enable"
   CEToLuaButton.height = 20
   CEToLuaButton.width = 60
   CEToLuaButton.top = 31
   CEToLuaButton.left = 100
   CEToLuaButton.onClick = function ()
memScan = createMemScan()
 createFoundList(memScan)
memscan_firstScan(soExactValue, vtDouble, rtTruncated, "1.000000", "0" ,'0', '7fffffff',"-C" ,fsmNotAligned ,false ,false ,false, false, false);
memscan_waitTillDone(memScan)
  foundlist_initialize()
  end



scan method.jpg
 Description:
 Filesize:  119.31 KB
 Viewed:  13948 Time(s)

scan method.jpg


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 Feb 25, 2014 8:48 am    Post subject: Reply with quote

This will replace all 143.421 with 1234.5
in memory block with readonly protection flag.

Code:
function findDoubleValueAndReplace(findValue, replaceWith)
  memscan = createMemScan()
  foundlist = createFoundList(memscan)
  protectionflags = "-W*X-C"

  -- firstScan(scanoption, vartype, roundingtype, input1, input2,
  --           startAddress, stopAddress, protectionflags,
  --           alignmenttype, "alignmentparam",
  --           isHexadecimalInput, isNotABinaryString, isunicodescan, iscasesensitive)

  --    scanOption: soUnknownValue, soExactValue, soValueBetween, soBiggerThan, soSmallerThan
  --    vartype: vtByte, vtWord, vtDword, vtQword, vtSingle, vtDouble, vtString,
  --             vtByteArray, vtGrouped, vtBinary, vtAll
  --    roundingtype: rtRounded, rtTruncated, rtExtremerounded
  --    alignmenttype: fsmNotAligned, fsmAligned, fsmLastDigits
  --    protectionflags: X W C   (+ to indicate that flag MUST be set, - MUST NOT, * whatever)

  memscan.firstScan(soExactValue, vtDouble, rtTruncated, findValue, nil,
               "0","7fffffff",protectionflags,
               fsmAligned,"4",
               false, false, false, false)
  memscan.waitTillDone()
  foundlist.initialize()

  for i=0,foundlist.Count-1 do
   fullAccess(  getAddress(foundlist.Address[i])  , 8)
   writeDouble(  foundlist.Address[i], replaceWith)
  end

  sleep(50)
  foundlist.destroy()
  sleep(50)
  memscan.destroy()

end

function doit()
  findDoubleValueAndReplace(143.421, 1234.5)
end

myForm = createForm()
myForm.OnClose = function () return caFree end
myForm.height = 100
myForm.width = 240
myForm.caption = "Double scan"
myForm.centerScreen()

myButton = createButton(myForm)
myButton.caption = "do it"
myButton.height = 20
myButton.width = 60
myButton.top = 31
myButton.left = 100
myButton.onClick = doit

_________________
Back to top
View user's profile Send private message MSN Messenger
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 Mar 03, 2014 4:08 pm    Post subject: Reply with quote

hondafrik wrote:
hi bro,i cant understand that code what you show me in post,i am copy all code and my game is freeze,then i am try to combinate protectionflags and nothing again.can you make script from this when you have time:

-Scan Type: Exact Value
-Value Type: Double
-Writeable : is Unchecked
-Value : 1.000000
-After First Scan all address marked and change value to zero

big thx bro Smile



Look again at findDoubleValueAndReplace function, there is:
protectionflags = "-W*X-C"


So, maybe you need this:
protectionflags = "-W*X+C"

or this:
protectionflags = "-W*X*C"

Also, be careful with floating-point values (float, double). Scanning for "1, type double" will also find:
- 1.02
- 1.5
- 1.0725
- and if you are using roundingtype anything except rtTruncated, it will find 0.7


From Cheat Engine Help file:
Quote:
roundingtype: Defined the way scans for exact value floating points are handled

rtRounded : Normal rounded scans. If exact value = "3" then it includes 3.0 to 3.49999999. If exact value is "3.0" it includes 3.00 to 3.0499999999
rtTruncated: Truncated algoritm. If exact value = "3" then it includes 3.0 to 3.99999999. If exact value is "3.0" it includes 3.00 to 3.099999999
rtExtremerounded: Rounded Extreme. If exact value = "3" then it includes 2.0000001 to 3.99999999. If exact value is "3.0" it includes 2.900000001 to 3.099999999



So, better use this:
findDoubleValueAndReplace("1.000000", 0)

As you see, first argument is a string.

_________________
Back to top
View user's profile Send private message MSN Messenger
mordax
Expert Cheater
Reputation: 1

Joined: 16 Apr 2010
Posts: 120

PostPosted: Fri Apr 24, 2015 3:42 pm    Post subject: Reply with quote

bit offtopic maybe, but i have question about this. how would i go about replacing all existences of 1234 with 6789?

for example i have decimal value of 1234 and i want to replace all of them with 6789.
currently i use AoB, but i have to convert all values to hex and reverse them, its pain. would be easier if i can scan + replace all values with a simple command.
thanks.
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