Omicon Posted April 6, 2025 Share Posted April 6, 2025 (edited) inst:WatchWorldState("startday", function () isnight = false auto_light(inst,inst.components.inventoryitem.owner) end) inst:WatchWorldState("startdusk", function () isnight = true auto_light(inst,inst.components.inventoryitem.owner) end) inst:WatchWorldState("startnight",function () isnight = true auto_light(inst,inst.components.inventoryitem.owner) end) The code is okay,but if I add the cave ,game crash and force close,whyyyyy The code located in prefabs file, which is custom item. Edited April 6, 2025 by Omicon Link to comment https://forums.kleientertainment.com/forums/topic/165224-i-need-help%EF%BC%8Cabout-custom-item-and-watchworldstate-function/ Share on other sites More sharing options...
Merkyrrie Posted April 6, 2025 Share Posted April 6, 2025 Generally when the game only crashes after adding caves, it suggests the mod is trying to do something client-side that should be done only on the server-side. This is because you are technically aren't a client when the world doesn't have caves, so for the person hosting the world specifically it doesn't care about the difference between client and server, but with caves enabled the host of the world becomes a client too. I would have to see the entire code to tell exactly what that is, but if its crashing from your custom item its possible that you have something above this line that in your item's main function that should be below: inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end Does the game still crash if you remove the WatchWorldState code specifically? Link to comment https://forums.kleientertainment.com/forums/topic/165224-i-need-help%EF%BC%8Cabout-custom-item-and-watchworldstate-function/#findComment-1811059 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