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 


New userdata class does not appear in LuaEngine

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Source -> Plugin development
View previous topic :: View next topic  
Author Message
MMM-304
Expert Cheater
Reputation: 0

Joined: 17 Aug 2020
Posts: 166
Location: Milkey Way

PostPosted: Tue Jan 23, 2024 11:40 pm    Post subject: New userdata class does not appear in LuaEngine Reply with quote

I've created a class, registered it as a userdata, and associated a metatable with it in C++. The problem is that in Lua engine, it does not index its properties and functions as it does with Pascal ones. And also on debug, it does not show "Object of type ...", which I have found to be associated with Pascal class TObject.ClassName property.

How can I add these features to my c++ based userdata including the indexing in LuaEngine?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Wed Jan 24, 2024 1:26 am    Post subject: Reply with quote

In the metatable fill in the methods and properties and also implement __index and __newindex manually
_________________
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
MMM-304
Expert Cheater
Reputation: 0

Joined: 17 Aug 2020
Posts: 166
Location: Milkey Way

PostPosted: Wed Jan 24, 2024 7:32 am    Post subject: Reply with quote

I did. That is why it shows the result when I hover over a property or shows "native function" for functions when I debug in Lua Engine. But it does not show anything when I try to index it while writing the code!
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Wed Jan 24, 2024 9:36 am    Post subject: Reply with quote

the object is of type LUA_TUSERDATA or LUA_TLIGHTUSERDATA ?
_________________
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
MMM-304
Expert Cheater
Reputation: 0

Joined: 17 Aug 2020
Posts: 166
Location: Milkey Way

PostPosted: Wed Jan 24, 2024 9:56 am    Post subject: Reply with quote

Yes it is LUA_TUSERDATA.
Back to top
View user's profile Send private message
MMM-304
Expert Cheater
Reputation: 0

Joined: 17 Aug 2020
Posts: 166
Location: Milkey Way

PostPosted: Sat Feb 24, 2024 12:25 am    Post subject: Reply with quote

@Dark Byte

I did some research and found that the error that occurs when I hover over my userdata object (to get its class name) occurs in the function "LuaValueToDescription" of file LuaHandler.pas.
That is because it tries to convert my c++ class into pascal TObject which it is not:

Code:

      try
        if o is TObject then
        begin
          result:='Object of type '+o.ClassName;
          if o is TControl then
            result:=result+' (Name='+tcontrol(o).Name+')'
        end;
      except
      end;



I still could not figure out where the errors for indexing occur and it would be easy if CheatEngine also had a PDB with it.

Can you make it and other userdata handling functions so that they try to index the ClassName and other stuff from the metatable associated with the userdata instead of trying to convert to a type of TObject.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Sat Feb 24, 2024 2:02 am    Post subject: Reply with quote

maybe instead of userdata make it a normal table with metadata assigned and have most of the entries copied to the table as well for the index (just for visuals while the metadata does the actual work)
_________________
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
MMM-304
Expert Cheater
Reputation: 0

Joined: 17 Aug 2020
Posts: 166
Location: Milkey Way

PostPosted: Sat Feb 24, 2024 8:51 am    Post subject: Reply with quote

Cant. I have multiple C++ objects that need to be accessed and written like other CE's LuaObjects.

Normal tables with associated metatables does not even require a plugin. I have my .lua based lib doing this already. But for current task I need c++ operations.
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 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