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 


[Help for newbie] Set to random value

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

Joined: 03 Oct 2013
Posts: 5

PostPosted: Thu Oct 03, 2013 3:37 pm    Post subject: [Help for newbie] Set to random value Reply with quote

Hi, i have some language barrier, and i think primitive explanation seems clearer to avoid misunderstanding

Need to create a trainer by CheatEngine. Address is static. Functional:
F1 - set value (ID) to default (as an example) "123456"
F2 - set value to RANDOM(!) integer value (better to define between 100000-900000) - and this is problem for me =)

Right now i use Increase/Decrease options (Lot of buttons: +1 -3 +5 -1 +2 etc) Rolling Eyes because GUI don't give me ability to use RANDOM value. I think need use a script.
Can someone show me example and explain how i can do this?
Back to top
View user's profile Send private message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Thu Oct 03, 2013 3:55 pm    Post subject: Reply with quote

Code:
writeInteger(0x000000, math.random(100000,900000));

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Thu Oct 03, 2013 3:56 pm    Post subject: Reply with quote

use a hotkey that sets the value to
Code:

[math.random(100000, 900000)]


(include the brackets [] )

_________________
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
Slyker
How do I cheat?
Reputation: 0

Joined: 03 Oct 2013
Posts: 5

PostPosted: Thu Oct 03, 2013 4:19 pm    Post subject: Reply with quote

Thank you. Can someone give me working example file, (i want remake it) because i'm newbie - with pattern i can understand faster.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Thu Oct 03, 2013 4:35 pm    Post subject: Reply with quote

here's an example.
When you press f1 it will set the value to 123456, if you press f2 it will set the value to a random value between 100000 and 900000



examplehk.CT
 Description:

Download
 Filename:  examplehk.CT
 Filesize:  830 Bytes
 Downloaded:  1137 Time(s)


_________________
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
Slyker
How do I cheat?
Reputation: 0

Joined: 03 Oct 2013
Posts: 5

PostPosted: Thu Oct 03, 2013 4:51 pm    Post subject: Reply with quote

Perfect. I'm very surprised by such quality support.
Back to top
View user's profile Send private message
Slyker
How do I cheat?
Reputation: 0

Joined: 03 Oct 2013
Posts: 5

PostPosted: Thu Oct 10, 2013 11:31 am    Post subject: Reply with quote

Is it possible to use a random number from a txt file? How?
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 Oct 10, 2013 11:45 am    Post subject: Reply with quote

Random number from a .txt file ?
Explain.

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

Joined: 03 Oct 2013
Posts: 5

PostPosted: Thu Oct 10, 2013 11:54 am    Post subject: Reply with quote

List of values:
123456
222222
333122
123123
...etc
in "values.txt"
As i asked above above, but with the difference that the value is taken randomly from the list.
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 Oct 10, 2013 12:05 pm    Post subject: Reply with quote

Again, you can use Lua:
Code:
for line in io.lines("my.txt") do
  print(line)
end


Of course, instead of print, you will use
Code:
writeInteger(address,  tonumber(line) )


Edit:
Or if you want keypress for it:

Code:
tableWithValues = {}
for line in io.lines("my.txt") do
  table.insert(tableWithValues,tonumber(line))
end

hk1 = createHotkey("writeValueFromList", keys, ...)

function writeValueFromList()
  writeInteger(address,  tableWithValues[math.random(1, #tableWithValues)] )
end

_________________
Back to top
View user's profile Send private message MSN Messenger
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