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 call the function I defined in the lua file in the ta

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

Joined: 22 Jan 2019
Posts: 183

PostPosted: Wed Mar 20, 2019 11:40 pm    Post subject: How to call the function I defined in the lua file in the ta Reply with quote

Lua file in table:

function print()
return print('555')
end


调用 Call the lua command of this table form in another lua?[/code]
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Thu Mar 21, 2019 12:21 am    Post subject: Reply with quote

Code:
----- Function to call code from CE Table File
function loadTableCode(n2)
 local t2 = findTableFile(n2)
 if t2 ~= nil then
 local s2 = t2.Stream
 local c2 = readStringLocal(s2.Memory,s2.Size)
 return c2 ~= nil and loadstring(c2) -- return a function
 end
end
----- Executing load code from table file : test.lua
local f2 = loadTableCode('test.lua')
----- Assert load code to check success or not success
if type(f2) == 'function' then f2() else print('not loaded') end

---- Run the function from test.lua
myPrint()

note = [[----------------------------------------------------------------------
1. Add your lua file to CE Table: Table > Add File > Browse your file to add
2. Load your lua file to memory by that function provided above

3. test.lua :

    function myPrint()
      return print('555')
    end

    I subtitute your 'function print() to function myPrint()
    to prevent confusion 'print as a function' or 'print' as lua command
-----------------------------------------------------------------------------]]

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

Joined: 22 Jan 2019
Posts: 183

PostPosted: Thu Mar 21, 2019 7:13 am    Post subject: thank Reply with quote

thank you for your help
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 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