Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TUTORIAL
- Creating a mod and an element
- In the mods folder, create a JavaScript file. In Windows, this can be done by creating a text file, then replacing the .txt extension with .js with file name extensions turned on (if they're off, it is most likely still a text file). The resulting file should be named like name_of_mod.js. When loading Sandboxels, you may now load in the mod through the mods menu like you would any other mod by typing its name in the mod manager menu.
- You may notice that there is nothing new in the game, as no elements have been created. To create an element, follow the template below:
- elements.hello_world = {
- color: "#ff0000",
- behavior: behaviors.WALL,
- category: "land",
- state: "solid",
- };
- What does it do?
- elements.hello_world creates a new element named "Hello World". The braces contain all the information this element uses.
- color: "#ff0000" states that the color of this element should be red. Colors are defined through hex codes, which you can get using Google's color picker.
- behavior: behaviors.WALL states that it should act like a wall. There are many kinds of behaviors, which will be discussed later on.
- category: "land" states that this element should belong in the Land category. You may opt to use one of the categories in the vanilla game or create one yourself, in which case a new category will be created.
- state: "solid" states that this element is a solid.
- Finally, the closing braces }; note that the element definition is over. Without this, your mod will fail to run.
- Now, if you reload the game, you can find the Hello World element which you can place around the canvas. If you don't, check the console for any errors (while its location may depend on the browser you are using, it is usually accessible in the same place Inspect Element is). There should be some errors and warnings that pop up, but all you need to check are ones coming from your mod instead of from index.html. If there is one, your mod has failed to load likely due to a syntax error.
- Common errors include:
- For text inputs, forgetting to include quotes. Any text input (also known as a string) to any property has to include quotes. This, however, does not apply to behavior as you are inserting a variable defined by the base game itself in this spot.
- Forgetting a comma. Commas are used to separate properties (creating a new line does not count), so you need to include one after every property filled in. However, including a comma after your last element does not cause an error, so you may keep one there so you don't forget to add a comma in when adding additional properties.
- If you misspell one of the property names, it will be treated as if it didn't have this property in the first place.
- Behaviors
- Main article: Behaviors
- While the element exists now, it's boring if all you could make are stationary walls. Fortunately, there are other behaviors you can use to dictate how your element moves, and you can also create your own. All default behaviors are prefixed with behaviors. and written in all-caps.
- Behavior name Description Example
- behaviors.POWDER Element drops like a powder Sand
- behaviors.STURDYPOWDER Element falls when not supported by something underneath Mud
- behaviors.AGPOWDER Element drops like a powder, however with reversed gravity Antipowder
- behaviors.LIQUID Element flows around like a liquid Water
- behaviors.SUPERFLUID Element flows like a superfluid or a liquid that flows smoothly with zero viscosity Liquid Light
- behaviors.AGLIQUID Element flows around like a liquid, however with reversed gravity Antifluid
- behaviors.WALL Element is completely stationary Wall
- behaviors.GAS Element flows like gas Oxygen
- behaviors.DGAS Element flows around like gas, however deletes itself after a while Smoke
- behaviors.SUPPORT Element falls when not supported by anything beside it Mudstone
- behaviors.SUPPORTPOWDER Element falls like powder when not supported by anything beside it Packed Snow
- behaviors.FOAM Element falls slowly and vanishes after a while Foam
- behaviors.BUBBLE Element falls very slowly and vanishes after a while Bubble
- behaviors.MOLTEN Element flows very slowly and produces fire Molten Dirt
- behaviors.BOUNCY Element bounces around the screen Laser
- Properties
- Main article: Element properties
- The properties of its element define what it is like and what sets it apart from other elements. Above, the color, behavior, category, and state values are its properties. There are many other properties you may use, such as the following:
- Property name Data type Description
- tempHigh Number The temperature at which this element melts or turns into another
- stateHigh Element name (string) The element which this element turns into when at its melting point
- tempLow Number The temperature at which this element freezes or turns into another
- stateLow Element name (string) The element which this element turns into when at its freezing point
- density Number The density of this element in kg/m3
- hidden Boolean Whether to hide this element from the element toolbar
- hardness Number The hardness of a material from 0 to 1
- breakInto Element name (string) The element that this element will turn into when broken
- burn Number The likelihood of this material to burn from 0 to 100
- burnTime Number How long this element can burn in ticks
- burnInto Element name (string) The elements this element turns into after burning
- reactions Object The reactions of this element
- Reactions
- Reactions determine what happens when an element touches another element. They are determined by a list of elements, which defines what elements it turns into. See the following code, which includes some of Water's reactions.
- reactions: {
- "dirt": { elem1: null, elem2: "mud" },
- "sand": { elem1: null, elem2: "wet_sand" },
- "clay_soil": { elem1: null, elem2: "clay" },
- "salt": { elem1: "salt_water", elem2: null },
- "sugar": { elem1: "sugar_water", elem2: null },
- "dust": { elem1: "dirty_water", elem2: null },
- "ash": { elem1: "dirty_water", elem2: null },
- "rock": { elem2: "wet_sand" },
- "ruins": { elem2: "rock" },
- "mudstone": { elem2: "mud" },
- },
- In here, elem1 refers to what the element itself turns into, in this case Water. elem2 refers to what the element it reacts with will turn into, which includes Dirt, Sand, Clay Soil, and others. If what is written is null, the element disappears. That means that in this code, when Water reacts with Dirt, the water disappears and the dirt will turn into Mud, while if it reacts with Salt instead, the water turns into Salt Water instead and the salt will disappear. If there is nothing written about a certain element, it implies it will stay the same instead of changing, in this case Rock will turn to Wet Sand when reacting with Water while the Water won't change.
- As it is a property, reactions are written along with the other properties. Suppose you have a test powder, and you want to turn both elements into oil when it touches water. It can be written as such:
- elements.hello_world = {
- color: "#ff0000",
- behavior: behaviors.POWDER,
- category: "land",
- state: "solid",
- reactions: {
- "water": { elem1: "oil", elem2: "oil" },
- }
- };
- Note the comma after the reaction. Like after an element property, you need a comma after a reaction when other reactions follow after it. This comma isn't necessary, but it's good to have one so you don't have to go back and add one if you're adding more reactions.
- Property name Data type Meaning
- name String Name of the element. If none is present, element object key will be used instead (e.g. elements.test_element -> TestElement)
- alias String
- Array Other name(s) of the element (e.g. "Hydrochloric Acid" for Acid element)
- category String The category the element button appears in. Entering "tools" places it above the element picker
- desc String Description of the element, shown in Lookup
- extraInfo String Description of the element added as backward compatibility with 'extra_element_info.js' mod. It's only visible in Lookup if desc is not present
- related String - Element
- Array (String - Element) Related element(s), shown under "See Also" in Lookup (e.g. Human is linked to Body and Head)
- hidden Boolean Whether the element is hidden from the element picker by default
- darkText Boolean Whether the element button uses dark or bright text
- canPlace Boolean Whether the element can be placed; true by default on elements that don't have a tool function
- nocheer Boolean Whether this element is hidden in Cheerful Mode
- forceAutoGen Boolean Whether automatic state generation will occur regardless of the existance of stateHigh
- color String - color
- Array (String - color) Color of the pixels of the element. The actual color can vary a bit from the specified value
- colorOn String - color
- Array (String - color) Color of the pixels of the element when charged
- customColor Boolean Whether the user can choose the pixel color (e.g. Art)
- forceSaveColor Boolean Whether pixels of the element store their original color in the save file
- singleColor Boolean Whether pixels of the element will have the same color when placed while drawing continuously
- colorPattern Array (String) Texture pattern of the element
- colorKey Object (key - pattern key, value - color string) Texture colors of the element (map certain pattern keys to colors)
- behavior Behavior array
- Function(pixel) Defines how the element works. See Behavior for more info and how behavior arrays are constructed
- behaviorOn Behavior array
- Function(pixel) Defines how the element works when charged
- tick Function(pixel) Defines how the element works, works independently from behavior (you can use both or either)
- tool Function(pixel) Defines how the element works if the element is tool
- onMouseDown Function Called when the element is selected and mouse button is pressed
- onMouseUp Function Called when the element is selected and mouse button is released
- onSelect Function Called when the element gets selected
- onUnselect Function Called when the element stops being selected
- onMix Function(pixel) Called when a pixel of the element is mixed
- perTick Function Called every tick if element is selected
- hoverStat Function(pixel) Provides hover information for a pixel
- reactions Reactions object Reactions of the element
- temp Number The default temperature of pixels of the element
- tempLow Number The temperature at which the pixel turns into the element specified by stateLow
- stateLow String - element The element that the pixel turns into after reaching the temperature specified by tempLow
- stateLowName String Name of the element that will be generated as stateLow with automatic state generation
- stateLowColor String - color Color of the element that will be generated as stateLow with automatic state generation
- stateLowColorMultiplier String - color Multiplier of the original color that will be used as a color of the element that will be generated as stateLow with automatic state generation
- tempHigh Number The temperature at which the pixel turns into the element specified by stateHigh
- stateHigh String - element The element that the pixel turns into after reaching the temperature specified by tempHigh
- stateHighName String Name of the element that will be generated as stateHigh with automatic state generation
- stateHighColor String - color Color of the element that will be generated as stateHigh with automatic state generation
- stateHighColorMultiplier String - color Multiplier of the original color that will be used as a color of the element that will be generated as stateHigh with automatic state generation
- extraTempLow Object (key - temperature, value - element) Defines other temperatures below tempLow at which element turns into other elements
- extraTempHigh Object (key - temperature, value - element) Defines other temperatures above tempHigh at which element turns into other.
- ELEMENT PROPERTIES
- state String ("solid", "liquid" or "gas") The state of matter of the element
- density Number Density of the element in kg/m³. See Density for more info.
- insulate Boolean Whether the element insulates from heat and electricity
- viscosity Number Viscosity of the element in cP
- conduct Number (0-1) Conductivity of an element
- stain Number (-1-1) How much pixels of the element stain other pixels (negative numbers clean stains)
- stainSelf Boolean Whether the element can stain itself
- charge Number Charge that pixels of the element spawn with
- movable Boolean Whether the element is movable; by default true for all element with tick function or behavior that contains M1 or M2 rules
- hardness Number (0-1) Chance of resisting damage in % (e.g. 5% would be 0.05)
- foodNeed Number Amount of food needed for an egg to be spawned
- properties Object (key - property name, value - default value) Default values of custom properties that pixels of the element will have
- maxSize Number Maximum brush size allowed when placing the element
- baby String - element Element that will be spawned from an egg
- egg String - element Element to be used as an egg (Egg by default)
- eggColor String - color Color of the element's egg
- seed String - element
- Boolean Element to be used as a seed of the element (when seed is a string)
- Whether the element is a seed (when seed is a boolean)
- noMix Boolean Whether the element will be ignored when mixing
- ignoreAir Boolean Whether the element should ignore air density
- excludeRandom Boolean Whether the element should be excluded from random events
- cooldown Number Amount of ticks you have to wait after placing the element before you can place it again
- isFood Boolean Whether the element can be mixed into Dough or Batter
- ignore Array (String - element) Elements that the element will ignore (e.g. in DL, DB, CH, ST or CF behavior rules)
- canContain Boolean Whether pixels of the element can contain other pixels
- burn Number Flammability of the element
- burning Boolean Whether the element is burning by default
- burnTime Number Amount of ticks pixels of the element can burn for
- burnInto String - element Element that pixels of the element will turn into when they burn down
- extinguish Boolean Whether the element can extinguish fire
- fireColor' String - color Color of the fire
- fireElement String - element Element that will be used as fire
- rotatable Boolean Whether the element can rotate in 4 directions
- flippableX Boolean Whether the element can be flipped on the X-axis when placed
- flippableY Boolean Whether the element can be flipped on the Y-axis when placed
- breakInto String - element Element that pixels of the element will turn into when they get smashed
- breakIntoColor String - color Color of pixels of the element after they are smashed
- Default behaviors
- There are 36 default behaviors, that you can access from behaviors object (e.g. behaviors. POWDER)
- BEHAVIORS
- Name Description Example
- POWDER_OLD Default behavior of powders before Version 1.6 -
- POWDER Default behavior of powders Sand
- AGPOWDER POWDER_OLD behavior with reversed gravity (powder goes up) Antipowder
- LIQUID_OLD Default behavior of liquids before Version 1.6 -
- LIQUID Default behavior of liquids Water
- SUPERFLUID_OLD This behavior was never used in the game, and has been added at the same time as SUPERFLUID (Version 1.8.2). It is a superfluid version of LIQUID_OLD -
- SUPERFLUID Superfluid version of LIQUID Liquid Light
- LIGHTWEIGHT Elements with this behavior fall slower and in a more random pattern Feather
- SLIDE This behavior is similar to SUPERFLUID_OLD, and has never been used in the game -
- AGLIQUID LIQUID_OLD behavior with reversed gravity (liquid goes up) Antifluid
- WALL Default behavior of solids Wall
- SLIDE Behavior similar to SUPERFLUID_OLD -
- UL_UR Behavior of Fire before Version 1.8.1 -
- UL_UR_OPTIMIZED Behavior of Fire Fire
- GAS_OLD Default behavior of gases before Version 1.6 -
- GAS Default behavior of gases Steam
- DGAS Behavior similar to GAS_OLD; pixel has 5% chance of deleting itself every tick Smoke
- SUPPORT Elements with this behavior can float if they are connected to a floating element on both sides, otherwise they fall straight down Mudstone
- SUPPORTPOWDER Element with this behavior can float if they are connected to a floating element on both sides, otherwise they fall like a powder Packed Snow
- DELETE Elements with this behavior all neighboring pixels (without diagonals) Void
- FILL Elements with this behavior clone themselves into all neighboring pixels (without diagonals) Filler
- CLONER Elements with this behavior clone the first pixel that touches them into all neighboring pixels (without diagonals) Cloner
- STURDYPOWDER Elements with this behavior fall straight down Mud
- SELFDELETE Elements with this behavior delete themselves -
- FOAM Default behavior of Foam Foam
- BUBBLE Default behavior of Bubble Bubble
- STICKY Elements with this behavior stick to other elements Glue
- MOLTEN Default behavior of molten elements Magma
- RADPOWDER Behavior similar to POWDER_OLD; pixel has 1% chance of creating radiation Rad Shard
- RADMOLTEN Behavior similar to MOLTEN; pixel has 1% chance of creating radiation Molten Uranium
- RADLIQUID Behavior similar to LIQUID_OLD; pixel has 2% chance of creating radiation -
- BOUNCY Elements with this behavior fly around the screen and can bounce off other pixels Laser
- FEEDPIXEL Behavior used in reactions; allows animals to eat other pixels Worm + Nut reaction
- KILLPIXEL1 Behavior used in reactions; kills the current pixel -
- KILLPIXEL2 Behavior used in reactions; kills the other pixel Dioxin + Head reaction
- FLY Default behavior of some flying insects Bee
- CRAWLER Default behavior of ants and worms; elements with that behavior can crawl through Dirt, Sand, Clay Soil, Gravel, Mulch, Color Sand and Grass Ant
- Rules
- Colons
- Data (usually element names) can be specified by placing it after a colon (e.g. DL:iron). The effects vary depending on the behavior rule.
- For HT and CO, a number can be specified (the amount by which the temperature is changed), but non-numeric values are ignored.
- Angle bracket
- Additional data can also be specified with the > symbol; the effects also vary depending on the behavior rule. This is seen in CH and EX (e.g. Rotten Meat's CH:meat>rotten_meat%1 and Cold Bomb's EX:10>cold_fire).
- Commas
- In the above constructs, multiple elements can be specified separated by commas (e.g. DL:fire,smoke to delete fire and smoke). Element names can be repeated in these lists, which might or might not have an effect depending on the rule.
- Percent sign
- The chance of a rule being applied can be specified by appending the percent sign and a number, which represents the percent chance per tick of the rule happening. An element with the behavior
- [
- ["XX","XX","XX"],
- ["XX","DL%50","XX"],
- ["XX","XX","XX"]
- ]
- has a 50% chance of deleting itself each tick.
- AND
- Multiple rules can be specified for the same position, separated by " AND " (spaces included). Rules are evaluated in order from left (first specified) to right (last specified).
- Nonexistent rules
- Nonexistent rules are ignored.
- Form
- Behaviors are initially defined in the form
- [
- "AA|AA|AA",
- "AA|AA|AA",
- "AA|AA|AA"
- ]
- (AA = any rule)
- When behaviors are parsed on load, they are automatically converted to 2-dimensional arrays; this is the form in which they will be listed in the examples below.
- The position in the middle represents a given pixel itself, and the eight positions around them represent the eight places where pixels can be around them.
- XX
- XX in a behavior means that nothing is specified. The element Wall has a behavior of
- [
- ["XX","XX","XX"],
- ["XX","XX","XX"],
- ["XX","XX","XX"]
- ]
- which means that it stays still and do nothing (as it has no tick functions or reactions)
- M1 and M2
- M1 means that a pixel will move there with first priority, while M2 indicates a second priority move. If a pixel with M2 positions fails to move into an M1 position (because there is a pixel or boundary in the way), it will try to move into an M2 position. If there are multiple M1 or M2 positions specified in a behavior, one will be chosen at random.
- An example, the old behavior of sand, is given in a comment within the game's code (it currently uses an equivalent tick function).
- /* Behavior Example (Sand)
- [
- ["XX","XX","XX"],
- ["XX","XX","XX"],
- ["M2","M1","M2"]
- ] */
- Sand pixels will first attempt to move straight down; if they're blocked, they instead try falling to the bottom left or bottom right (chosen randomly).
- SP
- A pixel with SP (Support) in its behavior will not move if every SP position has a pixel in it (the edges of the canvas don't count.) For instance, consider mudstone, whose behavior is
- [
- ["XX","XX","XX"],
- ["SP","XX","SP"],
- ["XX","M1","XX"]
- ]
- A mudstone pixel will fall straight down unless it has pixels (of any elements) on each side.
- If an element is specified, SP will only apply if the specified positions are of the specified element (e.g. an element with SP:iron will only be supported if the pixels in the SP:iron position are iron). This doesn't seem to work with multiple elements (e.g. SP:iron,mudstone).
- SA
- A pixel with SA (Support Any) in its behavior will not move if any of its SA positions have a pixel in them (the edges of the canvas don't count.) An element with the behavior
- [
- ["XX","XX","XX"],
- ["SA","XX","SA"],
- ["XX","M1","XX"]
- ]
- would fall straight down unless it has any pixel(s) on its sides.
- Unlike SP, element specifications are ignored.
- DL
- DL (Delete) in a position means that any pixel there will be deleted. If elements are specified (e.g. DL:water or DL:sugar,mud), only pixels of those elements will be deleted.
- A pixel that only deletes itself, like Pointer, would have the behavior
- [
- ["XX","XX","XX"],
- ["XX","DL","XX"],
- ["XX","XX","XX"]
- ]
- and a pixel that deletes those adjacent to it (i.e. Void), will have
- [
- ["XX","DL","XX"],
- ["DL","XX","DL"],
- ["XX","DL","XX"]
- ]
- DL is programmed to ignore itself.
- DB
- Pixels with DB (Delete Both) in their behaviors will delete themselves and the pixel(s) in the DB position(s). Multiple DB positions in the same behavior are applied with some inconsistency.
- DB in the center position has no effect, and DB is also programmed to ignore itself.
- CL
- If a pixel has CL (Clone) in its behavior, it will create a pixel of its same element in that position. An element with the behavior
- [
- ["XX","XX","XX"],
- ["CL","XX","XX"],
- ["XX","XX","XX"]
- ]
- will create more of itself to its left until it is blocked. Filler, whose behavior is
- [
- ["XX","CL","XX"],
- ["CL","XX","CL"],
- ["XX","CL","XX"]
- ]
- spreads infinitely by filling the adjacent pixels with itself.
- CF
- If a pixel has CF (Clone First) in its behavior, it will store the first pixel that it touches (excluding the cloning element itself, elements mentioned in ignore array and Wire). The positions are read in a certain way:
- Store the pixel on top.
- If there is no pixel on top, store the pixel to the left.
- If there is no pixel to the left, store the pixel on the right.
- If there is no pixel to the right, store the pixel below it.
- Once a pixel is chosen, it will be created perpetually from all positions that had a CF.
- Additionally, the selection of pixels spreads through the entire cloning body; placing a large square of Cloner, touching water to it, and erasing a hole deep in the center will result in water being cloned in that hole.
- Cloner's behavior is
- [
- ["XX","CF","XX"],
- ["CF","XX","CF"],
- ["XX","CF","XX"]
- ]
- which means that the first pixel to touch it will be cloned on the cloner's sides.
- CH
- CH (Change) in a behavior means that any pixel in the corresponding position will be replaced with the given element.
- The element that things will change into is separated with a colon. An element with the behavior
- [
- ["XX","CH:iron","XX"],
- ["CH:iron","XX","CH:iron"],
- ["M2","M1 AND CH:iron","M2"]
- ]
- will be a powder that turns anything it touches to iron (behaving unpredictably with itself unless it is explicitly told to ignore itself).
- An element with
- [
- ["XX","XX","XX"],
- ["XX","CH:sand","XX"],
- ["XX","XX","XX"]
- ]
- will immediately turn into sand.
- Multiple elements to change into can be specified with commas; the result will be chosen randomly.
- The colon can be used in conjunction with the > sign can be used to specify a "target" element so that only the target can be changed; for instance, the rule CH:water>alcohol will cause water in the rule's position to be changed to alcohol.
- In this case, the element (list) immediately after the colon is what is being changed, and the elements after the > are what it is being changed into; this is different from rules without the >, where the thing after the colon is what that pixel is being changed into.
- These can be combined. For instance, an element with the behavior
- [
- ["XX%0000000000000000000000000000000000000000","CH:lead,tin,iron,copper,mercury>gold,silver","XX%0000000000000000000000000000000000000000"],
- ["CH:lead,tin,iron,copper,mercury>gold,silver","XX%0000000000000000000000000000000000000000","CH:lead,tin,iron,copper,mercury>gold,silver"],
- ["XX%0000000000000000000000000000000000000000","CH:lead,tin,iron,copper,mercury>gold,silver","XX%0000000000000000000000000000000000000000"]
- ]
- (padded for readability) will change any pixels of lead, tin, iron, copper, or mercury into random gold and silver.
- (It should be noted that reactions are more efficient for changing things.)
- CH without a colon will cause the canvas to turn black and the game to stop responding.
- CH example summary
- Single element without angle bracket
- CH:dirt
- Any element in the position of this rule will be changed into dirt.
- Element list without angle bracket
- CH:dirt,sand
- Any element in the position of this rule will be changed into dirt or sand. Which of the two it is changed into will be picked randomly.
- Single elements with angle bracket
- CH:rainbow>static
- Any rainbow in the position of this rule will be changed into static.
- Angle bracket with list to the left and single element to the right
- CH:rainbow,static>border
- Any rainbow or static in the position of this rule will be changed into border.
- Angle bracket with single element to the left and list to the right
- CH:rainbow>static,border
- Any rainbow in the position of this rule will be changed into static or border. Which of the two it is changed into will be picked randomly.
- Element lists with angle bracket
- CH:rock,sand>zinc,sponge
- Any rock or sand in the position of this rule will be changed into zinc or sponge. Which of the two it is changed into will be picked randomly.
- C2
- An element with C2 (Change Self after M2) in its behavior will change into the specified element after it does an M2. The pixel will change regardless of where in the behavior the C2 is. When there are multiple C2's in a behavior, the bottom right position takes precedence, followed by the bottom center, bottom left, middle right... from bottom to top and right to left.
- If multiple elements are given with commas, they will be chosen randomly as with CH.
- C2 without any elements specified will also cause a black error canvas.
- CR
- CR (Create) in an element's behavior means that the specified pixel will be created in the position, with lists being chosen from randomly. When no elements are specified, it defaults to the element itself (like CL).
- LB, L1, and L2
- When an element with LB (Leave behind [a pixel] when moved) in its behavior will leave behind a pixel of the specified element after moving. This will happen regardless of where in the behavior the C2 is, but the code comment with behavior instructions advises putting LB's in the center. When there are multiple L2's in a behavior, they are prioritized in the same order as C2's. When no element is specified, LB has no effect.
- Lists are chosen from randomly.
- L1 and L2 are like LB, but only apply to M1 and M2 moves, respectively.
- SW
- SW (Swap) in a behavior means that an element will swap with whatever element is specified.
- An element with
- [
- ["XX","SW:wood","XX"],
- ["XX","XX","XX"],
- ["M2","M1","M2"]
- ]
- will fall down like sand unless there is wood above it, in which case it will switch places upwards through the wood.
- If multiple elements are specified, it will swap through all of the elements specified.
- HT and CO
- HT (Heat) in a behavior means that an element will heat whatever pixel is in that position, and CO (Cool) will cool that pixel. A colon can be used to specify a number (e.g. HT:3), which will be the amount by which the pixel is heated/cooled, in °C. However, you cannot specify only (a) certain element(s) to be heated/cooled.
- CC
- CC (Change Color) in a behavior means that an element will change the color of whatever pixel is in that position to the specified color. The color must be a valid hex triplet (e.g. #FFFFFF), though the # symbol is optional.
- ST
- ST (Stick) is like SA, but without sticking to itself.
- SH
- SH (Shock) in a behavior means that an element will electrically charge whatever pixel is in that position, depending on its conduct value. If an element is specified, only that element will be shocked; however, like with Support, this doesn't work with lists.
- FX and FY
- FX (Flip X) in a behavior means that it will flip across the X axis. For instance, a behavior of
- [
- ["XX","M2","XX"],
- ["XX","FX","M1"],
- ["XX","M2","XX"]
- ]
- would become
- [
- ["XX","M2","XX"],
- ["M1","FX","XX"],
- ["XX","M2","XX"]
- ]
- .
- FY (Flip Y) is the same over the Y axis.
- FX has no effect unless the element's flippableX property is true. This also applies to FY with flippableY. However, existing flipX or flipY values would still apply.
- RT
- (This section is incomplete.)
- RT (Rotate) in a behavior means that the pixel's r value will increase and it will operate with an accordingly rotated behavior.
- r value Rotation
- 0 0°
- 1 90° CCW/ACW
- 2 180°
- 3 270° CCW/ACW
- Values > 4 are mod 4
- (4 → 0, 5 → 1, etc.)
- By default, RT will increase r by 1, but specifying a number will increase r by that number; RT:2 specifies a 180° turn.
- RT has no effect unless the element's rotatable property is true. However, existing r values would still apply.
- BO
- BO is like FX or FY, but
- which axis gets flipped varies depending on its position in the behavior, and
- it only applies when its corresponding position on the canvas is blocked by a pixel or boundary.
- An element with the behavior
- [
- ["XX","XX","XX"],
- ["XX","XX","XX"],
- ["XX","M1 AND BO","XX"],
- ]
- will fall straight down until it hits something. Then, it will bounce, flipping its Y and falling upwards until it hits something else, which makes it fall back down and this cycle to repeat.
- If the BO is in the left or right positions, this will happen with the X axis. If it is in the corners, it will happen with both axes. The flippableX and flippableY requirement still applies.
- EX
- EX in a behavior means that an element will explode when that position has a pixel in it. A numeric radius (e.g. EX:7 is required, and the game will black screen without one. Additionally, a fire substitute can be specified (e.g. EX:10>water), which can be a list. The specified element(s) will replace fire in the explosion.
- When an EX rule is in the center, the element will explode immediately. Otherwise, it will explode depending on where pixels are around it; an element with the behavior
- [
- ["XX","XX","XX"],
- ["XX","XX","XX"],
- ["XX","M1 AND EX:10>sand","XX"],
- ]
- will fall down and explode into sand when it lands on something.
- REACTIONS
- Reaction requirements
- Reactions can be controlled and may be written to occur only when specific requirements are met:
- Property name Description Reaction example
- chance Chance per tick of reaction occurring Borax + Glue
- tempMin Minimum temperature a reaction can occur Rock + Bone
- tempMax Maximum temperature a reaction can occur Tuff + Charcoal
- oneway Reaction only occurs if elem1 moves into elem2 Water + Carbon Dioxide
- charged Reaction only occurs if elements are charged Water + Zinc
- burning1 Reaction only occurs if elem1 is burning Not used
- burning2 Reaction only occurs if elem2 is burning Chlorine + Oil
- "y" Reaction only occurs at y-values within range Steam + Snow Cloud
- "setting" Reaction only occurs if specified setting is enabled Oxygen + Ozone
- Examples of implementation include:
- reactions: {
- "chance_ex": { elem1:null, elem2:null, chance:0.5 }, // 50% chance per tick
- "temprange_ex": { elem1:null, elem2:null, tempMin:50, tempMax:100 }, // Temp must be between 50 and 100
- "oneway_ex": { elem1:null, elem2:null, oneway:true }, // Only if elem1 moves into elem2 - essentially, primary reactant must move and/or elements must be mixed
- "charged_ex": { elem1:null, elem2:null, charged:true }, // Elements must be charged
- "burning_ex": { elem1:null, elem2:null, burning1:true, burning2:true }, // elem1 and elem2 must be burning
- "height_ex": { elem1:null, elem2:null, "y":[81,71] } // Only at y-values between 81 and 71
- "setting_ex": { elem1:null, elem2:null, "setting":"clouds" } // Clouds setting must be toggled on
- },
- Product properties
- The properties of a reaction's product(s) can be overridden. These properties include:
- Property name Description Reaction example
- elem1 What primary reactant becomes Almost all reactions
- elem2 What secondary reactant becomes Almost all reactions
- color1 Color(s) of primary reactant Brass + Ammonia
- color2 Color(s) of secondary reactant Dough + Milk
- temp1 Temperature of primary reactant Cloud + Electric
- temp2 Temperature of secondary reactant Neutron + Uranium
- attr1 Additional attribute of primary reactant, must be applicable Vinegar + Limestone
- attr2 Additional attribute of secondary reactant, must be applicable Yeast + Bleach
- Examples of implementation include:
- reactions: {
- "elem_ex": { elem1:"water", elem2:"dirt" } // Primary reactant becomes Water, elem_ex becomes Dirt
- "color_ex": { color1:"#FFFFFF", color2:"#000000" }, // Primary reactant turns white, color_ex turns black
- "temp_ex": { temp1:500, color2:-800 }, // Primary reactant becomes 500°C, temp_ex becomes -80°C
- "attr_ex": { attr1:{"foam":20}, elem2:"sodium_acetate", attr2:{"foam":50} }, // If the primary reactant does not foam attr1 does nothing, elem2 becomes Sodium Acetate and foams
- },
- The base game utilizes the "foam" attribute, which only takes effect if the reactant has a function utilizing it. For example, Sodium Acetate contains:
- tick: function(pixel) {
- if ((pixel.foam || Math.random() < 0.25) && isEmpty(pixel.x,pixel.y-1)) {
- createPixel("foam",pixel.x,pixel.y-1);
- if (pixel.foam) {
- pixelMap[pixel.x][pixel.y-1].foam = pixel.foam;
- pixel.foam--;
- }
- }
- },
- Where foam contributes to the amount of Foam being generated. A function similar to this can be added to any element to further customize reactions.
- Functions for properties
- A function can be used in a reaction statement to set any of an element's properties following the reaction. For example:
- reactions: {
- "water": {func: (pixel1) => {pixel1.burning=true;pixel1.burnStart=pixelTicks}, // Primary reactant is burning starting at current tick
- elem2: ["caustic_potash", "fire"], temp2: 400}
- }
- A similar function can be written to set values for any of an element's properties, including modded ones.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement