Results 1 to 7 of 7

[SCAR] _G viewer

  1. #1
    Member Janne252's Avatar
    Join Date
    Aug 2009
    Location
    Finland

    [SCAR] _G viewer

    Just a simple script with some handy paging and configuration to see what is available in _G (global functions such as Entity_Kill, taskbar_hide, etc.)

    known_list table


    PHP Code:
    --replace this with the full list provided above
    local known_list 
    = {}
    local funcCount 0
    local resultCount 
    0
    local new_list 
    = {}
    local start 1
    local pageSize 
    40
    local stop 
    pageSize
    local page 
    1
    local skipKnown 
    true
    bind
    ("CONTROL+SHIFT+SPACE""Toggle_ViewPage()")

    for 
    keyvalue in pairs(_G) do
        
    local keyString tostring(key)
        
    local valueString tostring(value)
        if 
    type(value) == "function" then
            funcCount 
    funcCount 1
            local found 
    false
            
    for key2known in ipairs(known_list) do
                if 
    known == keyString then
                    found 
    true
                end
            end
            
    if not found or not skipKnown then
                table
    .insert(new_listkeyString)
                
    resultCount resultCount 1
            end
        end
    end

    print("unkown function count: "..funcCount)
    print(
    "result count: "..resultCount)

    function 
    DisplayText(text)
        
    dr_clear("UI")
        
    dr_setautoclear("UI"false)
        
    dr_text2d("UI"0.0150.02text255255255)  
    end

    function _getNextFullNumber(decimal)
        
    decimal decimal 1
        local text 
    tostring(decimal)
        
    local start string.find(text"."1true)
        return 
    tonumber(text:sub(0start))
    end

    function Toggle_ViewPage()    
        
    local listString ""
        
    for startstop do
            
    listString listString..new_list[i].."\n"
        
    end
        local currentPage 
    table.getn(new_list) / pageSize
        DisplayText
    ("Page: "..page.."/".._getNextFullNumber(currentPage).. ", functions "..start.." to "..stop.." of "..table.getn(new_list).."\n----------------------------------\n"..listString)

        
    page page 1
        start 
    start pageSize
        stop 
    stop pageSize
        
    if start table.getn(new_listthen
            start 
    1
            stop 
    pageSize
            page 
    1
        end
        
    if stop table.getn(new_listthen
            stop 
    table.getn(new_list)
        
    end
    end 
    Known list is based on a scan over RelicCoH2.exe

  2. #2
    Member eliw00d's Avatar
    Join Date
    Jul 2008
    Location
    Duluth, MN
    Code:
    table.insert(new_list, keyString)
    Code:
    for i = start, stop do
        listString = listString..new_list[i].."\n"
    end
    This might result in an error, since you are creating an associative array, but accessing values by index instead of key.

  3. #3
    Member Janne252's Avatar
    Join Date
    Aug 2009
    Location
    Finland
    So far not, as I've done stuff like this as long as I can remember.

  4. #4
    Member eliw00d's Avatar
    Join Date
    Jul 2008
    Location
    Duluth, MN
    Perhaps the keys you are using are integers, then. Otherwise, if they were strings, it would result in an attempt to concatenate field '?' (a nil value) error.

    Edit: Actually, in this case, it is because your stop is higher than the _G table size in my example.

  5. #5
    Member Janne252's Avatar
    Join Date
    Aug 2009
    Location
    Finland
    What do you mean? I'm not pulling stuff from _G with stop as you can see in the code.

  6. #6
    Member eliw00d's Avatar
    Join Date
    Jul 2008
    Location
    Duluth, MN
    Well, you build new_list from _G, so if new_list has less entries than the stop variable, it will error as seen above.

  7. #7
    Member Janne252's Avatar
    Join Date
    Aug 2009
    Location
    Finland
    It's protected already at the bottom of the code:
    PHP Code:
        if start table.getn(new_listthen
            start 
    1
            stop 
    pageSize
            page 
    1
        end
        
    if stop table.getn(new_listthen
            stop 
    table.getn(new_list)
        
    end 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •