Laiton Posted June 13, 2015 Share Posted June 13, 2015 local assets ={ Asset("ANIM", "anim/r_shelter.zip"),}local function onhammered(inst, worker) inst.components.lootdropper:DropLoot() SpawnPrefab("collapse_big").Transform:SetPosition(inst.Transform:GetWorldPosition()) inst.SoundEmitter:PlaySound("dontstarve/common/destroy_wood") inst:Remove()endlocal function onhit(inst, worker) inst.AnimState:PlayAnimation("idle") inst.AnimState:PushAnimation("idle", true)endlocal function onbuilt(inst) inst.components.resurrector.active = true ProfileStatsSet("r_shelter_activated", true) inst.AnimState:PlayAnimation("idle") inst.AnimState:PushAnimation("idle", true) inst.SoundEmitter:PlaySound("dontstarve/common/resurrectionstone_activate") inst.components.resurrector:OnBuilt()endlocal function doresurrect(inst, dude) inst:AddTag("busy") inst.MiniMapEntity:SetEnabled(false) if inst.Physics then MakeInventoryPhysics(inst) end ProfileStatsSet("r_shelter_used", true) GetClock():MakeNextDay() dude.Transform:SetPosition(inst.Transform:GetWorldPosition()) dude:Hide() TheCamera:SetDistance(12) dude.components.hunger:Pause() scheduler:ExecuteInTime(3, function() dude:Show() GetSeasonManager():DoLightningStrike(Vector3(inst.Transform:GetWorldPosition())) local smoke = SpawnPrefab("maxwell_smoke") local pos = inst:GetPosition() smoke.Transform:SetPosition(pos.x, pos.y, pos.z) smoke.Transform:SetScale(2,2,2) if dude.components.hunger then dude.components.hunger:SetPercent(1) end if dude.components.health then dude.components.health:SetPercent(1) end if dude.components.sanity then dude.components.sanity:SetPercent(1) end dude.sg:GoToState("wakeup") dude:DoTaskInTime(3, function(inst) if dude.HUD then dude.HUD:Show() end TheCamera:SetDefault() inst:RemoveTag("busy") end) end)endlocal function makeused(inst) -- inst:Remove()endlocal function fn(Sim) local inst = CreateEntity() local trans = inst.entity:AddTransform() local anim = inst.entity:AddAnimState() inst.entity:AddSoundEmitter() anim:SetBank("r_shelter") anim:SetBuild("r_shelter") anim:PlayAnimation("idle", true) local minimap = inst.entity:AddMiniMapEntity() minimap:SetIcon( "r_shelter.tex" ) inst:AddTag("shelter") inst:AddComponent("inspectable") inst: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:AddComponent("resurrector") inst.components.resurrector.doresurrect = doresurrect inst:ListenForEvent( "onbuilt", onbuilt) -- inst.components.resurrector.makeusedfn = makeused inst.components.inspectable:RecordViews() return instendreturn Prefab( "common/r_shelter", fn, assets), MakePlacer( "common/r_shelter_placer", "r_shelter", "r_shelter", "idle" ) why i can resurrect only one times? Link to comment Share on other sites More sharing options...
Mobbstar Posted June 13, 2015 Share Posted June 13, 2015 You need to register the resurrector again (the component automatically deregisters it after firing the "doresurrect" function). I think it should be fine to do so in the part where the player is told to wake up. inst.components.resurrector:OnBuilt(wilson) Link to comment Share on other sites More sharing options...
Laiton Posted June 13, 2015 Author Share Posted June 13, 2015 hi, thanks for your help.I put "inst.components.resurrector:OnBuilt()" next "dude.sg:GoToState("wakeup")" but it not work. Link to comment Share on other sites More sharing options...
Mobbstar Posted June 13, 2015 Share Posted June 13, 2015 hi, thanks for your help.I put "inst.components.resurrector:OnBuilt()" next "dude.sg:GoToState("wakeup")" but it not work. of course not, you forgot the parameter: inst.components.resurrector:OnBuilt(dude) I previously placed "wilson" there, sorry if that confused you. Link to comment Share on other sites More sharing options...
Laiton Posted June 13, 2015 Author Share Posted June 13, 2015 no problem but it still not working. Link to comment Share on other sites More sharing options...
Laiton Posted June 13, 2015 Author Share Posted June 13, 2015 sorry, but is possible do what I want? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.