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 


It is possible to put 2 lua scripts in just a cheat table?

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

Joined: 16 Dec 2011
Posts: 3
Location: Brasil

PostPosted: Thu Jan 12, 2012 8:02 pm    Post subject: It is possible to put 2 lua scripts in just a cheat table? Reply with quote

It is possible to put 2 lua scripts in just a cheat table?
Back to top
View user's profile Send private message AIM Address
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Thu Jan 12, 2012 8:31 pm    Post subject: Reply with quote

yes, just check that if you use global variables that don't interfere (and functionnames must be different)
_________________
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 12, 2012 9:18 pm    Post subject: Reply with quote

I'm using two LUA scripts too. (reason: more human readable code)

First one is inside CT table. ("show cheat table lua script" ctrl+alt+L)

Second scripts is loaded with this instruction require "myscript" - it loads myscript.lua file. CT file and myscript.lua must be in the same directory. Btw. myscript.lua contains my universal functions and wrappers.

When I'm making EXE trainers I must add secondfile.lua file manually ("Exe Trainer Generator" , "Extra files" panel) or copy&paste second script at the end of first script.


@Dark Byte
Would be nice to load second lua file from CT (added this way: Table -> add file), like this:

Code:
-- new registered function (suggestion)
-- function similar to findTableFile, but combined with require LUA function

require_fromTableFile('myscript')




Of course I could use this:
Code:
luascripttablefile=findTableFile('myscript')
tablefile_saveToFile(luascripttablefile,'myscript.lua')
require "myscript"

but I got "Error:Access violation" at tablefile_saveToFile() (rev.1160) (tablefile_saveToFile doesn't work?)


Edit:
OK. I've finished editing my post.

Edit2:
My sugesstons:
1) require_fromTableFile('myscript')
2) auto-adding lua files ( require ) when creating EXE trainers.

_________________
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: Mon Jan 23, 2012 8:26 am    Post subject: Reply with quote

mgr.inz.Player wrote:

Of course I could use this:
Code:
luascripttablefile=findTableFile('myscript')
tablefile_saveToFile(luascripttablefile,'myscript.lua')
require "myscript"

but I got "Error:Access violation" at tablefile_saveToFile() (rev.1160) (tablefile_saveToFile doesn't work?)


OK, It works now. And I'm using this:
Code:
luascripttablefile=findTableFile('myscript')
tablefile_saveToFile(luascripttablefile,'myscript.lua')
require "myscript"
os.remove("myscript.lua") -- immediately delete file after loading it.
                          -- It's still inside cheattable (table -> add file)

_________________
Back to top
View user's profile Send private message MSN Messenger
ddtank.
Newbie cheater
Reputation: 0

Joined: 03 Dec 2011
Posts: 21

PostPosted: Mon Jan 30, 2012 3:06 am    Post subject: Reply with quote

I can't use the function dofile("file1.lua") for that?
I try this and work fine for 2 scripts, but in the 3rd the script fails, all the functions don't work...
Back to top
View user's profile Send private message
ddtank.
Newbie cheater
Reputation: 0

Joined: 03 Dec 2011
Posts: 21

PostPosted: Sun Feb 05, 2012 11:41 pm    Post subject: Reply with quote

I try do this in lua:

dofile("script1.lua")
dofile("script2.lua")
dofile("script3.lua")

or this:

require("script1.lua")
require("script2.lua")
require("script3.lua")

to do the attachment luas, but this don't work.
I need change global variables? If i do this i can use all the functions in the lua of one ct, right?
I don't know which are global variables in the scrits, you can help me? Confused



script3.lua
 Description:
Readbytes scripts

Download
 Filename:  script3.lua
 Filesize:  1.03 KB
 Downloaded:  1073 Time(s)


script1.lua
 Description:
Readbytes scripts

Download
 Filename:  script1.lua
 Filesize:  1.03 KB
 Downloaded:  1126 Time(s)


script2.lua
 Description:
Readbytes scripts

Download
 Filename:  script2.lua
 Filesize:  1.03 KB
 Downloaded:  1084 Time(s)

Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Mon Feb 06, 2012 12:08 am    Post subject: Reply with quote

rename replaceAOB and restoreAOB for each script to a unique functionname

e.g: restoreAOB1, restoreAOB2, restoreAOB3

also activatetick and deactivatetick

_________________
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
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