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 6.5 CE version problem

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
AntonVitalievich
How do I cheat?
Reputation: 0

Joined: 21 Jan 2016
Posts: 6

PostPosted: Thu Jan 21, 2016 1:10 am    Post subject: Lua 6.5 CE version problem Reply with quote

Hi
I Tryed to made some lua sript in 6.5 CE version which will must add or sub value "8".

***************************
Code:
al = getAddressList()
FIRSTAdress = al.getMemoryRecordByDescription("FIRSTAdress")
function fordownder()
if FIRSTAdress.Value~="??" then
FIRSTAdress.Value=FIRSTAdress.Value-8
end
end
createHotkey("fordownder", VK_C);


***************************
FIRSTAdress.Value in CE Table has 4 bytes type. When i press hotckey lua show mesage - Error:"12.0" is an invalid integer
If i change type to float or drouble it work.
After that i try CE 6.4 version and in this version all fine. 4 bytes adress work. In CE 6.5 4 bytes adrees not work

Its some bug or i do something wrong in CE 6.5?


Last edited by AntonVitalievich on Thu Jan 21, 2016 4:36 am; edited 1 time in total
Back to top
View user's profile Send private message
hhhuut
Grandmaster Cheater
Reputation: 6

Joined: 08 Feb 2015
Posts: 607

PostPosted: Thu Jan 21, 2016 3:05 am    Post subject: Reply with quote

Maybe it's not a bug, but just another difference between LUA 5.1 (which is used by CE 6.4) and LUA 5.3 (which is used by CE 6.5) ...
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Thu Jan 21, 2016 3:51 am    Post subject: Reply with quote

redownload cheat engine, you may gotten it within the first week. There has been a fix at the end of the week after release that fixed an integer conversion issue
_________________
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
mgr.inz.Player
I post too much
Reputation: 218

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

PostPosted: Thu Jan 21, 2016 4:31 am    Post subject: Reply with quote

In Lua5.1 if you execute this line:
Code:
print(  '20'  -  8  )

it will convert '20' to 20, subtract 8, then print the result: 12

In Lua5.2-Lua5.3 if you execute this line:
Code:
print(  '20'  -  8  )

it will convert '20' to 20.0, subtract 8, then print the result: 12.0

You see the difference? 12 and 12.0





Going back to FIRSTAdress.Value

In CE6.4 doing FIRSTAdress.Value = 12.5 will throw 'is an invalid integer'.
In CE6.4 doing FIRSTAdress.Value = '12.5' will throw 'is an invalid integer'.

In CE6.5 doing FIRSTAdress.Value = 12.5 will throw 'is an invalid integer'.
In CE6.5 doing FIRSTAdress.Value = '12.5' will throw 'is an invalid integer'.

4bytes do not accept values with fractions.


Value field is a string, when assigning a value, Lua will convert that value to a string. In this case 12.0 to '12.0'.


solution:
you have to use math.floor:
Code:
FIRSTAdress.Value = math.floor(FIRSTAdress.Value-8)

_________________


Last edited by mgr.inz.Player on Thu Jan 21, 2016 4:33 am; edited 2 times in total
Back to top
View user's profile Send private message MSN Messenger
AntonVitalievich
How do I cheat?
Reputation: 0

Joined: 21 Jan 2016
Posts: 6

PostPosted: Thu Jan 21, 2016 4:31 am    Post subject: Reply with quote

Understand
It couse CE now have new version of Lua which work some another way


Thanks
With this now work
Code:
FIRSTAdress.Value = math.floor(FIRSTAdress.Value-8)
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: Thu Jan 21, 2016 4:43 am    Post subject: Reply with quote

Yes. I had that problem with previous CE versions (6.2-6.4).

I was making more advanced calculations:
Code:
newValue = {calculations here}
memoryRecord.Value = math.floor(newValue)

(value type is an integer type: 2bytes, 4bytes, 8bytes)






About the fix DB wrote.

In CE6.4 those are possible:
label.Top = 34.8
writeInteger(address,56.4)

