Jump to content

Recommended Posts

It's a game bug.

From the The Big List Of Mod-Related Code Suggestions

Fix repairable item describe strings (multiple bugs exist; one can cause crashes)

Detailed here. Example fix here (the function is in stringutil.lua)

To fix it, you can add the below spoilered code to a file like <modfolder>/scripts/repairabledescriptionfix.lua and then put GLOBAL.require "repairabledescriptionfix" in your modmain.lua.

local function getcharacterstring(tab, item, modifier)    if modifier then        modifier = string.upper(modifier)    end     if tab then        local topic_tab = tab[item]        if topic_tab then            if type(topic_tab) == "string" then                return topic_tab            elseif type(topic_tab) == "table" then                if modifier and topic_tab[modifier] then                    return topic_tab[modifier]                end                 if topic_tab['GENERIC'] then                    return topic_tab['GENERIC']                end                 if #topic_tab > 0 then                    return topic_tab[math.random(#topic_tab)]                end            end        end    endendfunction GetDescription(character, item, modifier)    character = character and string.upper(character)    local itemname = item.components.inspectable.nameoverride or item.prefab    itemname = itemname and string.upper(itemname)    modifier = modifier and string.upper(modifier)     local ret = GetSpecialCharacterString(character)     if not ret then        if STRINGS.CHARACTERS[character] then            ret = getcharacterstring(STRINGS.CHARACTERS[character].DESCRIBE, itemname, modifier)        end                  if not ret and STRINGS.CHARACTERS.GENERIC then            ret = getcharacterstring(STRINGS.CHARACTERS.GENERIC.DESCRIBE, itemname, modifier)        end              if not ret and STRINGS.CHARACTERS.GENERIC then            ret = STRINGS.CHARACTERS.GENERIC.DESCRIBE_GENERIC        end              if ret and item and item.components.repairable and item.components.repairable:NeedsRepairs() and item.components.repairable.announcecanfix then            local repairstring = nil                  if STRINGS.CHARACTERS[character] and STRINGS.CHARACTERS[character].DESCRIBE then                repairstring = getcharacterstring(STRINGS.CHARACTERS[character], "ANNOUNCE_CANFIX", modifier)            end                  if not repairstring and STRINGS.CHARACTERS.GENERIC then                repairstring = getcharacterstring(STRINGS.CHARACTERS.GENERIC, "ANNOUNCE_CANFIX", modifier)            end                          if repairstring then                ret = ret..repairstring            end        end    end     return retend

EDIT: Updated with a better fix.

Edited by squeek

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...