not sure if it's a bug, but ...

Discussion in 'Lua Discussions' started by Feldon Grimshaw, Nov 12, 2019.

Thread Status:
Not open for further replies.
  1. Feldon Grimshaw

    Feldon Grimshaw Avatar

    Messages:
    257
    Likes Received:
    449
    Trophy Points:
    28
    Iin the "ShroudOnConsoleInput" method, if i grab every line that has a type of "CombatSelf" or "CombatOthers", and also contains the words "and hits" - meaning combat is going on and a hit took place,

    IF i then do one or more string.match(...) with some pattern in there, funky things begin to happen. For example, if i'm fighting a large wolf, with 220 health, normally i just whack it once or twice and it's dead, BUT with this parsing going on, i literally have to hit it for about 30 seconds before it dies, doing several thousand points of danage to it. but if i comment the string.match out, it goes back to normal.

    and if instead of using string.match, i use string.find and string.sub to accomplish the same things, there's no problem.

    so somehow calling string.match is gumming up the system.
     
    StarLord and Sara Dreygon like this.
  2. Drake Aedus

    Drake Aedus Avatar

    Messages:
    536
    Likes Received:
    886
    Trophy Points:
    75
    Gender:
    Male
    This deserves more testing.
     
  3. Feldon Grimshaw

    Feldon Grimshaw Avatar

    Messages:
    257
    Likes Received:
    449
    Trophy Points:
    28
    i will post a simple script demonstrating the issue later tonight when i'm done with work.
     
  4. Feldon Grimshaw

    Feldon Grimshaw Avatar

    Messages:
    257
    Likes Received:
    449
    Trophy Points:
    28
    ok, i've created a short video showing off the issue, and i'll include the code snippet if you would like to try it yourself.

    @Drake Aedus @Chris

    https://www.twitch.tv/videos/507959658

    Code:
    function ShroudOnConsoleInput(type, player, message)
        -- message has a preamble "to <recipient[s]> [<type>]: the message"
        --this will strip off the extra stuff in front and deliver just "the message"
        local msg = string.match(message, '.*: (.*)')
    
        if (type == 'CombatSelf' or type == 'CombatParty') and string.find(msg, 'and hits') ~= nil then
            --this parses out the victim of the attack, but doing it this way causes bad things during combat
            local victim = string.match(msg, '.*attacks (.*) and hits.*')
    
            --this code does the equivalent thing, but doesn't cause bad things during combat
            --local victim = string.sub(msg, string.find(msg, 'attacks')+8, string.find(msg, ' and hits')-1)
    
            ConsoleLog('combat victim: ' .. victim)
        end
    
    end
     
  5. Drake Aedus

    Drake Aedus Avatar

    Messages:
    536
    Likes Received:
    886
    Trophy Points:
    75
    Gender:
    Male
    Next wild breaking test, string.match incoming damage and see if you before invincible, lol...
     
  6. DavidDC

    DavidDC Programmer Moderator SOTA Developer

    Messages:
    1,532
    Likes Received:
    3,236
    Trophy Points:
    113
    Gender:
    Male
    an error in code stop all receiving packet or sending or something which do that. Error shouldnt stop anything
     
Thread Status:
Not open for further replies.