34.8 will be truncated to 34
56.4 will be truncated to 56

Initial CE6.5 release has a bug (or, Lua new feature). That feature truncated all values with fractions to zero.
Now, in recent CE6.5 (with fixes) this is no longer an issue.


Edit:
typos

_________________


Last edited by mgr.inz.Player on Thu Jan 21, 2016 5:04 am; edited 2 times in total
Back to top
View user's profile Send private message MSN Messenger
AntonVitalievich
How do I cheat?
Reputation: 0

Joined: 21 Jan 2016
Posts: 6

PostPosted: Thu Jan 21, 2016 4:58 am    Post subject: Reply with quote

CE 6.5 which i used when test first script, i downlowd today from
this site, green button. Without language pack.
Back to top
View user's profile Send private message
AntonVitalievich
How do I cheat?
Reputation: 0

Joined: 21 Jan 2016
Posts: 6

PostPosted: Fri Jan 22, 2016 2:00 am    Post subject: Reply with quote

Hello again
Some problem yet with Lua

I try to use script
Code:
al = getAddressList()
FIRSTAdress = al.getMemoryRecordByDescription("FIRSTAdress")
function fordownderone()
if FIRSTAdress.Value>"8" then
FIRSTAdress.Value=math.floor(FIRSTAdress.Value-8)
end
end
createHotkey("fordownderone", VK_DOWN)


I want made protect for value. Want decrease value but not under 0
couse 4 bytes when was under 0 - was aboue 4294967272
But script not want work
If i set value 88 and then press 2 time hotkey - value was 80 and then 72 and then i press third time and not happend, it stop on 72

*************************************
And tryed this version of script
Code:
al = getAddressList()
FIRSTAdress = al.getMemoryRecordByDescription("FIRSTAdress")
function fordownderone()
if FIRSTAdress.Value>"8" then
FIRSTAdress.Value=math.floor(FIRSTAdress.Value-1)
end
end
createHotkey("fordownderone", VK_DOWN)

Value decrease only when i set value to 99. And it stoped on 79. If i set 100 - not want decrease, only when i set 99. But it stoped decrease on 79
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: Fri Jan 22, 2016 5:59 am    Post subject: Reply with quote

How many times you executed this script?

createHotkey creates an object every time you click "execute script". If you have five, it will call function 5 times per button press.




to prevent this, you have to this:
Code:
if myHotkey==nil then myHotkey=createHotkey("fordownderone", VK_DOWN) end

It will create hotkey only once.




Or this:
Code:
if myHotkey~=nil and myHotkey.destroy then myHotkey.destroy() end
myHotkey=createHotkey("fordownderone", VK_DOWN)

It will recreate hotkey. (delete existing, add new)

_________________
Back to top
View user's profile Send private message MSN Messenger
AntonVitalievich
How do I cheat?
Reputation: 0

Joined: 21 Jan 2016
Posts: 6

PostPosted: Fri Jan 22, 2016 7:07 am    Post subject: Reply with quote

Yes i activate/existing script only one time

And if i made some changes in script i always close CE and again open and when if CE ask meaboute start old lua project script - i set no. Then i copy past new scipt in lua (with new chenges)and then press existing
6.4 version cant too decrease 4 byte value
with this
Code:
if FIRSTAdress.Value>"8" then

withoute it string in script all fine all work
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: Fri Jan 22, 2016 3:59 pm    Post subject: Reply with quote

That line..... I see.

It is because you compare string with string.


Thy this instead:
Code:
if tonumber(FIRSTAdress.Value) > 8 then

_________________
Back to top
View user's profile Send private message MSN Messenger
AntonVitalievich
How do I cheat?
Reputation: 0

Joined: 21 Jan 2016
Posts: 6

PostPosted: Sat Jan 23, 2016 12:38 am    Post subject: Reply with quote

Now work with
Code:
if tonumber(FIRSTAdress.Value) > 8 then


Thanks mgr.inz.Player.
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