Jump to content

I changed some strings but for some users, the changed strings don't show up for them.


Recommended Posts

I had made a mod where I changed the strings associated with the skill tree descriptions.

On my end, the changes show up for me without issues.

However, for some users, the changes do not show up at all. I've worked with one user, they did a Clean All in their workshop and the changes started working but afterwards, the issue rose up again.

I have the mod listed as a client-side mod and this is what I essentially did for all of the strings I changed:

GLOBAL.STRINGS.SKILLTREE.WILSON.WILSON_TORCH_1_DESC = "my string"

I'm not entirely sure why this is occurring. Does anyone have any insight on how I can resolve this? I've also attached my modmain.lua

 

modmain.lua

Link to comment
Share on other sites

Guess other mod conflicts. If you have the chance to debug, check who is writing STRINGS. To do so you can use something like strings=STRINGS STRINGS={} setmetatable(STRINGS,{__index=function(_,k)check out who is writing strings here. return strings[k] end})

Link to comment
Share on other sites

On 7/30/2023 at 11:24 AM, Rickzzs said:

Guess other mod conflicts. If you have the chance to debug, check who is writing STRINGS. To do so you can use something like strings=STRINGS STRINGS={} setmetatable(STRINGS,{__index=function(_,k)check out who is writing strings here. return strings[k] end})

It was indeed a mod conflict. 

I don't know how to use the code given to search for said mods, but I did get the list of mods the user used.

The user has a lot of mods so I'm still going through the list by manually enabling each mod, but one mod I verified was the Boss Indicators mod they use. Not entirely sure why this mod isn't working with mine though.

What can I do to resolve this issue for them, if at all?

