bigpak Posted February 11, 2015 Share Posted February 11, 2015 (edited) Alright, I'm bringing this back up as I still haven't found a suitable solution. I am trying to edit the beefalos periodic spawner component to make it poop more often and in closer groups, however the only way to do this is to add it with a postinit and then add inst.components.periodicspawner:Start() However, if you do that then there is two Periodic Spawners running, one from the mod, and one from the base game. The only solution I have found is to edit beefalo.lua in data\scripts\prefabs which is not ideal, as it is editing it through base game files. is there a way to make it so that there isn't two periodicspawners running? If you don't add the periodic spawner start in the postinit it will not apply those changes. Any ideas? This is what beefalo.lua looks like inst:AddComponent("periodicspawner") inst.components.periodicspawner:SetPrefab("poop") inst.components.periodicspawner:SetRandomTimes(40, 60) inst.components.periodicspawner:SetDensityInRange(20, 2) inst.components.periodicspawner:SetMinimumSpacing(8) inst.components.periodicspawner:Start() and this is what the post init looks like local function MorePoop(inst) inst.components.periodicspawner:SetPrefab("poop") inst.components.periodicspawner:SetRandomTimes(1, 2) inst.components.periodicspawner:SetDensityInRange(20, 90) inst.components.periodicspawner:SetMinimumSpacing(0) inst.components.periodicspawner:Start()endAddPrefabPostInit("beefalo",MorePoop)I think I figured it out, does this fix it?local function MorePoop(inst) inst.components.periodicspawner:Stop() inst.components.periodicspawner:SetPrefab("poop") inst.components.periodicspawner:SetRandomTimes(1, 2) inst.components.periodicspawner:SetDensityInRange(20, 90) inst.components.periodicspawner:SetMinimumSpacing(0) inst.components.periodicspawner:Start()endAddPrefabPostInit("beefalo",MorePoop)Since it stops the current periodic spawner, then starts a new one? Edited February 11, 2015 by bigpak Link to comment https://forums.kleientertainment.com/forums/topic/50830-editing-periodicspawner-of-a-prefab/ Share on other sites More sharing options...
Blueberrys Posted February 11, 2015 Share Posted February 11, 2015 (edited) @bigpak Change the variables with SetRandomTimes, SetDensityInRange, etc, but don't call Stop or Start. The new variables will be used when the task resets. Edit: Regarding your edit, yes it probably would fix it, but you don't need to do that. The variables being set through SetRandomTimes etc are the ones used by the old task.See the TrySpawn function in the PeriodicSpawner component. (lines 57 - 99) Edited February 11, 2015 by Blueberrys Link to comment https://forums.kleientertainment.com/forums/topic/50830-editing-periodicspawner-of-a-prefab/#findComment-611936 Share on other sites More sharing options...
bigpak Posted February 11, 2015 Author Share Posted February 11, 2015 (edited) @bigpak Change the variables with SetRandomTimes, SetDensityInRange, etc, but don't call Stop or Start. The new variables will be used when the task resets. Oh, I see what you are saying, however that is not the case. I have tried that, to no avail however. It still uses the normal beefalos periodicspawner. When does the task reset? Edited February 11, 2015 by bigpak Link to comment https://forums.kleientertainment.com/forums/topic/50830-editing-periodicspawner-of-a-prefab/#findComment-611937 Share on other sites More sharing options...
Blueberrys Posted February 11, 2015 Share Posted February 11, 2015 @bigpak Hmm. I'll have to test it. Can't tell why it would do that from the code.Does your edited code work? Link to comment https://forums.kleientertainment.com/forums/topic/50830-editing-periodicspawner-of-a-prefab/#findComment-611938 Share on other sites More sharing options...
bigpak Posted February 11, 2015 Author Share Posted February 11, 2015 (edited) Yes, the code with the stop and start works perfectly, however I don't know if that is the correct way. I'm going to try what you suggested again, however It didn't work before. I would really appreciate if you test it, as I cannot get it to work without doing what I did. I lied, it does work after it resets, I just wasn't waiting long enough. Why does it take so long for it to reset? you mean after 40-60 seconds? Will it hurt to do the stop and start thing? Just to be sure/get it to start instantly?' Edited February 11, 2015 by bigpak Link to comment https://forums.kleientertainment.com/forums/topic/50830-editing-periodicspawner-of-a-prefab/#findComment-611940 Share on other sites More sharing options...
Blueberrys Posted February 11, 2015 Share Posted February 11, 2015 @bigpak No, the stop and start is perfectly fine. RoG does it internally anyways. Link to comment https://forums.kleientertainment.com/forums/topic/50830-editing-periodicspawner-of-a-prefab/#findComment-611942 Share on other sites More sharing options...
bigpak Posted February 11, 2015 Author Share Posted February 11, 2015 @bigpak No, the stop and start is perfectly fine. RoG does it internally anyways. What do you mean by RoG does it internally? Link to comment https://forums.kleientertainment.com/forums/topic/50830-editing-periodicspawner-of-a-prefab/#findComment-611943 Share on other sites More sharing options...
Corrosive Posted February 11, 2015 Share Posted February 11, 2015 @bigpak, In RoG, the periodicspawner component was changed to that when the SetRandomTimes() method is called, it will automatically call Stop() and Start(). I think that's what he's referring to.function PeriodicSpawner:SetRandomTimes(basetime, variance, no_reset) self.basetime = basetime self.randtime = variance if self.task and not no_reset then self:Stop() self:Start() endend Link to comment https://forums.kleientertainment.com/forums/topic/50830-editing-periodicspawner-of-a-prefab/#findComment-611963 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