Download src/ServerScriptService/MutationManager.server.lua from algorembrant/TimberWoods: direct link, hf CLI and curl.
- Browser
- Download file 2.31 kB
-
https://huggingface.co/algorembrant/TimberWoods/resolve/main/src/ServerScriptService/MutationManager.server.lua
- Command line
-
hf download hf://algorembrant/TimberWoods/src/ServerScriptService/MutationManager.server.lua
-
curl -L -o MutationManager.server.lua https://huggingface.co/algorembrant/TimberWoods/resolve/main/src/ServerScriptService/MutationManager.server.lua
2.31 kB
| -- src/ServerScriptService/MutationManager.server.lua | |
| local CollectionService = game:GetService("CollectionService") | |
| local ReplicatedStorage = game:GetService("ReplicatedStorage") | |
| local MutationConfig = require(ReplicatedStorage:WaitForChild("Shared"):WaitForChild("MutationConfig")) | |
| local function applyMutation(treeModel, hazardType) | |
| local config = MutationConfig.Hazards[hazardType] | |
| if not config then return end | |
| -- In Lumber Tycoon style, trees are models containing segments | |
| treeModel:SetAttribute("Mutated", hazardType) | |
| for _, part in pairs(treeModel:GetDescendants()) do | |
| if part:IsA("BasePart") and CollectionService:HasTag(part, "TreeSegment") then | |
| part:SetAttribute("TreeType", config.ModifiedType) | |
| part.Material = config.Material | |
| part.Color = config.Color | |
| -- Optional: Add a ParticleEmitter | |
| if hazardType == "Toxic" then | |
| local particles = Instance.new("ParticleEmitter") | |
| particles.Color = ColorSequence.new(config.Color) | |
| particles.Size = NumberSequence.new(0.5, 0) | |
| particles.Rate = 5 | |
| particles.Parent = part | |
| end | |
| end | |
| end | |
| end | |
| -- Scan all hazard zones at startup (and potentially periodically) | |
| local function scanForMutations() | |
| for _, hazardZone in pairs(CollectionService:GetTagged("HazardZone")) do | |
| local hazardType = hazardZone:GetAttribute("HazardType") | |
| local config = MutationConfig.Hazards[hazardType] | |
| if config then | |
| -- Find all trees near the hazard | |
| for _, tree in pairs(CollectionService:GetTagged("TreeModel")) do | |
| if not tree:GetAttribute("Mutated") then | |
| local distance = (tree.PrimaryPart.Position - hazardZone.Position).Magnitude | |
| if distance <= config.Radius then | |
| if math.random() <= config.MutationChance then | |
| applyMutation(tree, hazardType) | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| -- Run scan after a brief delay to ensure map has loaded | |
| task.delay(5, scanForMutations) | |