• 0

    posted a message on strsplit problem
    The function ended up looking like this, but still didn't work right:

    function mystrsplit(splitter, text)
        local tbl = {}
        for v in string.gmatch(text, splitter) do
            tinsert(tbl, v)
        end
        if #tbl >0 then
            return unpack(tbl)
        end
        return ""
    end


    It failes with this string:

    text = "A>>B"

    when called with:

    printbyte(mystrsplit("[^\>]+", text))

    Result is two strings, "A" and "B". strsplit returns 3 strings: "A", "" and "B"

    *sigh*
    Posted in: Lua Code Discussion
  • 0

    posted a message on strsplit problem
    So my splitter function looks like this:
    function mystrsplit(splitter, str)
    local tbl = {}
    for v in string.gmatch(text, splitter) do
    tinsert(tbl, v)
    end
    return unpack(tbl)
    end

    And seems to work fine.
    Posted in: Lua Code Discussion
  • 0

    posted a message on strsplit problem
    Just stumbled upon "unpack"... takes an array and returns the elements as arguments. :-)

    I was thinking about the recursive solution you wrote but decided that would be going over the top. :-P
    Posted in: Lua Code Discussion
  • 0

    posted a message on strsplit problem
    I have to admit my test was faulty. And my problem not well described.

    I wanted to split a string at each splitchar, but the splitchar is not \000. It is ">".

    I do want to split a string that contains zero valued bytes, and strsplit failed on that.

    I have (just now, before reading your solutions) retried gmatch and where it failed yesterday, it worked today. I must have made made an error. :-/

    This code apparently works fine:

    local tbl = {}
    for v in string.gmatch(text, "[^\>]+") do
    tinsert(tbl, v)
    end

    Now, with that working, is there an easy way to get tbl as a number of arguments for a function call? I.e. have it working just like strsplit.
    Posted in: Lua Code Discussion
  • 0

    posted a message on strsplit problem
    Neither find nor gmatch handle zero values bytes correctly which is a shame since almost eveyrthing else in Lua works properly with zery values bytes.

    gsub works (fortunately) so I have encoded my raw datastream so zero valued bytes aren't present, but it does mean a lower efficiency in my code. Too bad, but we have to use what there is. :-/
    Posted in: Lua Code Discussion
  • 0

    posted a message on LibCompress
    I also want to add checksum algorithms to LibCompress so you can make a more secure check if the compressed data is ok or not (before uncompressing it).

    Currently I have FCS (16 and 32 bit versions).
    Posted in: Libraries
  • 0

    posted a message on strsplit problem
    I have a string with zero byte values in and I would like to split the string at a character just like strsplit offers. Problem is, strsplit only works up to the first zero byte value in the string and then throws the rest of the string away.

    Does any of you know any alternative?
    Posted in: Lua Code Discussion
  • 0

    posted a message on LibCompress
    My optimised version of the huffman compressor/decompressor had two bugs. Both are fixed in the r32-release of LibCompress.

    Future plans for LibCompress include:

    - Encode/Decode (with optional list of reserved characters and quote-bytes). This will provide the possibility to encode for any channel with any number of reserved bytes.
    Possible syntax:

    codec = LibCompress:GetEncoder(reservedchars, quotebytes)

    encodedData = codec:Encode(compressedData)

    compressedData = codec:Decode(encodedData)

    The reservedchars contains a string with characters that may not occur in th encoded data. Quotebytes contains the characters(s) necessary to perform the encoding. OF course, the bytes in quotebytes may not appear in reservedchars.

    - Encode/Decode to/from 7-bit characters to 8-bit bytes. This is motivated by the fact that encoding raw huffman data for the chat channel will make the size increase a lot, neglecting any compressing gained with huffman. Reducing from 8 bit to 7 bit will only cause a slight increase in size, requiring much less encoding. Huffman compression will still save bandwidth in this case.

    Suggestion API:
    Encoding:
    sevenbitencoded = LibCompress:Encode7bit(rawdata)

    Decoding:
    rawdata = LibCompress:Decode7bit(sevenbitencoded)

    This could have been built into huffman compression/decompression with 0 speed penalty, but LibCompress has to offer this for all compressors/decompressors which is why I think a separate function should be offered.

    - Support for predefined symbol statistics for the huffman compressor. For short strings to be compressed, the symbol map is a large part of the compressed data and can neglect any compression gained. Even suboptimal symbol map statistics could provide a gain in compression. This change will not be backwards compatible though.
    Posted in: Libraries
  • 0

    posted a message on Compression algorithms
    I have been back for over 1,5 month and have been watching GuildAds and LibCompress during my away time in case of problems. I paused WoW because it was stale and resubscribed to make GuildAds work with patch 3 (LibCompress was pure Lua and I didn't expect problems there). The tag and toc change I see no problem with.

    I do want to be lead if jjsheets doesn't object. I have more to add to LibCompress; encode/decode (with customized reserved characters), crc-checks (I have fcs16/32 right now), custom static compress statistics for huffman to help reduce compressed size, incremental compression (with callback to minimized lag spikes... going to require some internal changes) and what else people may want.

    If I came on too hard in my posts, it was because this takeover was very unexpected.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Compression algorithms
    Quote from Allara
    Yes, I've got an add-on that makes great use of compression. See the following projects:

    LibCompress
    QuestAgent

    The development discussion for LibCompress is here.

    Let me know if you have any questions.


    I am wondering why I am not the author of LibCompress, or at least jjsheets2 (the original author). After all, I did add most code to LibCompress and optimised my huffman compression quite a bit. Could we please get this fixed?
    Posted in: Lua Code Discussion
  • 0

    posted a message on MD5 or CRC-32 hash in Lua
    In GuildAds, I use the FCS16 hash (16 bit hash). It is quite fast. I also have a FCS32 algorithm that has pretty much the same speed.

    Eventually, I want to add them to LibCompress where they really do belong (not that they compress, but is the best way to verify correctness of compressed data without attempting to uncompress it).
    Posted in: Lua Code Discussion
  • 0

    posted a message on ChatFrame_AddMessageEventFilter or ???
    I have a similar issue with ChatFrame_AddMessageEventFilter. In my case, I want to filter based on the channel the message arrives on.

    I see little other choice than to hook ChatFrame_OnEvent (or something like that). :-/
    Posted in: Lua Code Discussion
  • 0

    posted a message on Wiring a file via Lua
    You could join a custom chat channel and output your log information to that channel. By enabling chat logging, you get a file with all your chat activity (and therefore also your log-channel). That log is written during gameplay.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Calling JoinPermanentChannel upon login
    When is it safe to call JoinPermanentChannel at login? When called too early, it is being ignored, and joining it late (30 second delay? 1 minute?) is not a great solution either.

    Is there an event I can listen for after which it is known to be safe to call JoinPermanentChannel?

    I was using JoinChannelByName but it being replaced by JoinPermanentChannel as far as I can tell, but the same problem apply.
    Posted in: Lua Code Discussion
  • 0

    posted a message on LibCompress
    Of course. :-P

    But it hasn't been implemented yet. My wow account has expired and I may not return. Blizzard's arena elitism and warlock changes are just not fun for me.

    For the time being I encourage you to do your own encoding/decoding. If you need to encode for the chat channel, I can recommend having a look at GuildAds that has implemented a working chat channel encoding/decoding algorithm (pretty much a bug fixed Ace2 encode/decode).
    Posted in: Libraries
  • To post a comment, please or register a new account.