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 


Set value as text depending on the number

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

Joined: 30 Jan 2018
Posts: 25

PostPosted: Wed Feb 07, 2018 3:55 am    Post subject: Set value as text depending on the number Reply with quote

I'm making a trainer and I have a value that randomizes between 1-26.
I need to make it so that the number changes to text

if value = 4 then then label displays "Top left shelf" for example.
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: Wed Feb 07, 2018 4:09 am    Post subject: Reply with quote

Code:

texttable={}
texttable[3]="Something else"
texttable[4]="Top left shelf"
texttable[10000]="Some really high value"

value=4
if texttable[value] then
  print("The value is "..texttable[value])
else
  print("Unknown value:"..value) 
end

_________________
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
Johnden
Cheater
Reputation: 0

Joined: 30 Jan 2018
Posts: 25

PostPosted: Wed Feb 07, 2018 4:37 am    Post subject: Reply with quote

Is it the same if I want to put the value in CELabel?
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: Wed Feb 07, 2018 4:49 am    Post subject: Reply with quote

yes, instead of print you just write the text to the label's Caption property

Code:

MyForm.CELabel111234.Caption="The value is "..texttable[value]

_________________
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
Johnden
Cheater
Reputation: 0

Joined: 30 Jan 2018
Posts: 25

PostPosted: Thu Feb 08, 2018 12:09 pm    Post subject: Reply with quote

Another question, My Label doesn't seem to display the text ON

Code:

function CETimer1Timer(sender)
local memrec=addresslist_getMemoryRecordByDescription(getAddressList(), "KeyCard RNG")
local value=memoryrecord_getValue(memrec)

if value==1 then control_setCaption(CETrainer_CELabel1, "ON")
else control_setCaption(CETrainer_CELabel1, "OFF")
end
end
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 Feb 08, 2018 1:25 pm    Post subject: Reply with quote

try this code
Code:

function CETimer1Timer(sender)
  local memrec=getAddressList().getMemoryRecordByDescription("KeyCard RNG")
  if (memrec==nil)
    showMessage("The description was wrong")
  end

  if memrec.value==1 then
    CETrainer.CELabel1.Caption="ON"
  else
    CETrainer.CELabel1.Caption="It is OFF"
  end
end


And if your timer running? I am assuming the default code of your label is "OFF" so this script changes it to "It is OFF" to show the timer is active or not

_________________
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
Johnden
Cheater
Reputation: 0

Joined: 30 Jan 2018
Posts: 25

PostPosted: Thu Feb 08, 2018 1:54 pm    Post subject: Reply with quote

Didn't seem to work, it still stayed at OFF.
I want to use the timer similarly in this code
Code:

function CETimer1Timer(sender)
local memrec=addresslist_getMemoryRecordByDescription(getAddressList(), "Adress 1")
local value=memoryrecord_getValue(memrec)
control_setCaption(CETrainer_CELabel1, value)
end

I need each value to be a different text.
As an example I tried 0 - OFF and 1 - ON
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 Feb 08, 2018 3:57 pm    Post subject: Reply with quote

look at your timer code or object. make sure you enable it
_________________
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
Johnden
Cheater
Reputation: 0

Joined: 30 Jan 2018
Posts: 25

PostPosted: Thu Feb 08, 2018 4:29 pm    Post subject: Reply with quote

Doesn't work for me even if the timer is enabled. When I change the value to 1 it still says OFF
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 Feb 08, 2018 5:26 pm    Post subject: Reply with quote

is your formname correct?
is the labelname correct ?
does your timer run ?

_________________
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
Johnden
Cheater
Reputation: 0

Joined: 30 Jan 2018
Posts: 25

PostPosted: Fri Feb 09, 2018 12:04 am    Post subject: Reply with quote

I've checked, timer is running, and the formname (CETrainer) and labelname (CELabel1) is correct.
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: Fri Feb 09, 2018 2:25 am    Post subject: Reply with quote

and your timer's onTimer function is CETimer1Timer ? Then why does your label say "OFF" instead of "It is OFF" ?

try this code for the timer:
Code:

function CETimer1Timer(sender)
  print("I am running")
  CETrainer.CELabel1.Caption="MAYBE"

  local memrec=getAddressList().getMemoryRecordByDescription("KeyCard RNG")
  if (memrec==nil) then
    print("The description was wrong")
  end

  if tonumber(memrec.value)==1 then
    CETrainer.CELabel1.Caption="ON"
  else
    CETrainer.CELabel1.Caption="It is OFF"
  end
end


and tell me what happens

_________________
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


Last edited by Dark Byte on Fri Feb 09, 2018 7:47 am; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
Johnden
Cheater
Reputation: 0

Joined: 30 Jan 2018
Posts: 25

PostPosted: Fri Feb 09, 2018 7:45 am    Post subject: Reply with quote

First thing that appeared was an Error

Quote:

[string "function CETimer1Timer(sender)
..."]:7: 'then' expected near 'print'


After I added 'then'

lua engine repeatedly printed "I am running"

Also when I changed the value to 1 the label displayed "ON"
Any other value displayed "It is OFF"
So that worked.
Thank you
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