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 


Multi-address adder
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
condamor
Newbie cheater
Reputation: 0

Joined: 02 Jan 2017
Posts: 10

PostPosted: Mon Jan 02, 2017 12:07 pm    Post subject: Reply with quote

Ah okay.

I actually turned it into this:
Code:
    if _offset ~= nil then
        if type(_offset) == "table" then
            NewRecord.OffsetCount = #_offset
            local index = 0
            for i = #_offset, 1, -1 do
                --if type(_offset[i]) == "string" then
                    --NewRecord.OffsetText[index] = _offset[i]
                --else
                    NewRecord.Offset[index] = "0x" .. _offset[i]
                --end
                index = index + 1
            end
        else
            NewRecord.OffsetCount = 1
            NewRecord.Offset[0] = "0x" .. _offset
        end
    end


The ""0x" .. " is because I was wanting to pass the offsets in without the 0x part. Are there any reasons not to do it this way?

And then I commented out the rest because I only intend to pass strings in or a table of strings.

I see how it adds multiple offsets to the single address record. It did not dawn on me that the GUI did that lol I always wondered what the "add offset" and "remove offset" buttons did.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Mon Jan 02, 2017 12:14 pm    Post subject: Reply with quote

I updated my code to count strings as hex notation, if you are indeed sending values as strings.
Only concern with concatenating "0x" in front of the value is if they sent a decimal value.
Someone may send the decimal value 100 expecting it to be treated as decimal.
Your code would instead treat it as hex and the offset would be converted to decimal 256.
Back to top
View user's profile Send private message
condamor
Newbie cheater
Reputation: 0

Joined: 02 Jan 2017
Posts: 10

PostPosted: Mon Jan 02, 2017 12:55 pm    Post subject: Reply with quote

Alright, that looks great thank you so much!

So I think this is the final result for my code:

Code:
function AddRecordToCheatTable(_description, _address, _offset, _type, _length, _specificData, _parent)
    local CEAddressList = getAddressList()

    local NewRecord = CEAddressList.createMemoryRecord();

    NewRecord.Description = _description
    NewRecord.Address = _address
   
    if _offset ~= nil
        if type(_offset) == "table" then
            NewRecord.OffsetCount = #_offset
            local index = 0
            for i = #_offset, 1, -1 do
                local offset = _offset[i]
                if type(offset) == "string" then
                    offset = tonumber(offset, 16)
                end
                NewRecord.Offset[index] = offset
                index = index + 1
            end
        else
            if type(_offset) == "string" then
                _offset = tonumber(_offset, 16)
            end
            NewRecord.OffsetCount = 1
            NewRecord.Offset[0] = _offset
        end
    end

    if _type == "Array of Bytes" then
        _type = "Bytes"
    elseif _type == "AOB" then
        _type = "Bytes"
    elseif _type == "array of bytes" then
        _type = "Bytes"
    elseif _type == "aob" then
        _type = "Bytes"
    end
    if _type == "String" then
        NewRecord.Type = vtString
            if _length ~= nil then
                NewRecord.String.Size = _length
            end
        if _specificData ~= nil then
            NewRecord.String.Unicode = _specificData
        end

    elseif _type == "Binary" then
        NewRecord.Type = vtBinary
        NewRecord.Binary.Startbit = _specificData
        NewRecord.Binary.Size = _length

    elseif _type == "Double" then
        NewRecord.Type = vtDouble

    elseif _type == "Float" then
        NewRecord.Type = vtSingle

    elseif _type == "Bytes" then
        NewRecord.Type = vtByteArray
        NewRecord.Aob.Size = _length

    elseif _type == "Byte" then
        NewRecord.Type = vtByte
    elseif _type == "2 Bytes" then
        NewRecord.Type = vtWord
    elseif _type == "4 Bytes" then
        NewRecord.Type = vtDword
    elseif _type == "8 Bytes" then
        NewRecord.Type = vtQword
    end

    if _parent ~= nil then
        NewRecord.appendToEntry(_parent)
    else
        NewRecord.appendToEntry()
    end
    return NewRecord
end


Now what can be done to make sure this shows up in google really easy when people look for it? I spent a fair amount of time and effort googling to put what I started with together, now that there's a simple, usable solution for people I'd like for them to be able to find it.
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 All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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