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 


LUA list/item editor

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting -> Lua Extensions
View previous topic :: View next topic  
Author Message
jgoemat
Expert Cheater
Reputation: 21

Joined: 25 Sep 2011
Posts: 217

PostPosted: Wed Jun 06, 2018 12:23 pm    Post subject: LUA list/item editor Reply with quote

I've been messing around with LUA a lot lately and am trying to design a nice generic editor api. I think it should be easy to use and re-usable... Say you have a script that finds a pointer to the player's inventory and stores it in the global pointer pInventory. You could create a toggle script like this:

Code:

[enable]
LuaCall(ShowMasterDetail(GetInventory()))

[disable]
LuaCall(ShowMasterDetail(GetInventory()))


'ShowMasterDetail' would be the generic function that would take a list of lua tables and show a form sorta like the attached image which allows you to click on one item in a list on the left and edit the detail on the right. I did a custom one for 'DeadAge', the detail uses mono to find the fields shown in the attachment, but I'm still thinking on the api. I have an 'Address' class that simplifies getting and setting values of different types, and a 'Value' class with name, address, and type. Clicking on one of the items shows the details for that item. Clicking on a property opens a box to set a new value (currently works for byte/short/int/quad/single/float). Since the 'Value' class has a getString() and setString(), it handles the type conversion...

Code:

function GetInventory()
  local main = Address('[pInventory]')
  local list = main:offset(8):readAddress() -- another 'Address'
  local items = {}
  for i = 1,main:offset(0x0c).integer do
    table.insert(items, GetItem(list:offset(0x0c + i*4):readAddress())
  end
  return {
    title = "Inventory Editor",
    items = items
  }
end

function GetItem(address)
  local result = {}

  // mono string at 0x10 is a pointer, chars at offset 0x0c
  local itemTypeString = address:offset(0x10):readAddress():offset(0x0c).string
  result.description = 'Item '..itemTypeString..' at '..address

  // add values list for display in detail listbox
  result.values = {
    Value(address:offset(0x48), 'level', 'integer')
    Value(address:offset(0x4c), 'itemType', 'integer')
    Value(address:offset(0x5c), 'durability', 'float')
  }
end


Is this something worth adding to CE? Would just need a master/detail form and probably a detail only form for just editing one object and a script I mostly have written already... I think the Value and Address types would be handy additions to CE, I use them all the time now...



CE1.png
 Description:
 Filesize:  36.85 KB
 Viewed:  3796 Time(s)

CE1.png


Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater
Reputation: 34

Joined: 09 Aug 2013
Posts: 936

PostPosted: Wed Jun 06, 2018 2:50 pm    Post subject: Reply with quote

so... what like a fancy un-compressed version of the address list that comes with CE? Personally I don't see any need for it, but then I practically never mess with things like inventories.
_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
jgoemat
Expert Cheater
Reputation: 21

Joined: 25 Sep 2011
Posts: 217

PostPosted: Fri Jun 08, 2018 3:29 pm    Post subject: Reply with quote

Hmm.. I'm always wanting a way to edit lists of things, and wishing my actual table entries didn't get so cluttered. I'd rather just get a 'GameManger' pointer once and be able to edit the inventory or each party member than have to find separate injection points for the selected party member and selected inventory item and have to go back into the game to select a different item...

I started it with Shadow Warrior 2 though. The table I found was great and had entries in the address list for changing properties on upgrades. The problem is that it looks horrible because there can be 10 properties on the upgrade but most of them are pointers that aren't editable and don't have a description. The 1-4 you do care about can be either floats or integers, so they kind of get lost in the noise with four table entries per property... It was a lot easier for me to see each only the properties I care about with one per line and to just click on the one I want to change, type in a new value, and hit return...



sw2.jpeg
 Description:
 Filesize:  225 KB
 Viewed:  3715 Time(s)

sw2.jpeg


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 -> Lua Extensions 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