BakaSchwarz Posted October 15, 2018 Share Posted October 15, 2018 Hi, i am currently developing a patch for a part of a no longer maintained mod. Ideally, i'd like to use AddPrefabPostInit to add something to a prefab of another mod. I also want to use AddClassPostConstruct to insert another asset for the prefab. I check for the mod and that it is enabled just fine. I also set the priority of my mod into a negative value to ensure that the other mod gets loaded before mine. if GLOBAL.KnownModIndex:IsModEnabled("workshop-XXX") then AddClassPostConstruct("prefabs/other_mod_prefab", function() table.insert(GLOBAL.Prefabs['other_mod_prefab'].assets, Asset("ANIM", "anim/new_asset.zip")) end) AddPrefabPostInit("other_mod_prefab", my_cool_post_init) end This way of adding assets to a prefab works just fine with prefabs from the main game. But when i use the code above it corrupts the network communication of my client and the dedicated server (it works fine if you're the host). By corruption i mean all stats are 100, you cannot craft anything, when you get hit a sandstrom starts and other crazy stuff (It's all on the client side, though). Any idea want i am doing wrong? Do i have to access mod prefabs in any other way? The function my_cool_post_init contains the following: inst:ListenForEvent("phasechanged", function(src, data) if data ~= "night" and data ~= "dusk" and not GLOBAL.TheWorld:HasTag("cave") then inst:DoTaskInTime(2, function() inst.AnimState:PlayAnimation("idle_off") inst.Light:Enable(false) end) else inst:DoTaskInTime(2, function() inst.AnimState:PlayAnimation("idle") inst.Light:Enable(true) end) end end,GLOBAL.TheWorld) Link to comment Share on other sites More sharing options...
Ultroman Posted October 15, 2018 Share Posted October 15, 2018 You shouldn't make changes to prefabs on clients. Only the server needs to run prefab code, so you should surround your Add*** function calls with: if GLOBAL.TheNet and GLOBAL.TheNet:GetIsServer() then -- Add*** function calls end Sometimes adding these things on the client side, messes things up. Only changes you need to make to replica-components must also be run on the clients IIRC. I might have misunderstood your troubles, and if so, I'm sorry Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now