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 


Move cursor and check if value is in table

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

Joined: 08 Apr 2020
Posts: 14

PostPosted: Mon May 04, 2020 10:19 pm    Post subject: Move cursor and check if value is in table Reply with quote

hello, is there any way to move cursor in lua?
also to check if a value is in table?

I want to make something like

x = {"32325","87417","86221","85674"}

if value in x:
move cursor to certain position
end

thank you!
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Tue May 05, 2020 5:00 am    Post subject: Reply with quote

Code:
local function contains(table, val)
   for i=1,#table do
      if table[i] == val then
         return true
      end
   end
   return false
end

x = {"32325","87417","86221","85674"}

if contains(x, "32325") then
   print("Value found")
   setMousePos(0,0)
else
   print("Value not found")
end

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
akikazu12
Newbie cheater
Reputation: 0

Joined: 08 Apr 2020
Posts: 14

PostPosted: Tue May 05, 2020 9:30 am    Post subject: Reply with quote

Corroder wrote:
Code:
local function contains(table, val)
   for i=1,#table do
      if table[i] == val then
         return true
      end
   end
   return false
end

x = {"32325","87417","86221","85674"}

if contains(x, "32325") then
   print("Value found")
   setMousePos(0,0)
else
   print("Value not found")
end


thank you for the cursor mover!
sorry I didn't explain ir clearly, the value is always changing, and I want to make it like when the value match to one of the data from x table, the cursor will move, do you know how?
in python I can do
if Value in x:
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Tue May 05, 2020 1:11 pm    Post subject: Reply with quote

Code:
local x = {"32325","87417","86221","85674"} -- Why this is string?

local value_change = 32325  -- this value always change but I don't know from where get this value

--- or if the value_change has comes from hack table
--- local al = AddressList or getAddressList()
--- local mr1 = al.getMemoryRecordByDescription("your hack description here")
--- value_change = mr1.Value
--- then do as below

for _, v in ipairs(x) do
    if tonumber(v) == value_change then  -- check for match value
        print("Value found")
        setMousePos(0,0)  -- change 0,0 to what you want
    end
end

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
akikazu12
Newbie cheater
Reputation: 0

Joined: 08 Apr 2020
Posts: 14

PostPosted: Tue May 05, 2020 5:23 pm    Post subject: Reply with quote

Corroder wrote:
Code:
local x = {"32325","87417","86221","85674"} -- Why this is string?

local value_change = 32325  -- this value always change but I don't know from where get this value

--- or if the value_change has comes from hack table
--- local al = AddressList or getAddressList()
--- local mr1 = al.getMemoryRecordByDescription("your hack description here")
--- value_change = mr1.Value
--- then do as below

for _, v in ipairs(x) do
    if tonumber(v) == value_change then  -- check for match value
        print("Value found")
        setMousePos(0,0)  -- change 0,0 to what you want
    end
end


didn't work :/
I tried this in onTimer, and it worked(moved the cursor every time the value equals "32325"), but It will be a pain to write out the values one by one (there are like 20 values to check)
Code:

 local Almemrec=addresslist_getMemoryRecordByDescription(getAddressList(), "Changing Value")
 local value_change=memoryrecord_getValue(Almemrec)
 if CETrainer1.ActivateBox.Checked == true then
  if value_change == "32325" then  -- check for match value
   setMousePos(1277,826)  -- change 0,0 to what you want
   CETrainer1.ActivateBox.Checked = false
  end
 end
Back to top
View user's profile Send private message
exohaxor
Expert Cheater
Reputation: 1

Joined: 02 Sep 2018
Posts: 101

PostPosted: Tue May 05, 2020 6:00 pm    Post subject: Reply with quote

can you not cherrypick ofc it wont work and you need a timer because it executes 1 time you didnt even thank to him
_________________
hi
Back to top
View user's profile Send private message
akikazu12
Newbie cheater
Reputation: 0

Joined: 08 Apr 2020
Posts: 14

PostPosted: Tue May 05, 2020 6:16 pm    Post subject: Reply with quote

exohaxor wrote:
can you not cherrypick ofc it wont work and you need a timer because it executes 1 time you didnt even thank to him

well I did thank him at first reply
appreciate for all of his helps(he helped me too like weeks ago)
and I do use the timer, i said that I use timer, the code I attach is to test if the value would be match or not, and it matches and moved the cursor


did you misunderstand my reply as "your code didnt work, here let me put timer on it, see now it worked"?
if you did, then no, "I tried this in onTimer, and it worked" I was talking about my code, the word "worked" was for the cursor move for one value, it was just a confirmation to see if the value correct or no(since he was asking why is it string), I wanted to tell that it can be worked and I cant find solution to check the value if its match to one of data on table, I said that it will be a pain to write out all the values one by one, thats why I ask about this, I dont want to write "else variable == value then move cursor" for every values exist, I can write those values, not that Im lazy but Im not gonna learn a thing from that

Corroder wrote:
Code:
local x = {"32325","87417","86221","85674"} -- Why this is string?

local value_change = 32325  -- this value always change but I don't know from where get this value

--- or if the value_change has comes from hack table
--- local al = AddressList or getAddressList()
--- local mr1 = al.getMemoryRecordByDescription("your hack description here")
--- value_change = mr1.Value
--- then do as below

for _, v in ipairs(x) do
    if tonumber(v) == value_change then  -- check for match value
        print("Value found")
        setMousePos(0,0)  -- change 0,0 to what you want
    end
end


oh thank you! finally I found what make this doesn't work in my trainer
I just realized that tonumber convert data to number, the value actually is in string that's why I put strings to the table, so I remove the tonumber and it worked

Code:

  for _, v in ipairs(x) do
   if value_change == v then
    setMousePos(1277,826)  -- change 0,0 to what you want
   end
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Wed May 06, 2020 2:16 am    Post subject: Reply with quote

If you read my script carefully, then you just need to maintenance:

Code:
if tonumber(v) == value_change then


this part.

_________________
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