Hello, everyone!
As part of an interns’ project, I made a fire simulation. I started on this shortly before Christmas and have been refining it since. It basically turns the entire place flammable, so you can start anything from a campfire to a hellish inferno depending on how you use the script.
It does have some rough edges, still, but I am working on fixing those. The script works best with collections of relatively small cubes, best around sizes 2x2x2 - 10x10x10.
Any feedback is very welcome! Let me know what you think!
Below are instructions on how to use the simulation.
HOW TO USE - Basic
This is the variation that requires very little to no scripting knowledge from the user. The script comes with a fire extinguisher and a flamethrower to increase and decrease the temperature of the parts in question. The tools will fire in the direction the character is facing. Place the tools in the StarterPack to jump right into the action!
To get the most basic setup:
- Open the game you want the fire to run in with ROBLOX Studio
- Insert the script into anywhere in your game where it will run (workspace, ServerScriptService - found at Fire Simulator - Roblox)
- Make sure there are a lot of small wooden and plastic parts for you to set ablaze!
- Insert the Fire Extinguisher and Flamethrower tools into the StarterPack (tools sold separately, see here Fire Tools - Roblox). These are some things you should keep in mind while using the tools:
- The tools always fire in the direction your character (not your camera!) is facing. They are easiest to use with either Mouse Lock or First Person view.
- The effect isn’t instant. It usually takes a few simulation steps to ignite a part or extinguish it, so having a lot of parts in the simulation will slow you down a lot.
- It helps to focus on individual parts. Parts with temperatures in the high/low extremes will have a larger effect on the temperatures of the parts around it, making it easier to change their temperatures as well.
- Large parts are much more difficult to ignite, but also much more difficult to extinguish. A large part on fire may be able to burn down an entire house while a single beam on fire may not even burn completely before it cools down too much.
- Publish or run the place. The script takes care of everything else for you!
Stay off of burning parts! Your character will take damage if you step on hot parts or walk through hot air.
You can also choose to only run the simulation on a selection of parts. The way you do that is:
- In the script configuration, there is a value called OnlyConsiderLocalGroups. Set the value to TRUE (make sure the checkbox has a check in it)
- Put all the parts you want simulated into the LocalGroups folder
If you want all parts to be simulated, make sure that the OnlyConsiderLocalGroups value is FALSE (unchecked).
I CAN’T GET THINGS TO BURN!
There may be a few reasons why you’re having trouble setting the world on fire. For one, a lot of models you get from the Toolbox may be made of non-flammable materials. Materials such as Brick, Slate, Sand, Pebble and so on don’t burn at all. Metal, CorrodedMetal and DiamondPlate burn at a lower temperature than it takes to ignite them so the fire can’t keep itself going even if you manage to ignite it. Foil only starts burning at a temperature much higher than what you can get with your flamethrower.
Your parts may also be too large. The simulation doesn’t include any parts that are larger than a certain size because the game would slow down way too much if it did. As a rule of thumb, if the part is longer than 100 studs along any axis, the simulation will ignore it.
The specific rule is that if the Size.magnitude of the part is smaller than 100, the simulation will consider the part, and ignore it otherwise.
Just because your parts are glowing doesn’t mean that they will catch fire. All parts start glowing at the exact same temperature. Wooden materials ignite long before they begin glowing, while metallic materials glow before they start burning.
Also, Neon won’t ever change its temperature, burn or change the color or brightness of its glow.
HOW TO USE - Advanced
First off, some basic RBX.Lua scripting knowledge is presumed. You should, at the very least, know how to fire a BindableEvent, since that is how the temperature of, well, anything is set, really.
As soon as the script runs, it will check all parts in workspace and register all parts below a certain size as ‘thermally active’. This means that they now have a ‘Temperature’ and a ‘Percent Burned’ property. The temperature can be set through the Events/SetPartTemperature BindableEvent. The event is fired with the part as the first argument and the desired temperature as the second.
The update happens instantly but its effects might take a while to apply, as the script does internally throttle its updates to prevent the script execution frequency from ever dropping below 20/s. The amount of throttling depends on the amount of parts and voxels that are being updated every run.
Finally, a code example:
local fireSpread = workspace.FireSpread
--Set the temperature of a part well above its ignition temperature
fireSpread.Events.SetPartTemperature:Fire(workspace.WoodenPart,300)
--Now, monitor the temperature
while true do
wait()
print(fireSpread.Functions.GetPartTemperature:Invoke(workspace.WoodenPart))
end
BEHAVIOR
This section is supposed to give a quick overview of how the script works. For the full picture, you can check the source code.
Each part material has the following new properties associated with it:
- Ignition temperature: The minimum temperature required to set that part on fire.
- Burning (flame) temperature: The temperature of the flame the material produces. This is the temperature a part tries to reach when it burns.
- Specific heat: Determines how difficult it is to change the temperature of a given material.
- Flammable: If set to FALSE, the material will never set on fire.
Each part has the following new properties associated with it:
- Temperature
- Percent burned
The following behavior is followed:
- All parts shed off thermal energy to parts that are touching them
- All parts also shed off thermal energy to the atmosphere
- Parts that are above their ignition temperature will spontaneously combust
- Parts below their ignition temperature will not burn
- Parts on fire will increase their percent damaged value depending on their surface area and volume, as well as their temperature
- Parts on fire will attempt to reach their flame temperature rather than the ambient temperature
- Ambient temperature only matters right at the start when the place initializes. The ambient temperature will then be the average temperature of the surrounding air voxels.
- Parts that are 50% burned will turn black and break their joints with everything.
- Parts that are 100% burned will disappear in a cloud of ash.
CONFIGURATION
This is about the configuration options the script provides. Each value is given a quick explanation:
AmbientTemperature: This is the temperature all parts start at, and that all parts will return to when there is no source of heat.
- ConductionSpeedTouch: The speed at which heat is transferred between touching parts.
- ConductionSpeedWelded: The speed at which heat is transferred between attached parts.
- ConvectionSpeed: The speed at which heat is transferred to and from the surrounding air.
- MaterialStrength: The heat resistance of the materials. This value changes how long it takes for a part to completely burn out.
- DoDebug: When TRUE, the script will output debugging messages. This is turned off by default because it would likely be of no use to you. OnlyConsiderLocalGroups: When TRUE, the script will only handle parts in the LocalGroups folder.
- CharactersTakeDamage: When set to TRUE, players can take damage from hot air.
- CharacterDamageThreshold: The threshold at which players begin taking damage.
- CharacterDamageMultiplier: The damage multiplier for players in hot air. The damage taken is the temperature of the air at that location, multiplied by this value, once every simulation step.
These values can be changed at runtime, with the exception of OnlyConsiderLocalGroups which is loaded at script startup.
Each material then has the following values:
BurnTemp: The temperature of the flame the material produces. This is the temperature a part tries to reach when it burns.
- IgnitionTemp: The minimum temperature required to set that part on fire.
- IsFlammable: If set to FALSE, the material will never set on fire.
- SpecificHeat: Determines how difficult it is to change the temperature of a given material.
The material properties are loaded once on startup and any changes after that are ignored.
DEFAULT MATERIAL PROPERTIES