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 load a CE table from a plugin?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Source -> Plugin development
View previous topic :: View next topic  
Author Message
redplug
How do I cheat?
Reputation: 0

Joined: 20 Jun 2012
Posts: 9

PostPosted: Thu Jun 21, 2012 5:29 am    Post subject: How to load a CE table from a plugin? Reply with quote

Hi,

I am writing a plugin for CE with Lazarus and want to load a CE table from a file (or even better from a resource).

Is this possible with the SDK?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Thu Jun 21, 2012 7:09 am    Post subject: Reply with quote

It's possible to a certain degree, but you might want to rethink what you're doing.
Why would you wish to load a table with a plugin, why not just use the hardcoded data internally instead of adding some stuff no one will see to the table ? (you hide the ce window)

Anyhow, you could make use of createTableEntry followed by the memrec_ functions to configure the added entries.
If you really want to use a cheat table you will then have to parse the xml data into commands to configure the table


An alternative method is to call lua's loadTable function. Just write the table to a temp dir and load.
(read http://forum.cheatengine.org/viewtopic.php?t=552839 and check the source. It makes use of ce's lua library to control the luavm object, you can use it to call lua functions as well )


If you just wish to execute an auto assemble script, then AutoAssembler(string) is a better solution

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

Joined: 20 Jun 2012
Posts: 9

PostPosted: Thu Jun 21, 2012 12:56 pm    Post subject: Reply with quote

Hi. Thanks for the reply.

Because it is easyer for me to debug and modify the table if the game gets patched.

but i found a way to do so. I have a Lua script:

Code:
ErrorLoadingWoWBot = true;

function WoWBotInitialized()
  ErrorLoadingWoWBot = false;
  startWoWBot();
end;

if startWoWBot == nil then
  loadPlugin('wowbot.dll');
  if ErrorLoadingWoWBot then
    showMessage('Error loading wowbot.dll');
    closeCE();
  end
else
  startWoWBot();
end


and my wow bot dll:

Code:



function StartWoWBot(L: PLua_State): integer; cdecl;
begin
  Application.Initialize;
  Application.CreateForm(TWoWBotForm, Form);
  Application.Run();
  CE.closeCE();
  Result := 1;
end;

function InitializePlugin(ExportedFunctions: PExportedFunctions;
  PluginId: DWord): BOOL; stdcall;
var
  CallWoWBotInitialized: boolean;

begin
  Result := False;

  CE := ExportedFunctions^;
  L := CE.GetLuaState();

  if L <> nil then
  begin
    lua_register(L, 'startWoWBot', StartWoWBot);

    lua_pushstring(L, 'WoWBotInitialized');
    lua_rawget(L, LUA_GLOBALSINDEX);
    CallWoWBotInitialized := lua_isfunction(L, -1);
    lua_pop(L, 1);

    if CallWoWBotInitialized then
    begin
      lua_getfield(L, LUA_GLOBALSINDEX, 'WoWBotInitialized');
      lua_call(L, 0, 0);
    end;

    Result := True;
  end;

end;


function GetVersion(var PluginVersion: TPluginVersion;
  SizeOfPluginVersion: integer): BOOL; stdcall;
begin
  Result := False;
  if SizeOfPluginVersion <> SizeOf(TPluginVersion) then
    exit;

  PluginVersion.version := 1;
  PluginVersion.pluginname := 'WoW Bot';


  Result := True;
end;

function DisablePlugin: BOOL; stdcall;
begin
  Result := True;
end;



and i created a CETRAINER file. this code solves also the problem with closing the form.

the best thing would be that i could create a exe from this woth CE. But it always say 'Error loading wowbot.dll' even if i add the wowbot.dll to the file list in CE.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Tue Jun 26, 2012 12:35 pm    Post subject: Reply with quote

you just have to specify the path to your plugin
Either TrainerOrigin if the plugin is separate but in the same folder as the trainer or getCheatEngineDir() if the plugin is inside the exe

_________________
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 Source -> Plugin development 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