You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When this mod and the Prefab Counter mod up to version 1.0.1 are both enabled, the server will crash:
[00:00:03]: Mod: mod-dont-starve-prefab-counter (Prefab Counter) [INFO ] starting
[00:00:03]: Mod: mod-dont-starve-prefab-counter (Prefab Counter) [INFO ] CFG: log level set to INFO
[00:00:03]: Mod: mod-dont-starve-prefab-counter (Prefab Counter) [INFO ] finished initialization
[00:00:03]: Mod: mod-dont-starve-chat-announcements (Chat Announcements) Loading modworldgenmain.lua
[00:00:03]: Mod: mod-dont-starve-chat-announcements (Chat Announcements) Mod had no modworldgenmain.lua. Skipping.
[00:00:03]: Mod: mod-dont-starve-chat-announcements (Chat Announcements) Loading modmain.lua
[00:00:03]: Mod: mod-dont-starve-prefab-counter (Prefab Counter) [INFO ] starting initialization
[00:00:03]: Mod: mod-dont-starve-prefab-counter (Prefab Counter) [INFO ] initializing DiscordClient
[00:00:03]: SimLuaProxy::QueryServer()
[00:00:03]: Mod: mod-dont-starve-prefab-counter (Prefab Counter) [INFO ] installing monster death announcement handlers
[00:00:03]: MOD ERROR: mod-dont-starve-chat-announcements (Chat Announcements): Mod: mod-dont-starve-chat-announcements (Chat Announcements)
[00:00:03]: Event data unavailable: lavaarena_event_server/lavaarena_achievement_quest_defs
[00:00:03]: [string "../mods/mod-dont-starve-chat-announcements/..."]:281: bad argument #1 to 'pairs' (table expected, got nil)
LUA ERROR stack traceback:
=[C] in function 'pairs'
../mods/mod-dont-starve-chat-announcements/modmain.lua(281,1) in function 'main'
../mods/mod-dont-starve-chat-announcements/modmain.lua(323,1) in main chunk
=[C] in function 'xpcall'
scripts/util.lua(754,1) in function 'RunInEnvironment'
scripts/mods.lua(558,1) in function 'InitializeModMain'
scripts/mods.lua(532,1) in function 'LoadMods'
scripts/main.lua(343,1) in function 'ModSafeStartup'
scripts/main.lua(449,1) in function 'callback'
scripts/modindex.lua(103,1) in function 'BeginStartupSequence'
scripts/main.lua(448,1) in function 'callback'
scripts/modindex.lua(735,1)
=[C] in function 'GetPersistentString'
scripts/modindex.lua(709,1) in function 'Load'
scripts/main.lua(447,1) in main chunk
The affected mod is the Chat Announcements mod here, as visible in the incorrect modname in the log entries, which have been overwritten with Prefab Counter data, as well as the bad argument #1 to 'pairs' error, which refers to an externally defined constant table, which should never be nil.
Running either mod alone does not cause any issue.
The text was updated successfully, but these errors were encountered:
The root cause was manipulation of the global package path for the require() calls, combined with using identical names for the const, util, and logging modules in both mods. The later mod, Chat Announcements, will encounter a package.path manipulated to look up modules in the Prefab Counter directory first, finds matching filenames, and imports them. That way the logging module will have a wrong modname stored, and the constants used in Chat Announcements are undefined in the Prefab Counter constants module, causing the bad argument in the log.
Instead of shuffling the lookup order around, or doing other shenanigans with the package path, I'll use Klei's modimport() instead, despite its many shortcomings. It's good enough for small projects, and should not affect other mods in any way.
Manipulating GLOBAL.package.path to be able to use require() nicely
messes up the package.path for all mods being loaded after this one, so
it has to be avoided.
Klei's modinfo() function does not return a value, isn't cached nor
guarded against repeated inclusion, and "dependencies" need to be
resolved manually by importing in the correct order. All a bit iffy,
but for a project this size probably okay.
Fixes#12.
When this mod and the Prefab Counter mod up to version 1.0.1 are both enabled, the server will crash:
The affected mod is the Chat Announcements mod here, as visible in the incorrect modname in the log entries, which have been overwritten with Prefab Counter data, as well as the
bad argument #1 to 'pairs'
error, which refers to an externally defined constant table, which should never be nil.Running either mod alone does not cause any issue.
The text was updated successfully, but these errors were encountered: