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 


how to read value from editbox and perform arithmetic on it.

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

Joined: 27 Apr 2018
Posts: 33
Location: pakistan

PostPosted: Mon Jul 23, 2018 4:55 am    Post subject: how to read value from editbox and perform arithmetic on it. Reply with quote

Hi there!

am getting an error in my code and due to lack of coding skills I can't fix it myself and am here asking for help if someone can.

I have two memory addresses, two Edit Boxes and Two Buttons in my trainer. What I want to do is :
1. when a user enter some digits in first edit box then I read its value, add "0.1" in it and then apply the value to the memory address/

2. when he enter digits in second Edit box then I read its value and add "0.2" in it then apply it to memory address.

I tried to do so but failed, here it is,
1 :-
local readN = getProperty(CEEdit1_UDF1, "TEXT")
local newN = readN + 0.1
wirteFloat(0086FFE2"", newN)

and

2 :-

local readM = getProperty(CEEdit2_UDF1, "TEXT")
local newM = readM + 0.2
wirteFloat("00FFAD00", newM)


the error im getting in this is that I am trying to perform arithmetic operation on a NIl, IDK whtas this but maybe because am trying to add a numerci value in string(what the code recognize it as lol).

Any help will be appreciated. If you guys want more explanation about the problem, feel free to ask.
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 51

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Mon Jul 23, 2018 5:58 am    Post subject: Reply with quote

Nil is just Lua's form of Null, None, or nothing. And Null is not the same as zero.

Code:
local newN = tonumber(readN) + 0.1

But if it's nil is will still give an error.

I Think your object name may be the problem. Try `"form name"."edit name".Text`.
Code:
-- local readN = UDF1.CEEdit1.Text
local readN = CEEdit1_UDF1.Text
print(readN)
local newN = tonumber(readN) + 0.1
wirteFloat(0x0086FFE2, newN)

_________________
Back to top
View user's profile Send private message Visit poster's website
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Mon Jul 23, 2018 7:42 am    Post subject: Reply with quote

Quote:
the error im getting in this is that I am trying to perform arithmetic operation on a NIl,


How a 'TEXT' can be subtract with a number ?.
As TheyCallMeTim13 code above, you see a command 'tonumber'.
This convert 'number as text' to 'number' which able to perform an arithmetic operation.

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
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