Jump to content

Recommended Posts

Just about anyone who's done minecraft modding knows about chunk loaders, basically they keep a "chunk" (a certain area, it might have been 16x16 if i remember correctly) loaded at all times, regardless of whether a player was near it or not, because if you have machines operating, and your far away from it, the "chunk" won't be loaded, and thus won't work, basically i'd like to have something like this for don't starve, because, well same reason you'd want them in minecraft.

Link to comment
https://forums.kleientertainment.com/forums/topic/30342-mod-request-chunk-loaders/
Share on other sites

In Don't Starve, loaded/unloaded entities are referred to as awake/asleep. You can disable entities from sleeping on a case-by-case basis by doing:

inst.entity:SetCanSleep(false)
By default, the only entities that are disabled from sleeping are: TheGlobalInstance, forest, maxwellphonograph, minimap, player, walls, and the world.

If you turn on debug rendering (press backspace), you can see the entity count and the number of awake entities in the top left. Entities are automatically slept once you are a certain distance away from them. If I remember right, the sleep distance is determined by a number of factors (hardware you're running, version you're running, other stuff?).

EDIT: Also, components can catch onsleep/onwake by defining the functions:

function YourComponent:OnEntitySleep()endfunction YourComponent:OnEntityWake()end
See growable, combat, periodicspawner, playerprox, sleeper, spawner, stretcher, teamattacker for examples.

Prefabs can do the same thing:

inst.OnEntitySleep = function() endinst.OnEntityWake = function() end
See bee, beebox, beehive, bunnyman, cavelight, cavespiders, deerclops, evergreens, exitcavelight, hound, houndmound, lureplant, mosquito, penguin, penguin_ice, rabbit, slurtlehole, spider, spiderden, tentacle_pillar, walrus, walrus_camp, and wasphive for examples. Edited by squeek

In Don't Starve, loaded/unloaded states are called awake/asleep. You can disable entities from sleeping on a case-by-case basis by doing:

inst.entity:SetCanSleep(false)
By default, the only entities that are disabled from sleeping are: TheGlobalInstance, forest, maxwellphonograph, minimap, player, walls, and the world.

If you turn on debug rendering (press backspace), you can see the entity count and the number of awake entities in the top left. Entities are automatically slept once you are a certain distance away from them. If I remember right, the sleep distance is determined by a number of factors (hardware you're running, version you're running, other stuff?).

 

Would there be a way to make a structure keep all entities within a radius of it awake no matter what?

This would inevitably increase lag on a lot of systems.

Thats sort of inevitable, loading more areas, or rather entities, at once takes up more cpu thus making it more lag inducing, it does the same thing in minecraft, so why wouldn't it here?

Would there be a way to make a structure keep all entities within a radius of it awake no matter what?

Depends what you're trying to do. I've also had no real experience in messing with this sort of stuff, so you'd have to experiment to see what works.

For example, I'm unsure if asleep entities would be included in a TheSim:FindEntities() call. If they are included, then you may not need to keep all entities awake (for example, if you had a machine that picked up nearby stuff, then the stuff that's being picked up wouldn't necessarily need to be awake).

So, yeah. Can't give a definitive answer. Ideally you'd always want to try to keep as few entities awake at a time as possible.

Edited by squeek

In looking around a bit more, forcing something to never sleep shouldn't really be necessary. Tasks will continue when an entity is sleeping, so you can use that to continue functionality while asleep. See the periodicspawner component for an example of something that can be used to only spawn things when the entity it is a component of is 'offscreen' (meaning asleep); take a look at the component's variable 'spawnoffscreen' and how it's used.

Edited by squeek

My goal here is to make things such as spider farms and actual farms and bees and such work while you're away

Meaning what? Which parts of those things currently don't work while you're away?

Regardless, though, keeping the entities awake is probably the least efficient method and should be avoided if at all possible. There's no reason to actually spawn bees and have them move around offscreen if it's possible to simulate their effects without them actually existing.

Meaning what? Which parts of those things currently don't work while you're away?

Regardless, though, keeping the entities awake is probably the least efficient method and should be avoided if at all possible. There's no reason to actually spawn bees and have them move around offscreen if it's possible to simulate their effects without them actually existing.

Thats an interesting idea, what im saying is, since, say in a spider farm, if the entities are sleeping, e.g the pig/bunny houses and spider den, no pigs spawn, no spiders spawn, there's nothing to fight each other, so nothing drops, i like your bee idea though

Thats an interesting idea, what im saying is, since, say in a spider farm, if the entities are sleeping, e.g the pig/bunny houses and spider den, no pigs spawn, no spiders spawn, there's nothing to fight each other, so nothing drops, i like your bee idea though

Combat may make things a bit difficult, and may require entities to actually be awake. That'd require more focused testing and experimentation.

However, beeboxes already do the simulation: when a beebox sleeps, it starts accumulating honey on its own with a period of TUNING.BEEBOX_HONEY_TIME. See prefabs/beebox.lua's onsleep and stopsleep functions (lines 95-107).

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...