Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script not setting a tostring(index) into a (value) of a different table?

Asked by 5 years ago
Edited 5 years ago

I have no idea why it won't do it.

getCommands = function() -- WIP
        local result
        local functions
        functions = {}
        print(functions)
        local toChar = CVExtra.toCharList
        local toString = CVExtra.charlistToString
        local function searchTable(tab,nam)
            local parent = ""
            for i,v in pairs(tab) do
                if tab==nil or nam==nil or tostring(tab)==CVExtra then
                    parent=""
                else
                    local nam2 = toChar(nam)
                    nam = toString(nam2)
                    print(nam)
                    print(nam2)
                    parent=""..nam
                end
                if typeof(v)=="function" then
                    print("function")
                    local funcr = ""..tostring(i)
                    local func = toChar(funcr)
                    funcr = toString(func)
                    func = funcr
                    if parent=="" then

                    else
                        func = parent.."."..funcr
                    end
                    table.insert(functions,func)
                elseif typeof(v)=="table" then
                    print("table")
                    searchTable(v,tostring(i))
                end
            end
            return tab
        end
        result = searchTable(CVExtra)
        return result
    end

Since concatenation wasn't working, I used one of my scripts that changes the individual letters of a string (toChar) to a table of individual letters. Then has it converted back into a string with toString (custom function)

I've done numerous prints to test and figure out where it goes wrong, but I think it's Roblox. Because somehow even though I set the value of another table to a string, turn it into a table then back into a string and concatenate it, it still puts it as an index for another table, a dictionary.

Of course, the only other alternate solution I could think of is to get the names of the things I want printed, into a table for the script to print, but I want it to get the "commands" I have from my module I am making.

(Edit)

For anyone wondering, "CVExtra" is a table with functions and other tables in it.

0
Why are you reinventing the wheel, no need for your own tostring User#24403 69 — 5y

Answer this question