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 


What is the required path and code for "require"?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1533

PostPosted: Sun Jan 12, 2020 4:15 am    Post subject: What is the required path and code for "require"? Reply with quote

hi ..
What is the required path and code for "require"?
I have an auxiliary code index.
And I need to create a table integrated into the code inside.
But I don't know the code index to reconcile in CE Lua.
Is it possible to get an explanation with the example below?
CE How can I reconcile and encode the file I place in "autorun" or "autorun \ dlls"?


Code:
local http = require("socket.http")

-- or
Code:
local dir =  = getCheatEngineDir()..'autorun'
local ba = require(dir.."\\Barracuda.dll")


thanks in advance

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Sun Jan 12, 2020 4:44 am    Post subject: Reply with quote

package.path and package.cpath are strings that decide where lua searches (note that it includes the extension types as well)

you can adjust that path at runtime

and in case of lua dll's make sure you compile using ce's lib files, else the dll will link to the wrong dllname (ce uses renamed lua dll names)

_________________
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
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1533

PostPosted: Sun Jan 12, 2020 5:04 am    Post subject: Reply with quote

Code:
Error:[string "cedir = getCheatEngineDir() ..'Cheat Engine.e..."]:3: module 'C:\Program Files (x86)\Cheat Engine 7.0\Cheat Engine.exe\autorun\Barracuda.dll' not found:
   no field package.preload['C:\Program Files (x86)\Cheat Engine 7.0\Cheat Engine.exe\autorun\Barracuda.dll']
   no file 'C:\Program Files (x86)\Cheat Engine 7.0\lua\C:\Program Files (x86)\Cheat Engine 7\0\Cheat Engine\exe\autorun\Barracuda\dll.lua'



I think I still need a use case. Smile

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Sun Jan 12, 2020 7:52 am    Post subject: Reply with quote

i need to see the full script because i don't think
Code:

C:\Program Files (x86)\Cheat Engine 7.0\Cheat Engine.exe\autorun\Barracuda.dll
C:\Program Files (x86)\Cheat Engine 7.0\lua\C:\Program Files (x86)\Cheat Engine 7\0\Cheat Engine\exe\autorun\Barracuda\dll.lua

are valid paths

print out package.path and package.cpath to see the formatting

also try putting your dll in clibs32 or clibs64 which is ce's default lua searchpath

_________________
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 Sun Jan 12, 2020 8:09 am; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Sun Jan 12, 2020 8:06 am    Post subject: This post has 1 review(s) Reply with quote

I am back on the first topic about Lua 'require' and example for luaSocket.

Example: Creatimg a module

Code:
---- This is a sample module
---- To show how to use Lua 'require' statement
---- Save these script as a file 'matchcalc.lua'
---- Put this 'matchcalc.lua' in same folder/Dir with the CE trainer
------------------------------------------------
module("mathcalc", package.seeall)   --- using Lua 5.0/5.1 ols way


--local mathcalc =  {}

function mathcalc.add(a,b)
   print(a+b)
end

function mathcalc.sub(a,b)
   print(a-b)
end

function mathcalc.mul(a,b)
   print(a*b)
end

function mathcalc.div(a,b)
   print(a/b)
end

return mathcalc
-------------------------------------------------



Then creating a CT file and execute:

Code:
-- This is a example CT file to implementing Lua 'require' statement
-- The module name is "mathcalc.lua
-- Make sure 'matchcalc.lua' save in the correct path
require('mathcalc')
mathcalc.add(10,20)
mathcalc.sub(30,20)
mathcalc.mul(10,20)
mathcalc.div(30,20)

--- will print result:
30
10
200
1.5





When you load a module with require Lua uses the package paths to determine where to look for the module. Specifically, the section on package.path and package.cpath.

Code:
package.path: The path used by require to search for a Lua loader (.lua modules)
package.cpath: The path used by require to search for a C loader (.so/.dll modules)


Example to check CE package.path and package.cpath:

Code:
print(package.path..'\n'..package.cpath)


You can set the package paths relative to your project before you require the socket library (substitute /?.dll for /?.so on Linux)

You can modify the package paths before calling require. For example, if you create a folder for your project and extract the LuaSocket library to a sub-folder called libs within your project folder:

Code:
Project
|
> libs
     |
     > lua
         |
         > socket         
     > socket
     > mime


and set on your trainer script:

Code:
package.path = package.path..';./libs/lua/?.lua'
package.cpath = package.cpath..';./libs/socket/?.dll;./libs/mime/?.dll'
local socket = require 'socket'


Hope it work in CE path/libs.

EDIT:
I am not sure using barracuda.dll only will work, because I think barracuda we app need to the installation process.

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1533

PostPosted: Sun Jan 12, 2020 5:35 pm    Post subject: Reply with quote

Although on the correct path: The specified procedure could not be found.

There are some features I want to use in this .dll.
For more information see:
https://realtimelogic.com/ba/doc/en/lua/lua.html#xlua

Barracuda.dll :
https://www.dosyaupload.com/fo1p

There may not be a .dll that CE can read. I am not sure.
With @Corroder's explanation, back to the topic:
How can I benefit by integrating a ".dll" into CE?



Screenshot_10.jpg
 Description:
 Filesize:  130.2 KB
 Viewed:  3957 Time(s)

Screenshot_10.jpg



_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Sun Jan 12, 2020 8:57 pm    Post subject: Reply with quote

You can use "package.loadlib(module)".

Example :
Code:

package.loadlib('Barracuda.dll', 'luaopen_Barracuda')


We could alternately pass an absolute path, example:

Code:
package.loadlib([[c:\path\to\Barracuda.dll.dll]], 'luaopen_Barracuda')


see:
http://lua-users.org/wiki/LoadLibrary
https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order?redirectedfrom=MSDN

Alternative, if you know the function name inside Barracuda.dll, then consider using "executeCodeLocalEx()" also.
Also, you need to consider how that 'Barracuda.dll' compiled. Is it matching to CE environment?

_________________
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