Jump to content

runmodsfn function in mods.lua


skittles sour
  • Closed

i've been getting a new bug that I haven't gotten before with the Green! mod, it has to do with adding a custom green component, and then, when running the component post inits, the runmods function in the mods.lua file crashes because a certain variable that was supposed to be a string turned out to be nil:

[string "scripts/mods.lua"]:172: attempt to concatenate local 'r' (a nil value)
LUA ERROR stack traceback:
        scripts/mods.lua(172,1) in function 'fn'
        scripts/entityscript.lua(573,1) in function 'AddComponent'

here is the mods.lua file

local runmodfn = function(fn,mod,modtype)
	return (function(...)
		if fn then
			local status, r = xpcall( function() return fn(unpack(arg)) end, debug.traceback)
			if not status then
				print("error calling "..modtype.." in mod "..ModInfoname(mod.modname)..": \n"..r)-- LINE 172
				ModManager:RemoveBadMod(mod.modname,r)
				ModManager:DisplayBadMods()
			else
				return r
			end
		end
	end)
end

(here is the full chunk of the crash)

[00:00:38]: error calling PrefabPostInitAny in mod workshop-1418878027 (Green!): 
[string "scripts/mods.lua"]:172: attempt to concatenate local 'r' (a nil value)
LUA ERROR stack traceback:
        scripts/mods.lua(172,1) in function 'fn'
        scripts/entityscript.lua(573,1) in function 'AddComponent'
        ../mods/workshop-1418878027/scripts/gf_init_prefabs.lua(443,1)
        =(tail call) ?
        =[C] in function 'xpcall'
        scripts/mods.lua(170,1) in function 'prefabpostinitany'
        scripts/mainfunctions.lua(322,1)
        =[C] in function 'SpawnPrefab'
        scripts/mainfunctions.lua(348,1) in function 'SpawnPrefab'
        scripts/mainfunctions.lua(365,1) in function 'SpawnSaveRecord'
        scripts/gamelogic.lua(592,1) in function 'PopulateWorld'
	...
        =[C] in function 'GetPersistentString'
        scripts/saveindex.lua(285,1) in function 'Load'
        scripts/gamelogic.lua(1197,1) in function 'callback'
        scripts/playerprofile.lua(1325,1) in function 'Set'
        scripts/playerprofile.lua(1174,1)
        =[C] in function 'GetPersistentString'
        scripts/playerprofile.lua(1172,1) in function 'Load'
        scripts/gamelogic.lua(1196,1) in main chunk
        =[C] in function 'require'
        scripts/mainfunctions.lua(1260,1)	

 


Steps to Reproduce

use green

  • Like 1



User Feedback


This crash can only occur if the component post init throws an error, which we cannot solve on our end.
Changed Status to Closed

  • Like 1
  • Thanks 1

Share this comment


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

×
  • Create New...