View previous topic :: View next topic |
Author |
Message |
MMM-304 Expert Cheater Reputation: 0
Joined: 17 Aug 2020 Posts: 170 Location: Milkey Way
|
Posted: Tue Jan 23, 2024 11:40 pm Post subject: New userdata class does not appear in LuaEngine |
|
|
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 |
|
|
Dark Byte Site Admin Reputation: 465
Joined: 09 May 2003 Posts: 25570 Location: The netherlands
|
Posted: Wed Jan 24, 2024 1:26 am Post subject: |
|
|
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 |
|
|
MMM-304 Expert Cheater Reputation: 0
Joined: 17 Aug 2020 Posts: 170 Location: Milkey Way
|
Posted: Wed Jan 24, 2024 7:32 am Post subject: |
|
|
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 |
|
|
Dark Byte Site Admin Reputation: 465
Joined: 09 May 2003 Posts: 25570 Location: The netherlands
|
Posted: Wed Jan 24, 2024 9:36 am Post subject: |
|
|
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 |
|
|
MMM-304 Expert Cheater Reputation: 0
Joined: 17 Aug 2020 Posts: 170 Location: Milkey Way
|
Posted: Wed Jan 24, 2024 9:56 am Post subject: |
|
|
Yes it is LUA_TUSERDATA.
|
|
Back to top |
|
|
MMM-304 Expert Cheater Reputation: 0
Joined: 17 Aug 2020 Posts: 170 Location: Milkey Way
|
Posted: Sat Feb 24, 2024 12:25 am Post subject: |
|
|
@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 |
|
|
Dark Byte Site Admin Reputation: 465
Joined: 09 May 2003 Posts: 25570 Location: The netherlands
|
Posted: Sat Feb 24, 2024 2:02 am Post subject: |
|
|
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 |
|
|
MMM-304 Expert Cheater Reputation: 0
Joined: 17 Aug 2020 Posts: 170 Location: Milkey Way
|
Posted: Sat Feb 24, 2024 8:51 am Post subject: |
|
|
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 |
|
|
|