Berwin Posted December 4, 2017 Share Posted December 4, 2017 Hi I have a script which work perfectly when I host a game through the ingame browser but will crash the client if I try to connect it to a dedicated server. The crash occurs when one of my altered structures is spawned. I assume the script isn't on the client, that's my interpretation of the error. The script and error are below. The first 'for' loop adding the component is causing the problems, seems the client doesn't have this informations. Script below, and error below that: local minutes_per_year = GLOBAL.TUNING.AUTUMN_LENGTH*60 + GLOBAL.TUNING.WINTER_LENGTH*60 + GLOBAL.TUNING.SPRING_LENGTH*60 + GLOBAL.TUNING.SUMMER_LENGTH*60 minutes_per_year = minutes_per_year*5 local addperish = { ["researchlab2"] = minutes_per_year, -- Alchemy Engine ["beebox"] = minutes_per_year, -- Bee Box ["birdcage"] = minutes_per_year, -- Birdcage ["firepit"] = minutes_per_year, -- Fire Pit ["cartographydesk"] = minutes_per_year, -- Cartographer's Desk ["chesspiece_pipe_marble"] = minutes_per_year, -- Bubble Pipe Carving ["chesspiece_pipe_stone"] = minutes_per_year, -- Bubble Pipe Carving ["chesspiece_hornucopia_marble"] = minutes_per_year, -- Carved Hornucopia ["chesspiece_hornucopia_stone"] = minutes_per_year, -- Carved Hornucopia ["chesspiece_rook_marble"] = minutes_per_year, -- Rook Figure ["chesspiece_rook_stone"] = minutes_per_year, -- Rook Figure ["chesspiece_knight_marble"] = minutes_per_year, -- Knight Figure ["chesspiece_knight_stone"] = minutes_per_year, -- Knight Figure ["chesspiece_bishop_marble"] = minutes_per_year, -- Bishop Figure ["chesspiece_bishop_stone"] = minutes_per_year, -- Bishop Figure ["chesspiece_formal_marble"] = minutes_per_year, -- Kingly Figure ["chesspiece_formal_stone"] = minutes_per_year, -- Kingly Figure ["chesspiece_muse_marble"] = minutes_per_year, -- Queenly Figure ["chesspiece_muse_stone"] = minutes_per_year, -- Queenly Figure ["chesspiece_pawn_marble"] = minutes_per_year, -- Pawn Figure ["chesspiece_pawn_stone"] = minutes_per_year, -- Pawn Figure ["chesspiece_deerclops_marble"] = minutes_per_year, -- Deerclops Figure ["chesspiece_deerclops_stone"] = minutes_per_year, -- Deerclops Figure ["chesspiece_bearger_marble"] = minutes_per_year, -- Bearger Figure ["chesspiece_bearger_stone"] = minutes_per_year, -- Bearger Figure ["chesspiece_moosegoose_marble"] = minutes_per_year, -- Goose/Goose Figure ["chesspiece_moosegoose_stone"] = minutes_per_year, -- Goose/Goose Figure ["chesspiece_dragonfly_marble"] = minutes_per_year, -- Dragonfly Figure ["chesspiece_dragonfly_stone"] = minutes_per_year, -- Dragonfly Figure ["treasurechest"] = minutes_per_year, -- Chest ["storeroom"] = minutes_per_year, -- Storeroom ["cookpot"] = minutes_per_year, -- Crockpot ["arrowsign_post"] = minutes_per_year, -- Directional Sign ["meatrack"] = minutes_per_year, -- Drying Rack ["coldfirepit"] = minutes_per_year, -- Endothermic Fire Pit ["slow_farmplot"] = minutes_per_year, -- Farm (Slow) ["fast_farmplot"] = minutes_per_year, -- Farm (Improved) ["scarecrow"] = minutes_per_year, -- Friendly Scarecrow ["eyeturret"] = minutes_per_year, -- Houndius Shootius ["icebox"] = minutes_per_year, -- Ice Box ["firesuppressor"] = minutes_per_year, -- Ice Flingomatic ["lightning_rod"] = minutes_per_year, -- Lightning Rod ["resurrectionstatue"] = minutes_per_year, -- Meat Effigy ["moondial"] = minutes_per_year, -- Moon Dial ["mushroom_light"] = minutes_per_year, -- Mushroom Light (Mushlight) ["mushroom_light2"] = minutes_per_year, -- Mushroom Light (Glow Cap) ["mushroom_farm"] = minutes_per_year, -- Mushroom Planter ["nightlight"] = minutes_per_year, -- Night Light ["sentryward"] = minutes_per_year, -- Ocuvigil ["pottedfern"] = minutes_per_year, -- Potted Fern ["succulent_potted"] = minutes_per_year, -- Potted Succulent ["sculptingtable"] = minutes_per_year, -- Potter's Wheel ["researchlab4"] = minutes_per_year, -- Prestihatitator ["rainometer"] = minutes_per_year, -- Rainometer ["saltlick"] = minutes_per_year, -- Salt Lick ["dragonflychest"] = minutes_per_year, -- Scaled Chest ["dragonflyfurnace"] = minutes_per_year, -- Scaled Furnace ["researchlab"] = minutes_per_year, -- Science Machine ["researchlab3"] = minutes_per_year, -- Shadow Manipulator ["siestahut"] = minutes_per_year, -- Siesta Lean-to ["homesign"] = minutes_per_year, -- Sign ["telebase"] = minutes_per_year, -- Telelocator Focus ["gemsocket"] = minutes_per_year, -- Telelocator Focus ["tent"] = minutes_per_year, -- Tent ["townportal"] = minutes_per_year, -- The Lazy Deserter ["winterometer"] = minutes_per_year, -- Thermal Measure ["wardrobe"] = minutes_per_year, -- Wardrobe ["marbletree"] = minutes_per_year, -- Marble Tree } for k,v in pairs(addperish) do AddPrefabPostInit(k or "",function(inst) if inst.components.health == nil then inst:AddComponent("health") inst.components.health:SetMaxHealth(v) inst.components.health:StartRegen(-1, 60) end end) end local addregen = { ["mermhouse"] = 0, -- Rundown House ["catcoonden"] = 0, -- Catcoon Den ["slurtlehole"] = 0, -- Slurtle Mound ["houndmound"] = 0, -- Hound Mound ["pigtorch"] = 0, -- Pig Torch ["monkeybarrel"] = 0, -- Slumonkey Pod ["pighouse"] = 0, -- Pig House ["rabbithouse"] = 0, -- Rabbit Hutch } for k,v in pairs(addregen) do AddPrefabPostInit(k or "",function(inst) if inst.components.health then inst:RemoveComponent("health") end if inst.components.workable then inst:RemoveComponent("workable") end end) end [00:02:11]: Loading Nav Grid [00:02:11]: OVERRIDE: setting regrowth to fast [00:02:11]: OVERRIDE: setting bearger to often [00:02:11]: OVERRIDE: setting deerclops to often [00:02:11]: OVERRIDE: setting frograin to rare [00:02:11]: OVERRIDE: setting meteorshowers to often [00:02:11]: removing onetime override frograin [00:02:11]: Reconstructing topology [00:02:11]: ...Sorting points [00:02:11]: ...Sorting edges [00:02:11]: ...Connecting nodes [00:02:11]: ...Validating connections [00:02:11]: ...Housekeeping [00:02:11]: ...Done! [00:02:11]: [ModifyOwnership|AddSimPostInit] string.split check passed. [00:02:12]: ModIndex: Load sequence finished successfully. [00:02:12]: Reset() returning [00:02:13]: Attempting to send resume request [00:02:13]: ReceiveResumeNotification [00:02:13]: Deleting user: session/42CF62CD5DA8D5B2/A7H4OQHU86QP/0000000001 [00:02:22]: Movement prediction enabled [00:02:22]: Craft Pot ~~~ component loaded with no data [00:02:23]: Deserializing tile data (450 x 450) [00:02:32]: SendRemoteExecute(c_spawn("researchlab" ), -221.282730, 50.276993) [00:02:32]: error calling PrefabPostInit: researchlab in mod workshop-1217607385 (DST Server): [string "scripts/components/health.lua"]:8: attempt to index field 'health' (a nil value) LUA ERROR stack traceback: scripts/components/health.lua(8,1) in function '?' scripts/class.lua(30,1) scripts/components/health.lua(48,1) in function '_ctor' scripts/class.lua(181,1) in function 'cmp' scripts/entityscript.lua(533,1) in function 'AddComponent' ../mods/workshop-1217607385/scripts/modules/mod_structurechanges.lua(78,1) =(tail call) ? =[C] in function 'xpcall' scripts/mods.lua(154,1) in function 'mod' scripts/mainfunctions.lua(194,1) [00:02:32]: Disabling workshop-1217607385 (DST Server) because it had an error. [00:02:32]: [string "scripts/components/health.lua"]:8: attempt to index field 'health' (a nil value) LUA ERROR stack traceback: scripts/components/health.lua(8,1) in function '?' scripts/class.lua(30,1) scripts/components/health.lua(48,1) in function '_ctor' scripts/class.lua(181,1) in function 'cmp' scripts/entityscript.lua(533,1) in function 'AddComponent' ../mods/workshop-1217607385/scripts/modules/mod_structurechanges.lua(78,1) =(tail call) ? =[C] in function 'xpcall' scripts/mods.lua(154,1) in function 'mod' scripts/mainfunctions.lua(194,1) [00:02:32]: [string "scripts/components/health.lua"]:8: attempt to index field 'health' (a nil value) LUA ERROR stack traceback: scripts/components/health.lua(8,1) in function '?' scripts/class.lua(30,1) scripts/components/health.lua(48,1) in function '_ctor' scripts/class.lua(181,1) in function 'cmp' scripts/entityscript.lua(533,1) in function 'AddComponent' ../mods/workshop-1217607385/scripts/modules/mod_structurechanges.lua(78,1) =(tail call) ? =[C] in function 'xpcall' scripts/mods.lua(154,1) in function 'mod' scripts/mainfunctions.lua(194,1) [00:02:32]: replica health already exists! scripts/entityreplica.lua:76 in (method) ReplicateEntity (Lua) <73-83> [00:02:32]: Registering duplicate lua network variable 1421215739 in entity researchlab[103175] [00:02:32]: Break at: ..\source\simlib\Entity.cpp(330) : Link to comment Share on other sites More sharing options...
Berwin Posted December 4, 2017 Author Share Posted December 4, 2017 AddPrefabPostInit("researchlab",function(inst) inst:AddComponent("health") inst.components.health:SetMaxHealth(100) inst.components.health:StartRegen(-1, 60) end) So.. I've tried just running this on dedicated server and it crashes client when you spawn Science Machine. Works on self hosted server. Link to comment Share on other sites More sharing options...
CarlZalph Posted December 4, 2017 Share Posted December 4, 2017 5 minutes ago, Berwin said: AddPrefabPostInit("researchlab",function(inst) inst:AddComponent("health") inst.components.health:SetMaxHealth(100) inst.components.health:StartRegen(-1, 60) end) So.. I've tried just running this on dedicated server and it crashes client when you spawn Science Machine. Works on self hosted server. AddPrefabPostInit( "researchlab", function(inst) if not GLOBAL.TheWorld.ismastersim then return end inst:AddComponent("health") inst.components.health:SetMaxHealth(100) inst.components.health:StartRegen(-1, 60) end ) Link to comment Share on other sites More sharing options...
Lumina Posted December 4, 2017 Share Posted December 4, 2017 Usually something working without caves and crashing with caves is a problem related to server/client. Like something that should be server side but that is on client. Ok i'm too slow to type, this seems to be the case here Link to comment Share on other sites More sharing options...
Berwin Posted December 4, 2017 Author Share Posted December 4, 2017 Thanks for doing this. It's working perfectly. Should I apply this to the 2nd 'for' loop also? Could you explain what is going on here so I can learn from it. I assume the bit listed below is stopping the code being applied to the client? if not GLOBAL.TheWorld.ismastersim then return 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