1. This forum is for bug reporting of current Live Game Server issues ONLY.
    Be sure to follow the format below, it will help us out greatly in responding. If you do not, your report may not be entered into the system.

    Read BEFORE submitting your first bug: Reporting Bugsā€¦ QA 101 Document
    • Search for your bug in all likely categories before posting in order to avoid duplicate reports.
    • Be sure to provide details of what the issue is and how to re-produce it, but keep your bug report factual.
    • Reply to an existing thread if you have additional information for the reported bug.
      Do not use this forum for commentary, your post will be deleted and you may be moderated, suspended or banned if the activity continues.
    • There is no need to submit crash logs. Crash data we require is automatically logged.
    NOTE: Important information including your location and system specs are automatically put into your clipboard when using /bug in the game (DO NOT add additional system specs unless requested). When starting your post, just use <CTRL>-V to insert the data and fill in the entries with no data.

    Please include Screenshots if possible. Images can be saved on our SotA Discord Server here

    If the clipboard does not work, use and fill in this Bug Report Template:
    1. Title:
    2. Reproducible?
    3. Blocker?
    4. Details:
    5. Steps to Reproduce:
    6. User Specs: (RAM, CPU, GPU and Operating System only)
    Dismiss Notice

Lua error "... too complex" occurs for only one of my avatars not the rest

Discussion in 'Lua API' started by Kelly O'Shay, Jun 26, 2020.

  1. Kelly O'Shay

    Kelly O'Shay Avatar

    Messages:
    393
    Likes Received:
    290
    Trophy Points:
    43
    06/26/2020 19:57
    Title:
    Reproduction Rate:
    Blocker?
    Details:
    Steps to Reproduce:
    User Specs:
    OS: Windows 10 (10.0.0) 64bit
    CPU: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz (8) System RAM: 12212
    GPU: NVIDIA GeForce GT 740 GPU RAM: 2007
    SotA.Win.64.1248.Date.06.26.20
    Area: POT_forest_metropolis_02_template/Cottage Grove
    Area Display Name: Cottage Grove
    Loc: (-39.6, 44.7, -31.9)
    Debug: UE9UX2ZvcmVzdF9tZXRyb3BvbGlzXzAyX3RlbXBsYXRlfENvdHRhZ2UgR3JvdmV8KC0zOS41NzUsIDQ0LjY4OCwgLTMxLjg2NSl8KDAsIDAuOTk5LCAwLCAtMC4wNCl8MTg0LjU4NTh8MTB8Mi42NDY3NzY=

    This avatar was created on a new account after the lua had been installed and was working ok for my other account. Maybe there is a problem with an avatar being added to the windows 10 filoe system after the lua has already been used before.

    I tried /lua unload and that worked to unload the lua and the error message stopped. But when I reloaded the lua with /lua reload the error recurred so I had to use /lua unload to stop it again.

    This lua script will work fine still with my other avatars on the previous account.

    [​IMG]

    [​IMG]

    [​IMG]

    Code:
    --[[
        ------------------ ad.lua ----------------------
        A very basic script that will display a number of statistics in the lower right (by default) section of your SOTA screen.
        I've borrowed bits and pieces from scripts that have been already posted to the SOTA LUA forums.  My thanks to the many
        people that hang out there for some of the ideas behind this.
        
        My goal was to have a simple tracker of various items in my inventory as I'm mining, farming or cutting timber.  I get
        tired of continually opening up my inventory to see where I am on a certain run.
        
        The script consists of this file and an optional ad.settings.ini file which holds the names of the various items that you
        want to track.
        
        To run this script:
            1. Install into the lua directory of your SOTA install (on my machine this is in my %appdata% directory.   I'm not sure
            where it would be located on a Linux box, but if your running SOTA on Linux then you are likely intelligent enough to know
            where this is.
            
            2. Create a file named ad.settings.ini in the same directory you installed this file to (see item #1 if you've forgotten that already).
            
            3. Modify the file ad.settings.ini to look like this:
                
                [Settings]
                menuX=-230
                menuY=14
                watch=Metal Scrap, Iron Ore
    
            4. The important item here is the "watch" line.  Add the items you're interested in watching to this line.  Each item MUST be spelled
                 exactly as it is in your inventory and each item must be separated by a comma.  This is important. 
                
                 Also, as of this writing (12/27/2019) the names are case sensitive. 
                 Remember, I wrote this for myself and there is work still to be done but I wanted to get it out into the wild and get some
                 more eyes on it.
                
        So give it a try.  It's not fancy, but it does the job.
        -arthur dent (aka, jeff bryant)
    --]]
    
    local posX = 200;
    local posY = 400;
    local watching = ""
    local isWatching = false;
    local aWatching
    local watchCount = 0
    local whatToWatch = "";
    local isLoaded = false;
    
    function trim(s)
       return (s:gsub("^%s*(.-)%s*$", "%1"))
    end
    
    function split(str, pat)
        local t = {}  -- NOTE: use {n = 0} in Lua-5.0
        local fpat = "(.-)" .. pat
        local last_end = 1
        local s, e, cap = str:find(fpat, 1)
      
       while s do
          if s ~= 1 or cap ~= "" then
              table.insert(t,cap)
              if watchCount==0 then
                watchCount = 1
              else
                watchCount = watchCount + 1;
              end
          end
          last_end = e+1
          s, e, cap = str:find(fpat, last_end)
       end
       if last_end <= #str then
          cap = str:sub(last_end)
          table.insert(t, trim(cap))
          watchCount = watchCount + 1;
       end
       return t
    end
    
    
    function displayStatus()
        if isLoaded == true then
            items = ""
            whatToWatch = ""
            watchCount = 0;
            inventory = ShroudGetInventory();
            aWatching = split(watching,",");
            aDisplay = {}
            
            
            for i = 1, watchCount do   
                aDisplay[aWatching[i]] = {aWatching[i], 0};
                
                for _, item in ipairs(inventory) do
                    local name,
                        durability,
                        primaryDurability,
                        maxDurability,
                        weight,
                        quantity,
                        value = item
                        
                        if (trim(name) == trim(aWatching[i])) then
                            aDisplay[aWatching[i]] = { trim(name), quantity };
                        end
                end
            end
    
            for i = 1, watchCount do
                if whatToWatch == "" then
                    whatToWatch = string.format("%s:\t%s", aDisplay[aWatching[i]][2],aDisplay[aWatching[i]][1] )
                else
                    whatToWatch = string.format("%s\n%s:\t%s",whatToWatch,aDisplay[aWatching[i]][2],aDisplay[aWatching[i]][1]);
                end
            end
            whatToWatch = string.format("%s\t\n",whatToWatch);
            iWatching = true;
            statsToDisplay = string.format("%sAdv Pool:\t%s\nProd Pool:\t%s",whatToWatch, comma_value(ShroudGetPooledAdventurerExperience()), comma_value(ShroudGetPooledProducerExperience())) 
        end
    end
    
    function size(T)
      local count = 0
      for _ in pairs(T) do count = count + 1 end
      return count
    end
    
    -- Lifted from the lua script Amalgamate by DevilCult
    function LoadSettings(fileName)
    
        local file = assert(io.open(fileName, 'r'), 'Error loading file : ' .. fileName);
        local data = {};
        local section;
        
        for line in file:lines() do
            local tempSection = line:match('^%[([^%[%]]+)%]$');
        
            if(tempSection)then
                section = tonumber(tempSection) and tonumber(tempSection) or tempSection;
                data[section] = data[section] or {};
            end
    
            local param, value = line:match('^([%w|_]+)%s-=%s-(.+)$');
    
            if(param and value ~= nil)then
                if(tonumber(value))then
                    value = tonumber(value);
                elseif(value == 'true')then
                    value = true;
                elseif(value == 'false')then
                    value = false;
                end
                if(tonumber(param))then
                    param = tonumber(param);
                end
                data[section][param] = value;
            end
        end
    
        file:close();
        return data;
    end
    
    function InitAD()
        local path = ShroudLuaPath.."\\ad.settings.ini"
        local settings;
        settings=LoadSettings(path)
        watching = settings.Settings.watch;
    end;
    
    function comma_value(n) -- credit http://richard.warburton.it
        local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
        return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right
    end
    
    function ShroudOnStart()
        InitAD()
        ShroudRemovePeriodic("sotadbinfo.UpdatePool")
        displayStatus()
        ShroudRegisterPeriodic("sotadbinfo.UpdatePool", "displayStatus", 1, true)
        screenPosX = ShroudGetScreenX() - posX
        screenPosY = ShroudGetScreenY() - posY
    end
    
    function ShroudOnGUI()
      ShroudGUILabel(screenPosX, screenPosY, posX, posY, statsToDisplay)
        isLoaded=true;
    end
    
    the following is a config file for the above lua

    Code:
    [Settings]
    menuX=-210
    menuY=140
    watch=Arrow,Black Pearl,Corpse Wax,Garlic,Mandrake Root,Nightshade,Obsidian Chip,Serpent Scales,Spider Silk,Sulfurous Ash,Silver Ore
    
    
     
  2. Toular

    Toular Avatar

    Messages:
    419
    Likes Received:
    418
    Trophy Points:
    43
    I started getting that on one of my Lua scripts also. I know for certain that it did not do that in the past. I fixed it by breaking--up the "match" into two separate statements. Less efficient because it's now two calls to match, but ... ok.

    Of course it may also "technically" be a bug on the script, which the script's developer would have to fix, not Portalarium.
     
    Last edited: Jun 29, 2020
    tioga trailrunner likes this.
  3. Kelly O'Shay

    Kelly O'Shay Avatar

    Messages:
    393
    Likes Received:
    290
    Trophy Points:
    43
    But, why would the same script only give this error for the new account, and all the avatars on the old account still don't get the error?
     
  4. Toular

    Toular Avatar

    Messages:
    419
    Likes Received:
    418
    Trophy Points:
    43
    I wondered the exact same thing. Simple answer is that it shouldn't, unless there's some logic in the script that executes some code in the script for the one account that for the other account (or character) does not.
     
  5. tioga trailrunner

    tioga trailrunner Avatar

    Messages:
    38
    Likes Received:
    21
    Trophy Points:
    8
    Location:
    California, Central Valley
    Kelly, send me the ad.settings.ini file via discord. I suspect that there's something in it that I'm not handling correctly.
     
    Anpu likes this.
  6. Kelly O'Shay

    Kelly O'Shay Avatar

    Messages:
    393
    Likes Received:
    290
    Trophy Points:
    43
    This is it, as shown above. Is that what you meant?

    Code:
    [Settings]
    menuX=-210
    menuY=140
    watch=Arrow,Black Pearl,Corpse Wax,Garlic,Mandrake Root,Nightshade,Obsidian Chip,Serpent Scales,Spider Silk,Sulfurous Ash,Silver Ore