Don't Starve Together

Don't Starve Together

Less lags
Muche 23 May, 2016 @ 4:13pm
Feature request
Would you consider adding new feature - protected entities.

It would be possible to protect some entities of a prefab scheduled for removal by placing a sign next to it with a special text "#LL:<prefabname>" (i.e. magic string followed by the name of the prefab; without the quotes). Special case - text "#LL:*" acts as a match for all prefabs.
The number of such protected entities is configurable (in custom prefabs configuration option only, for each prefab, but independently from total count for that prefab). It could be even bigger than total count, which would remove all unprotected entities.
If during the cleanup the number of protected entities is reached, all remaining entities are treated as not protected (thus possibly removed).
The protective radius of such sign is configurable as well (limited to the interval from zero to 40) - either globally, or separately for each prefab (e.g. flowers' signs could have bigger radius, so there are fewer of them needed for a honey flower garden).

Prefabspec (item of custom prefab configuration option value) has been extended to: prefabname:count:protect_count:protect_radius
* protect_count - how many protected entities there can be (optional, defaults to count value)
* protect_radius - the radius in which to check for a sign with magic text (optional, defaults to the value of Protect_radius configuration option)

In my opinion, there are three main ways of using this feature:
1. all prefabs can use protection with the same radius, the number of protected entities is the same as the number of non-protected entities
- set Protect_radius option to chosen radius
2. all prefabs can use protection with the same radius, the number of protected entities differs from the number of non-protected entities
- set Protect_radius option to chosen radius
- update Custom_prefabs option with counts for each prefab
3. only selected prefabs can use protection, radius can differ for each of them
- set Protect_radius option to 0
- update Custom_prefabs option with counts and radii for each selected prefab

I think the feature will be most useful when configured for spiderdens, lureplants and flowers.

See https://www.dropbox.com/sh/6ch3fxii30fsq2s/AADm90TQuuthBz8CsIf2eGypa?dl=0 for patched code.
Last edited by Muche; 23 May, 2016 @ 5:10pm
< >
Showing 1-3 of 3 comments
Scu|ptor 11 Feb, 2017 @ 9:45pm 
Hi. Is there chance to set mod in manual mode only? Without auto cleaning, but only with TheWorld.Clean() command?
please add flower to infinite , we need flower to Improve mind
hero 8 Jun, 2022 @ 6:02am 
Do you still maintain this mod? My suggestion would be to not clean domesticated prefabs.

I already have the code for this, and already tested it on domesticated beefalos.

Add the following lines to modmain.lua:

-- CODE START
function IsDomesticated(b)
local owner = nil

if b.components.domesticatable and b.components.domesticatable:IsDomesticated() then
print ("Domesticated prefab found.")
return true
end
return false
end
-- CODE END

and then change the line from function CleanPrefab:
-- CODE START
if not IsInInventory(v) then
-- CODE END

into:
-- CODE START
if not IsInInventory(v) and not IsDomesticated(v) then
-- CODE END

Do you mind to update the mod so this function becomes native? People have been asking me how I've done it, so I guess this would be a nice addition for some people. :-)
< >
Showing 1-3 of 3 comments
Per page: 1530 50