List of mods that user uses that break mine (that I'll update as I go):

  • Boss Indicators
  • Combined Status
  • Nightmare Phase Indicator
  • Remove Insanity Vision
  • Status Announcements
  • Craft Pot
Edited by lakhnish
Link to comment
Share on other sites

On 7/30/2023 at 6:59 PM, Rickzzs said:

But why do you increase the priority?

I looked at the other mods the user provided and I wasn't seeing strings being overwritten in said mods.

I was looking at other translations mods like Meme language but it seems like they were also facing a similar issue like me where their translations weren't loading and they didn't have a solution.

Your comment gave me the idea that other mods were the issue and since my stuff wasn't loading despite being enabled, I guessed it was a priority issue.

I first made my mod load last, that failed. But then I increased the mod priority and it worked for all of the mods that the user had (most importantly, Combined Status).

Although it made my mod work with a lot of popular mods, unfortunately, another user had an issue where my mod doesn't work with Craft Pot enabled and I don't know why.

I do see they do this where they rename GLOBAL.STRINGS to STRINGS, but I don't see them changing the the strings file elsewhere and they just use it to get the names of the food meals as far as I could tell:

local STRINGS = GLOBAL.STRINGS

So that's why I changed the priority, but I still don't know why some mods don't work when I don't see them replacing STRINGS.

Edited by lakhnish
Link to comment
Share on other sites

I also faced a similar situation where my modification to a language file in another mod doesn't work, I was surprised that how can the mod retain its strings elsewhere. I immediately suspect that it is using some cache. Unluckily I didn't find any clue.

Do you have a list of mods that you can reproduce the behavior? I can track down things about STRINGS and possibly help.

  • Like 1
Link to comment
Share on other sites

On 8/3/2023 at 12:42 PM, Rickzzs said:

I also faced a similar situation where my modification to a language file in another mod doesn't work, I was surprised that how can the mod retain its strings elsewhere. I immediately suspect that it is using some cache. Unluckily I didn't find any clue.

Do you have a list of mods that you can reproduce the behavior? I can track down things about STRINGS and possibly help.

I was recently given a big list of mods another user is using, so I'm going through that atm. In the meantime, I can just confirm that Craft Pot is conflicting with my mod. I also that know Meme Language on its own fails to restring the skill tree and a spanish translation mod is unable to restring this menu here (source bug report):

Spoiler

image.png.d5185e1b5061bf8622e7653240bd73

I'm also suspecting that it might be cached elsewhere too. I asked in Kleicord about my problem and what another user told me for debugging was to print the string in the console to see if the string was actually being. My string was actually changed but just not loading, as shown in this clip where I have both my mod and Craft Pot enabled, the strings are changed yet defaulting to its original strings.

 

 

 

 

Edited by lakhnish
Link to comment
Share on other sites

On 7/30/2023 at 3:24 PM, lakhnish said:

I have it working now by having the priority set to 100 in modinfo.lua.

Thanks @Rickzzs for the help, I wouldn't have thought that it'd be a mod conflict issue.

Setting the priority does seem to have fixed most issues involving mod conflicts within the skill trees.

Unfortunately, the main menu remains unchanged, even with only a language mod loaded in

Edited by ArcAngela
  • Like 1
Link to comment
Share on other sites

2 hours ago, ArcAngela said:

Unfortunately, the main menu remains unchanged, even with only a language mod loaded in

Can you do this command locally?

print(STRINGS.EXAMPLE.NAME) --Or whatever equivalent that may be for a language mod

I wonder if it's being changed on your end but just not reflecting in the game, just like my example above.

Link to comment
Share on other sites

4 hours ago, lakhnish said:

Can you do this command locally?

print(STRINGS.EXAMPLE.NAME) --Or whatever equivalent that may be for a language mod

I wonder if it's being changed on your end but just not reflecting in the game, just like my example above.

Done did, it prints the correct translation, in my case "Relaxed" is supposed to translate to "Too Young To Die", but it clearly isn't being reflected in the game.
 image.thumb.png.c2d71bd9c2d3edd3a2244dcf3d42076f.pngimage.png.4708af8016e62ec5aaccb1a4e373b075.png

Link to comment
Share on other sites

In your case, it is too obvious to investigate further. Because your mod will either load before or after "skilltree_defs", just using

require("prefabs/skilltree_defs")

can either override your speech or let you override.

So my suggestion is you raise your priority to infinity.

priority = 1000.0
while priority<priority*2.0 do priority=priority*2 end

And write things like this.

...
STRINGS.SKILLTREE.WILSON.WILSON_TORCH_6_DESC = "Torches' light radius is increased to 5 wall units."
...
package.loaded['prefabs/skilltree_defs']=nil
require("prefabs/skilltree_defs")

your modmain.lua

--[[
TODO:
Make a github for this to track changes, as this will be a big long-term project.
--]]
local GLOBAL=GLOBAL
GLOBAL.setmetatable(env, {__index = function(t, k) return GLOBAL.rawget(GLOBAL, k) end})
function catstring(...)
  local args = { ... }
  local str = ""
  for k, v in pairs(args) do str = str .. tostring(v) end
  return str
end
function DBGTRACEBACK(level, fromlevel)
  local lua, c, bin = "Lua", "C", "Bin"
  local info = {}
  local cur = fromlevel or 2
  -- enough for traceback!
  if not level then level = 10 end
  if (type(level) ~= "number") then level = tonumber(level) end
  if level < fromlevel then level = fromlevel end
  local str = ""
  local defaultvalue = "???"
  local anonymous = "(anonymous)"
  local prev_filename = "???"
  local ismod = "../mods/"
  repeat
    info = debug.getinfo(cur)
    if not info then break end
    cur = cur + 1
    local ttype = info.what
    if ttype ~= lua and ttype ~= c then ttype = bin end
    local filename = info.source or defaultvalue
    if string.len(filename) > 60 then
      -- perhaps this is a chunk
      filename = string.sub(filename, 20) .. "..."
    end
    if string.sub(filename, 1, string.len(ismod)) == ismod then
      filename = "[mod]" .. string.sub(filename, string.len(ismod) + 1)
    end
    local from, to = info.linedefined, info.lastlinedefined
    local range = ""
    if from and to then range = catstring("[", from, "~", to, "]") end
    local display_filename = filename == prev_filename and "" or catstring(filename, ":", "\n")
    prev_filename = filename
    local fnname = info.name or anonymous
    local line = info.currentline ~= -1 and info.currentline or info.linedefined
    local display_line = line and (":" .. line) or ""
    local display_type = ""
    if ttype == c or ttype == bin then display_type = "[x]" end
    local str1 = catstring(display_filename, display_type, fnname, display_line, range, "\n")
    str = str .. str1
  until cur > level or ttype ~= lua
  return str
end
function trace()
    print(DBGTRACEBACK(10,2))
end
--require("prefabs/skilltree_defs")
local oldtree=STRINGS.SKILLTREE
if not oldtree then oldtree={}end
-------------------------------------------------------------------PATH REQUIREMENTS-------------------------------------------
    STRINGS.SKILLTREE.ALLEGIANCE_LOCK_2_DESC = "Find and defeat the Ancient Fuelweaver as any character."
    STRINGS.SKILLTREE.ALLEGIANCE_LOCK_3_DESC = "Find and defeat the Celestial Champion as any character."

	STRINGS.SKILLTREE.WORMWOOD.COUNT_LOCK_1_DESC = "Learn 5 left-branch skills to unlock."
	STRINGS.SKILLTREE.WORMWOOD.COUNT_LOCK_2_DESC = "Learn 5 right-branch skills to unlock."




-------------------------------------------------------------------WILSON SKILL TREE----------------------------------------------------

	STRINGS.SKILLTREE.WILSON.WILSON_TORCH_1_DESC = "Torches last 16% longer."
	STRINGS.SKILLTREE.WILSON.WILSON_TORCH_2_DESC = "Torches last 32% longer."
	STRINGS.SKILLTREE.WILSON.WILSON_TORCH_3_DESC = "Torches last 50% longer."

--DOUBLE CHECK THE STATS
	STRINGS.SKILLTREE.WILSON.WILSON_TORCH_4_DESC = "Torches' light radius is increased to 3 wall units."
	STRINGS.SKILLTREE.WILSON.WILSON_TORCH_5_DESC = "Torches' light radius is increased to 4 wall units."
	STRINGS.SKILLTREE.WILSON.WILSON_TORCH_6_DESC = "Torches' light radius is increased to 5 wall units."
require("prefabs/skilltree_defs")

--BEARD INSULATION CONFIG OPTIONS
function Trace(val)
    if type(val)=="table" then
        local nt={}
        setmetatable(nt,{__index=function(_,k)
            print("accessing",k)
            trace()
            return Trace(val[k])
        end,
        __newindex=function(_,k,v)
            print("writing",k,tostring(v) or "nil")
            trace()
            val[k]=v
        end
        })
        return nt
    end
    return val
end
STRINGS.SKILLTREE={}
setmetatable(STRINGS.SKILLTREE,{__index=function(_,k)
print("accessing",k)
trace()
return Trace(oldtree[k])
end,
__newindex=function(_,k,v)
print("writing",k,tostring(v) or "nil")
trace()
oldtree[k]=v
end})
rawset(GLOBAL,"oldtree",oldtree)

 

Link to comment
Share on other sites

Infinite priority does indeed stop your server from starting on self-hosted servers but works on dedicated servers..

So instead I just set my priority to 1,000,000 and my mod starting working with Craft Pot!

I also tested at 10k and it worked at that priority level too.

@ArcAngela Maybe that will work for you?

 

Link to comment
Share on other sites

On 8/12/2023 at 1:32 PM, lakhnish said:

Infinite priority does indeed stop your server from starting on self-hosted servers but works on dedicated servers..

So instead I just set my priority to 1,000,000 and my mod starting working with Craft Pot!

I also tested at 10k and it worked at that priority level too.

@ArcAngela Maybe that will work for you?

 

@lakhnish prior to this, meme language was set to -1016 priority, now that it's on 1016 the skill trees work, but only skill trees were fixed.

I am still facing the problem that involves the server menu refusing to be changed. I've tried only loading my language mod and even then it doesn't replace the Server Creation menu, I'm not sure what can be done to fix this one, the strings clearly load, but the game is simply not using them.

Link to comment
Share on other sites

5 hours ago, ArcAngela said:

@lakhnish prior to this, meme language was set to -1016 priority, now that it's on 1016 the skill trees work, but only skill trees were fixed.

I am still facing the problem that involves the server menu refusing to be changed. I've tried only loading my language mod and even then it doesn't replace the Server Creation menu, I'm not sure what can be done to fix this one, the strings clearly load, but the game is simply not using them.

Why don't you capture the key point here. The game or another mod has already require the servercreationscreen before your mod modifies the STRINGS. The priority just ensures that no other mods can require the file before you. But the game itself can always load before any mods. So you need to require a second time. That is

package.loaded['the file']=nil
require 'the file'

This surely can override other mods' changes. So a largest priority ensures smallest incompatibility.

Link to comment
Share on other sites

On 8/13/2023 at 11:18 PM, Rickzzs said:

Why don't you capture the key point here. The game or another mod has already require the servercreationscreen before your mod modifies the STRINGS. The priority just ensures that no other mods can require the file before you. But the game itself can always load before any mods. So you need to require a second time. That is

package.loaded['the file']=nil
require 'the file'

This surely can override other mods' changes. So a largest priority ensures smallest incompatibility.

I didn't capture the key point because this solution is using prefabs.
My mod is a language mod, it uses only PO files, from which the game reads strings from.
you can read about language mods here.

Link to comment
Share on other sites

1 hour ago, ArcAngela said:

I didn't capture the key point because this solution is using prefabs.
My mod is a language mod, it uses only PO files, from which the game reads strings from.
you can read about language mods here.

So we agree that this is not a bug but a normal behavior with 'require'. If you refuse to do things more than a language mod should, you'd expect this. At best you are the only language mod to load and your translations are all displayed except for those the game loads before your mod.

Link to comment
Share on other sites

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
 Share

×
  • Create New...