Mobbstar Posted October 27, 2015 Share Posted October 27, 2015 (edited) EDIT: Solved I am a total noob when it comes to networking. To be fair, I know that data needs to be send by the host for the client to recieve it, but that's about it. I tried porting Vasa Mundus to DST (available on Steam Workshop), and whilst the host part works perfectly fine, the client... lacks. I couldn't test everything because client testing takes two people, but here are two important issues: 1. crash when opening a chest prefab. The client side never sets the container widget's data to the standard "treasurechest". I didn't get to try an explicit data set so far, though I doubt it would be any different.local assets = {Asset("ANIM","anim/jabchest.zip"),Asset("ANIM", "anim/treasure_chest.zip"),Asset("ANIM", "anim/ui_chest_3x2.zip"),}local function onopen(inst)inst.AnimState:PlayAnimation("open")inst.SoundEmitter:PlaySound("dontstarve/wilson/chest_open") --hurting non-players is further downendlocal function onclose(inst)inst.AnimState:PlayAnimation("close")inst.SoundEmitter:PlaySound("dontstarve/creatures/bat/bite")inst.AnimState:PushAnimation("closed", false)endlocal function onhammered(inst, worker)inst.components.lootdropper:DropLoot()inst.components.container:DropEverything()SpawnPrefab("collapse_small").Transform:SetPosition(inst.Transform:GetWorldPosition())inst.SoundEmitter:PlaySound("dontstarve/wilson/rock_break")inst:Remove()endlocal function onhit(inst, worker)inst.AnimState:PlayAnimation("hit")--inst.components.container:DropEverything()inst.AnimState:PushAnimation("closed", false)inst.components.container:Close()if worker thenif worker.components.combat thenworker.components.combat:GetAttacked(inst,20)elseif worker.components.health thenworker.components.health:DoDelta(-20,false,inst.prefab)endendendlocal function onbuilt(inst,data)inst.AnimState:PlayAnimation("place")inst.AnimState:PushAnimation("closed", false)inst.owner = data.builder.useridendlocal function onsave(inst, data)if inst.owner thendata.owner = inst.ownerendendlocal function onload(inst, data)if data and data.owner theninst.owner = data.ownerendendlocal function fn()local inst = CreateEntity()inst.entity:AddTransform()inst.entity:AddAnimState()inst.entity:AddSoundEmitter()inst.entity:AddNetwork()inst.entity:AddMiniMapEntity()inst.MiniMapEntity:SetIcon( "treasure_chest.png" )inst.AnimState:SetBank("jabchest")inst.AnimState:SetBuild("jabchest")inst.AnimState:PlayAnimation("closed")inst:AddTag("structure")inst:AddTag("chest")inst:AddTag("playerowned")inst:AddTag("personal")MakeSnowCoveredPristine(inst)inst.entity:SetPristine()if not TheWorld.ismastersim thenreturn instendinst:AddComponent("inspectable")inst:AddComponent("container")inst.components.container:WidgetSetup("treasurechest")inst.components.container.onopenfn = onopeninst.components.container.onclosefn = oncloseinst:AddComponent("lootdropper")inst:AddComponent("workable")inst.components.workable:SetWorkAction(ACTIONS.HAMMER)inst.components.workable:SetWorkLeft(4)inst.components.workable:SetOnFinishCallback(onhammered)inst.components.workable:SetOnWorkCallback(onhit)inst:ListenForEvent( "onbuilt", onbuilt)inst:ListenForEvent( "onopen", function(self, data) --due to datalocal dude = data.doerif dude and not dude:HasTag("player") or --npc thief(inst.owner and dude.userid ~= inst.owner) then --player thiefif dude.components.combat thendude.components.combat:GetAttacked(self,10)elseif dude.components.health thendude.components.health:DoDelta(-10, false, "stingchest")enddude:PushEvent("thorns") --say auchendend)inst.OnSave = onsaveinst.OnLoad = onloadMakeSnowCovered(inst)return instendreturn Prefab("forest/objects/stingchest",fn,assets),MakePlacer("common/stingchest_placer","jabchest","jabchest","closed") 2. Talker component does not talk. This isn't critical, but highly annoying, and even worse, I have no idea why it happens (or doesn't, rather). The prefab is meant to talk when hit, and it properly shows for the host only. local assets = {Asset("ANIM", "anim/shelldummy.zip")}local function Die(inst)SpawnPrefab("collapse_small").Transform:SetPosition(inst.Transform:GetWorldPosition())inst.SoundEmitter:PlaySound("dontstarve/creatures/slurtle/shatter")inst.components.lootdropper:DropLoot()inst:Remove()endlocal function onbuilt(inst)inst.AnimState:PlayAnimation("place")inst.AnimState:PushAnimation("idle_LP",true)endlocal function OnHit(inst, guy, dmg)inst.AnimState:PlayAnimation("hit")inst.AnimState:PushAnimation("idle_LP",true)if inst.hittime < GetTime() - 2.5 theninst.components.talker:Say(tostring(dmg))inst.hitnum = 0elseif inst.hitnum >= 3 thenDie(inst)elseinst.hitnum = inst.hitnum + 1inst.components.talker:Say("I'm hurt! Stop it!")endinst.hittime = GetTime()inst.components.health.currenthealth = inst.components.health.maxhealthendlocal function fn()local inst = CreateEntity()inst.entity:AddSoundEmitter()inst.entity:AddTransform()inst.entity:AddAnimState()inst.entity:AddNetwork()MakeObstaclePhysics(inst, .6)inst.AnimState:SetBank("shelldummy")inst.AnimState:SetBuild("shelldummy")inst.AnimState:PushAnimation("idle_LP",true)inst.entity:SetPristine()if not TheWorld.ismastersim thenreturn instendinst.hitnum = 0inst.hittime = GetTime()inst:AddComponent("lootdropper")inst:AddComponent("inspectable")inst:AddComponent("talker")inst:AddComponent("combat")inst.components.combat.onhitfn = OnHitinst:AddComponent("health") --why do I have to do this... why does combat want me to do this...inst.components.health.vulnerabletoheatdamage = falseinst.components.health.minhealth = 1 --never dieinst.components.health.nofadeout = trueinst.components.health.canmurder = falseinst.components.health.canheal = falseinst:ListenForEvent("onbuilt",onbuilt)inst:AddTag("grass") --maybe port this back to DS?return instendreturn Prefab("forest/objects/shelldummy", fn, assets),MakePlacer("common/shelldummy_placer", "shelldummy", "shelldummy", "idle") Thank you for letting me complain about things I don't grasp. I am probably just being stupid or ignorant or overthinking or all three of those. Don't be harsh, just honest. Thanks again! Edited October 28, 2015 by Mobbstar Link to comment https://forums.kleientertainment.com/forums/topic/58707-help-i-have-no-idea-how-to-sync-these-things/ Share on other sites More sharing options...
Lumina Posted October 27, 2015 Share Posted October 27, 2015 I tried porting Vasa Mundus to DST (available on Steam Workshop), and whilst the host part works perfectly fine, the client... lacks. I couldn't test everything because client testing takes two people, but here are two important issues: If it can help you, i suggest you to make a local dedicated server. It's very, very, very usefull when you want to test your mod in client-side, because you can test a lot more easily your mod.You don't have to have a server to make this, the computur you use to launch and play the game usually is perfectly fine for it. See this link : http://dont-starve-game.wikia.com/wiki/Guides/Don%E2%80%99t_Starve_Together_Dedicated_Servers And if you needs help to make one, you could have help. This way, in the future, it will be easier for you to test, find what is wrong and all.Dedicated server is very convenient for test Link to comment https://forums.kleientertainment.com/forums/topic/58707-help-i-have-no-idea-how-to-sync-these-things/#findComment-682944 Share on other sites More sharing options...
DarkXero Posted October 28, 2015 Share Posted October 28, 2015 (edited) if not TheWorld.ismastersim then inst.OnEntityReplicated = function(inst) inst.replica.container:WidgetSetup("treasurechest") end return instendAs I pointed out herehttp://forums.kleientertainment.com/topic/58664-i-derped-with-the-backpacks/clients try to lookup the jabchest widget info in the params table of containers.lua, since the WidgetSetup of the container component doesn't propagate the setup to the client. And as I pointed out herehttp://forums.kleientertainment.com/topic/56702-joining-clients-hate-the-talker-component/inst:AddComponent("talker")inst.entity:SetPristine()if not TheWorld.ismastersim then return instendAs of now, talker is a server and client component.If only the server has it, then clients won't update their textwidgets over their prefabs, so they won't see any text. Edited October 28, 2015 by DarkXero Link to comment https://forums.kleientertainment.com/forums/topic/58707-help-i-have-no-idea-how-to-sync-these-things/#findComment-682972 Share on other sites More sharing options...
Mobbstar Posted October 28, 2015 Author Share Posted October 28, 2015 If it can help you, i suggest you to make a local dedicated server. It's very, very, very usefull when you want to test your mod in client-side, because you can test a lot more easily your mod.You don't have to have a server to make this, the computur you use to launch and play the game usually is perfectly fine for it. See this link : http://dont-starve-game.wikia.com/wiki/Guides/Don%E2%80%99t_Starve_Together_Dedicated_Servers And if you needs help to make one, you could have help. This way, in the future, it will be easier for you to test, find what is wrong and all.Dedicated server is very convenient for test Ah, I should try that. Thank you very much for pointing it out! if not TheWorld.ismastersim theninst.OnEntityReplicated = function(inst) inst.replica.container:WidgetSetup("treasurechest") endreturn instendAs I pointed out hereclients try to lookup the jabchest widget info in the params table of containers.lua, since the WidgetSetup of the container component doesn't propagate the setup to the client. And as I pointed out hereinst:AddComponent("talker")inst.entity:SetPristine()if not TheWorld.ismastersim then return instendAs of now, talker is a server and client component.If only the server has it, then clients won't update their textwidgets over their prefabs, so they won't see any text. Thank you for the thorough help! I didn't realise I could set things up for the client too, I thought the game would do all the work for me ;_; Link to comment https://forums.kleientertainment.com/forums/topic/58707-help-i-have-no-idea-how-to-sync-these-things/#findComment-682993 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