Advertisement
Guest User

Sandboxels modding AI prompt

a guest
Jun 21st, 2024
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.26 KB | None | 0 0
  1. TUTORIAL
  2. Creating a mod and an element
  3. 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.
  4.  
  5. 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:
  6.  
  7. elements.hello_world = {
  8. color: "#ff0000",
  9. behavior: behaviors.WALL,
  10. category: "land",
  11. state: "solid",
  12. };
  13. What does it do?
  14.  
  15. elements.hello_world creates a new element named "Hello World". The braces contain all the information this element uses.
  16. 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.
  17. behavior: behaviors.WALL states that it should act like a wall. There are many kinds of behaviors, which will be discussed later on.
  18. 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.
  19. state: "solid" states that this element is a solid.
  20. Finally, the closing braces }; note that the element definition is over. Without this, your mod will fail to run.
  21. 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.
  22.  
  23. Common errors include:
  24.  
  25. 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.
  26. 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.
  27. If you misspell one of the property names, it will be treated as if it didn't have this property in the first place.
  28. Behaviors
  29. Main article: Behaviors
  30.  
  31. 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.
  32.  
  33. Behavior name Description Example
  34. behaviors.POWDER Element drops like a powder Sand
  35. behaviors.STURDYPOWDER Element falls when not supported by something underneath Mud
  36. behaviors.AGPOWDER Element drops like a powder, however with reversed gravity Antipowder
  37. behaviors.LIQUID Element flows around like a liquid Water
  38. behaviors.SUPERFLUID Element flows like a superfluid or a liquid that flows smoothly with zero viscosity Liquid Light
  39. behaviors.AGLIQUID Element flows around like a liquid, however with reversed gravity Antifluid
  40. behaviors.WALL Element is completely stationary Wall
  41. behaviors.GAS Element flows like gas Oxygen
  42. behaviors.DGAS Element flows around like gas, however deletes itself after a while Smoke
  43. behaviors.SUPPORT Element falls when not supported by anything beside it Mudstone
  44. behaviors.SUPPORTPOWDER Element falls like powder when not supported by anything beside it Packed Snow
  45. behaviors.FOAM Element falls slowly and vanishes after a while Foam
  46. behaviors.BUBBLE Element falls very slowly and vanishes after a while Bubble
  47. behaviors.MOLTEN Element flows very slowly and produces fire Molten Dirt
  48. behaviors.BOUNCY Element bounces around the screen Laser
  49. Properties
  50. Main article: Element properties
  51.  
  52. 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:
  53.  
  54. Property name Data type Description
  55. tempHigh Number The temperature at which this element melts or turns into another
  56. stateHigh Element name (string) The element which this element turns into when at its melting point
  57. tempLow Number The temperature at which this element freezes or turns into another
  58. stateLow Element name (string) The element which this element turns into when at its freezing point
  59. density Number The density of this element in kg/m3
  60. hidden Boolean Whether to hide this element from the element toolbar
  61. hardness Number The hardness of a material from 0 to 1
  62. breakInto Element name (string) The element that this element will turn into when broken
  63. burn Number The likelihood of this material to burn from 0 to 100
  64. burnTime Number How long this element can burn in ticks
  65. burnInto Element name (string) The elements this element turns into after burning
  66. reactions Object The reactions of this element
  67. Reactions
  68. 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.
  69.  
  70. reactions: {
  71. "dirt": { elem1: null, elem2: "mud" },
  72. "sand": { elem1: null, elem2: "wet_sand" },
  73. "clay_soil": { elem1: null, elem2: "clay" },
  74. "salt": { elem1: "salt_water", elem2: null },
  75. "sugar": { elem1: "sugar_water", elem2: null },
  76. "dust": { elem1: "dirty_water", elem2: null },
  77. "ash": { elem1: "dirty_water", elem2: null },
  78. "rock": { elem2: "wet_sand" },
  79. "ruins": { elem2: "rock" },
  80. "mudstone": { elem2: "mud" },
  81. },
  82. 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.
  83.  
  84. 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:
  85.  
  86. elements.hello_world = {
  87. color: "#ff0000",
  88. behavior: behaviors.POWDER,
  89. category: "land",
  90. state: "solid",
  91. reactions: {
  92. "water": { elem1: "oil", elem2: "oil" },
  93. }
  94. };
  95. 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.
  96. Property name Data type Meaning
  97. name String Name of the element. If none is present, element object key will be used instead (e.g. elements.test_element -> TestElement)
  98. alias String
  99. Array Other name(s) of the element (e.g. "Hydrochloric Acid" for Acid element)
  100. category String The category the element button appears in. Entering "tools" places it above the element picker
  101. desc String Description of the element, shown in Lookup
  102. 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
  103. related String - Element
  104. Array (String - Element) Related element(s), shown under "See Also" in Lookup (e.g. Human is linked to Body and Head)
  105. hidden Boolean Whether the element is hidden from the element picker by default
  106. darkText Boolean Whether the element button uses dark or bright text
  107. canPlace Boolean Whether the element can be placed; true by default on elements that don't have a tool function
  108. nocheer Boolean Whether this element is hidden in Cheerful Mode
  109. forceAutoGen Boolean Whether automatic state generation will occur regardless of the existance of stateHigh
  110. color String - color
  111. Array (String - color) Color of the pixels of the element. The actual color can vary a bit from the specified value
  112. colorOn String - color
  113. Array (String - color) Color of the pixels of the element when charged
  114. customColor Boolean Whether the user can choose the pixel color (e.g. Art)
  115. forceSaveColor Boolean Whether pixels of the element store their original color in the save file
  116. singleColor Boolean Whether pixels of the element will have the same color when placed while drawing continuously
  117. colorPattern Array (String) Texture pattern of the element
  118. colorKey Object (key - pattern key, value - color string) Texture colors of the element (map certain pattern keys to colors)
  119. behavior Behavior array
  120. Function(pixel) Defines how the element works. See Behavior for more info and how behavior arrays are constructed
  121. behaviorOn Behavior array
  122. Function(pixel) Defines how the element works when charged
  123. tick Function(pixel) Defines how the element works, works independently from behavior (you can use both or either)
  124. tool Function(pixel) Defines how the element works if the element is tool
  125. onMouseDown Function Called when the element is selected and mouse button is pressed
  126. onMouseUp Function Called when the element is selected and mouse button is released
  127. onSelect Function Called when the element gets selected
  128. onUnselect Function Called when the element stops being selected
  129. onMix Function(pixel) Called when a pixel of the element is mixed
  130. perTick Function Called every tick if element is selected
  131. hoverStat Function(pixel) Provides hover information for a pixel
  132. reactions Reactions object Reactions of the element
  133. temp Number The default temperature of pixels of the element
  134. tempLow Number The temperature at which the pixel turns into the element specified by stateLow
  135. stateLow String - element The element that the pixel turns into after reaching the temperature specified by tempLow
  136. stateLowName String Name of the element that will be generated as stateLow with automatic state generation
  137. stateLowColor String - color Color of the element that will be generated as stateLow with automatic state generation
  138. 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
  139. tempHigh Number The temperature at which the pixel turns into the element specified by stateHigh
  140. stateHigh String - element The element that the pixel turns into after reaching the temperature specified by tempHigh
  141. stateHighName String Name of the element that will be generated as stateHigh with automatic state generation
  142. stateHighColor String - color Color of the element that will be generated as stateHigh with automatic state generation
  143. 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
  144. extraTempLow Object (key - temperature, value - element) Defines other temperatures below tempLow at which element turns into other elements
  145. extraTempHigh Object (key - temperature, value - element) Defines other temperatures above tempHigh at which element turns into other.
  146. ELEMENT PROPERTIES
  147. state String ("solid", "liquid" or "gas") The state of matter of the element
  148. density Number Density of the element in kg/m³. See Density for more info.
  149. insulate Boolean Whether the element insulates from heat and electricity
  150. viscosity Number Viscosity of the element in cP
  151. conduct Number (0-1) Conductivity of an element
  152. stain Number (-1-1) How much pixels of the element stain other pixels (negative numbers clean stains)
  153. stainSelf Boolean Whether the element can stain itself
  154. charge Number Charge that pixels of the element spawn with
  155. movable Boolean Whether the element is movable; by default true for all element with tick function or behavior that contains M1 or M2 rules
  156. hardness Number (0-1) Chance of resisting damage in % (e.g. 5% would be 0.05)
  157. foodNeed Number Amount of food needed for an egg to be spawned
  158. properties Object (key - property name, value - default value) Default values of custom properties that pixels of the element will have
  159. maxSize Number Maximum brush size allowed when placing the element
  160. baby String - element Element that will be spawned from an egg
  161. egg String - element Element to be used as an egg (Egg by default)
  162. eggColor String - color Color of the element's egg
  163. seed String - element
  164. Boolean Element to be used as a seed of the element (when seed is a string)
  165. Whether the element is a seed (when seed is a boolean)
  166. noMix Boolean Whether the element will be ignored when mixing
  167. ignoreAir Boolean Whether the element should ignore air density
  168. excludeRandom Boolean Whether the element should be excluded from random events
  169. cooldown Number Amount of ticks you have to wait after placing the element before you can place it again
  170. isFood Boolean Whether the element can be mixed into Dough or Batter
  171. ignore Array (String - element) Elements that the element will ignore (e.g. in DL, DB, CH, ST or CF behavior rules)
  172. canContain Boolean Whether pixels of the element can contain other pixels
  173. burn Number Flammability of the element
  174. burning Boolean Whether the element is burning by default
  175. burnTime Number Amount of ticks pixels of the element can burn for
  176. burnInto String - element Element that pixels of the element will turn into when they burn down
  177. extinguish Boolean Whether the element can extinguish fire
  178. fireColor' String - color Color of the fire
  179. fireElement String - element Element that will be used as fire
  180. rotatable Boolean Whether the element can rotate in 4 directions
  181. flippableX Boolean Whether the element can be flipped on the X-axis when placed
  182. flippableY Boolean Whether the element can be flipped on the Y-axis when placed
  183. breakInto String - element Element that pixels of the element will turn into when they get smashed
  184. breakIntoColor String - color Color of pixels of the element after they are smashed
  185. Default behaviors
  186. There are 36 default behaviors, that you can access from behaviors object (e.g. behaviors. POWDER)
  187.  
  188. BEHAVIORS
  189. Name Description Example
  190. POWDER_OLD Default behavior of powders before Version 1.6 -
  191. POWDER Default behavior of powders Sand
  192. AGPOWDER POWDER_OLD behavior with reversed gravity (powder goes up) Antipowder
  193. LIQUID_OLD Default behavior of liquids before Version 1.6 -
  194. LIQUID Default behavior of liquids Water
  195. 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 -
  196. SUPERFLUID Superfluid version of LIQUID Liquid Light
  197. LIGHTWEIGHT Elements with this behavior fall slower and in a more random pattern Feather
  198. SLIDE This behavior is similar to SUPERFLUID_OLD, and has never been used in the game -
  199. AGLIQUID LIQUID_OLD behavior with reversed gravity (liquid goes up) Antifluid
  200. WALL Default behavior of solids Wall
  201. SLIDE Behavior similar to SUPERFLUID_OLD -
  202. UL_UR Behavior of Fire before Version 1.8.1 -
  203. UL_UR_OPTIMIZED Behavior of Fire Fire
  204. GAS_OLD Default behavior of gases before Version 1.6 -
  205. GAS Default behavior of gases Steam
  206. DGAS Behavior similar to GAS_OLD; pixel has 5% chance of deleting itself every tick Smoke
  207. SUPPORT Elements with this behavior can float if they are connected to a floating element on both sides, otherwise they fall straight down Mudstone
  208. 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
  209. DELETE Elements with this behavior all neighboring pixels (without diagonals) Void
  210. FILL Elements with this behavior clone themselves into all neighboring pixels (without diagonals) Filler
  211. CLONER Elements with this behavior clone the first pixel that touches them into all neighboring pixels (without diagonals) Cloner
  212. STURDYPOWDER Elements with this behavior fall straight down Mud
  213. SELFDELETE Elements with this behavior delete themselves -
  214. FOAM Default behavior of Foam Foam
  215. BUBBLE Default behavior of Bubble Bubble
  216. STICKY Elements with this behavior stick to other elements Glue
  217. MOLTEN Default behavior of molten elements Magma
  218. RADPOWDER Behavior similar to POWDER_OLD; pixel has 1% chance of creating radiation Rad Shard
  219. RADMOLTEN Behavior similar to MOLTEN; pixel has 1% chance of creating radiation Molten Uranium
  220. RADLIQUID Behavior similar to LIQUID_OLD; pixel has 2% chance of creating radiation -
  221. BOUNCY Elements with this behavior fly around the screen and can bounce off other pixels Laser
  222. FEEDPIXEL Behavior used in reactions; allows animals to eat other pixels Worm + Nut reaction
  223. KILLPIXEL1 Behavior used in reactions; kills the current pixel -
  224. KILLPIXEL2 Behavior used in reactions; kills the other pixel Dioxin + Head reaction
  225. FLY Default behavior of some flying insects Bee
  226. 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
  227. Rules
  228. Colons
  229. 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.
  230.  
  231. For HT and CO, a number can be specified (the amount by which the temperature is changed), but non-numeric values are ignored.
  232.  
  233. Angle bracket
  234. 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).
  235.  
  236. Commas
  237. 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.
  238.  
  239. Percent sign
  240. 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
  241.  
  242. [
  243. ["XX","XX","XX"],
  244. ["XX","DL%50","XX"],
  245. ["XX","XX","XX"]
  246. ]
  247. has a 50% chance of deleting itself each tick.
  248.  
  249. AND
  250. 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).
  251.  
  252. Nonexistent rules
  253. Nonexistent rules are ignored.
  254.  
  255. Form
  256. Behaviors are initially defined in the form
  257.  
  258. [
  259. "AA|AA|AA",
  260. "AA|AA|AA",
  261. "AA|AA|AA"
  262. ]
  263. (AA = any rule)
  264.  
  265. 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.
  266.  
  267. 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.
  268.  
  269. XX
  270. XX in a behavior means that nothing is specified. The element Wall has a behavior of
  271.  
  272. [
  273. ["XX","XX","XX"],
  274. ["XX","XX","XX"],
  275. ["XX","XX","XX"]
  276. ]
  277. which means that it stays still and do nothing (as it has no tick functions or reactions)
  278.  
  279. M1 and M2
  280. 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.
  281.  
  282. An example, the old behavior of sand, is given in a comment within the game's code (it currently uses an equivalent tick function).
  283.  
  284. /* Behavior Example (Sand)
  285. [
  286. ["XX","XX","XX"],
  287. ["XX","XX","XX"],
  288. ["M2","M1","M2"]
  289. ] */
  290. 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).
  291.  
  292. SP
  293. 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
  294.  
  295. [
  296. ["XX","XX","XX"],
  297. ["SP","XX","SP"],
  298. ["XX","M1","XX"]
  299. ]
  300. A mudstone pixel will fall straight down unless it has pixels (of any elements) on each side.
  301.  
  302. 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).
  303.  
  304. SA
  305. 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
  306.  
  307. [
  308. ["XX","XX","XX"],
  309. ["SA","XX","SA"],
  310. ["XX","M1","XX"]
  311. ]
  312. would fall straight down unless it has any pixel(s) on its sides.
  313.  
  314. Unlike SP, element specifications are ignored.
  315.  
  316. DL
  317. 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.
  318.  
  319. A pixel that only deletes itself, like Pointer, would have the behavior
  320.  
  321. [
  322. ["XX","XX","XX"],
  323. ["XX","DL","XX"],
  324. ["XX","XX","XX"]
  325. ]
  326. and a pixel that deletes those adjacent to it (i.e. Void), will have
  327.  
  328. [
  329. ["XX","DL","XX"],
  330. ["DL","XX","DL"],
  331. ["XX","DL","XX"]
  332. ]
  333. DL is programmed to ignore itself.
  334.  
  335. DB
  336. 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.
  337.  
  338. DB in the center position has no effect, and DB is also programmed to ignore itself.
  339.  
  340. CL
  341. 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
  342.  
  343. [
  344. ["XX","XX","XX"],
  345. ["CL","XX","XX"],
  346. ["XX","XX","XX"]
  347. ]
  348. will create more of itself to its left until it is blocked. Filler, whose behavior is
  349.  
  350. [
  351. ["XX","CL","XX"],
  352. ["CL","XX","CL"],
  353. ["XX","CL","XX"]
  354. ]
  355. spreads infinitely by filling the adjacent pixels with itself.
  356.  
  357. CF
  358. 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:
  359.  
  360. Store the pixel on top.
  361. If there is no pixel on top, store the pixel to the left.
  362. If there is no pixel to the left, store the pixel on the right.
  363. If there is no pixel to the right, store the pixel below it.
  364. Once a pixel is chosen, it will be created perpetually from all positions that had a CF.
  365.  
  366. 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.
  367.  
  368. Cloner's behavior is
  369.  
  370. [
  371. ["XX","CF","XX"],
  372. ["CF","XX","CF"],
  373. ["XX","CF","XX"]
  374. ]
  375. which means that the first pixel to touch it will be cloned on the cloner's sides.
  376.  
  377. CH
  378. CH (Change) in a behavior means that any pixel in the corresponding position will be replaced with the given element.
  379.  
  380. The element that things will change into is separated with a colon. An element with the behavior
  381.  
  382. [
  383. ["XX","CH:iron","XX"],
  384. ["CH:iron","XX","CH:iron"],
  385. ["M2","M1 AND CH:iron","M2"]
  386. ]
  387. will be a powder that turns anything it touches to iron (behaving unpredictably with itself unless it is explicitly told to ignore itself).
  388.  
  389. An element with
  390.  
  391. [
  392. ["XX","XX","XX"],
  393. ["XX","CH:sand","XX"],
  394. ["XX","XX","XX"]
  395. ]
  396. will immediately turn into sand.
  397.  
  398. Multiple elements to change into can be specified with commas; the result will be chosen randomly.
  399.  
  400. 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.
  401.  
  402. 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.
  403.  
  404. These can be combined. For instance, an element with the behavior
  405.  
  406. [
  407. ["XX%0000000000000000000000000000000000000000","CH:lead,tin,iron,copper,mercury>gold,silver","XX%0000000000000000000000000000000000000000"],
  408. ["CH:lead,tin,iron,copper,mercury>gold,silver","XX%0000000000000000000000000000000000000000","CH:lead,tin,iron,copper,mercury>gold,silver"],
  409. ["XX%0000000000000000000000000000000000000000","CH:lead,tin,iron,copper,mercury>gold,silver","XX%0000000000000000000000000000000000000000"]
  410. ]
  411. (padded for readability) will change any pixels of lead, tin, iron, copper, or mercury into random gold and silver.
  412.  
  413. (It should be noted that reactions are more efficient for changing things.)
  414.  
  415. CH without a colon will cause the canvas to turn black and the game to stop responding.
  416.  
  417. CH example summary
  418. Single element without angle bracket
  419. CH:dirt
  420. Any element in the position of this rule will be changed into dirt.
  421.  
  422. Element list without angle bracket
  423. CH:dirt,sand
  424. 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.
  425.  
  426. Single elements with angle bracket
  427. CH:rainbow>static
  428. Any rainbow in the position of this rule will be changed into static.
  429.  
  430. Angle bracket with list to the left and single element to the right
  431. CH:rainbow,static>border
  432. Any rainbow or static in the position of this rule will be changed into border.
  433.  
  434. Angle bracket with single element to the left and list to the right
  435. CH:rainbow>static,border
  436. 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.
  437.  
  438. Element lists with angle bracket
  439. CH:rock,sand>zinc,sponge
  440. 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.
  441.  
  442. C2
  443. 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.
  444.  
  445. If multiple elements are given with commas, they will be chosen randomly as with CH.
  446.  
  447. C2 without any elements specified will also cause a black error canvas.
  448.  
  449. CR
  450. 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).
  451.  
  452. LB, L1, and L2
  453. 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.
  454.  
  455. Lists are chosen from randomly.
  456.  
  457. L1 and L2 are like LB, but only apply to M1 and M2 moves, respectively.
  458.  
  459. SW
  460. SW (Swap) in a behavior means that an element will swap with whatever element is specified.
  461.  
  462. An element with
  463.  
  464. [
  465. ["XX","SW:wood","XX"],
  466. ["XX","XX","XX"],
  467. ["M2","M1","M2"]
  468. ]
  469. will fall down like sand unless there is wood above it, in which case it will switch places upwards through the wood.
  470.  
  471. If multiple elements are specified, it will swap through all of the elements specified.
  472.  
  473. HT and CO
  474. 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.
  475.  
  476. CC
  477. 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.
  478.  
  479. ST
  480. ST (Stick) is like SA, but without sticking to itself.
  481.  
  482. SH
  483. 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.
  484.  
  485. FX and FY
  486. FX (Flip X) in a behavior means that it will flip across the X axis. For instance, a behavior of
  487.  
  488. [
  489. ["XX","M2","XX"],
  490. ["XX","FX","M1"],
  491. ["XX","M2","XX"]
  492. ]
  493. would become
  494.  
  495. [
  496. ["XX","M2","XX"],
  497. ["M1","FX","XX"],
  498. ["XX","M2","XX"]
  499. ]
  500. .
  501.  
  502. FY (Flip Y) is the same over the Y axis.
  503.  
  504. 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.
  505.  
  506. RT
  507. (This section is incomplete.)
  508.  
  509. RT (Rotate) in a behavior means that the pixel's r value will increase and it will operate with an accordingly rotated behavior.
  510.  
  511. r value Rotation
  512. 0 0°
  513. 1 90° CCW/ACW
  514. 2 180°
  515. 3 270° CCW/ACW
  516. Values > 4 are mod 4
  517. (4 → 0, 5 → 1, etc.)
  518. By default, RT will increase r by 1, but specifying a number will increase r by that number; RT:2 specifies a 180° turn.
  519.  
  520. RT has no effect unless the element's rotatable property is true. However, existing r values would still apply.
  521.  
  522. BO
  523. BO is like FX or FY, but
  524.  
  525. which axis gets flipped varies depending on its position in the behavior, and
  526. it only applies when its corresponding position on the canvas is blocked by a pixel or boundary.
  527. An element with the behavior
  528.  
  529. [
  530. ["XX","XX","XX"],
  531. ["XX","XX","XX"],
  532. ["XX","M1 AND BO","XX"],
  533. ]
  534. 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.
  535.  
  536. 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.
  537.  
  538. EX
  539. 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.
  540.  
  541. 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
  542.  
  543. [
  544. ["XX","XX","XX"],
  545. ["XX","XX","XX"],
  546. ["XX","M1 AND EX:10>sand","XX"],
  547. ]
  548. will fall down and explode into sand when it lands on something.
  549. REACTIONS
  550. Reaction requirements
  551. Reactions can be controlled and may be written to occur only when specific requirements are met:
  552.  
  553. Property name Description Reaction example
  554. chance Chance per tick of reaction occurring Borax + Glue
  555. tempMin Minimum temperature a reaction can occur Rock + Bone
  556. tempMax Maximum temperature a reaction can occur Tuff + Charcoal
  557. oneway Reaction only occurs if elem1 moves into elem2 Water + Carbon Dioxide
  558. charged Reaction only occurs if elements are charged Water + Zinc
  559. burning1 Reaction only occurs if elem1 is burning Not used
  560. burning2 Reaction only occurs if elem2 is burning Chlorine + Oil
  561. "y" Reaction only occurs at y-values within range Steam + Snow Cloud
  562. "setting" Reaction only occurs if specified setting is enabled Oxygen + Ozone
  563. Examples of implementation include:
  564.  
  565. reactions: {
  566. "chance_ex": { elem1:null, elem2:null, chance:0.5 }, // 50% chance per tick
  567. "temprange_ex": { elem1:null, elem2:null, tempMin:50, tempMax:100 }, // Temp must be between 50 and 100
  568. "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
  569. "charged_ex": { elem1:null, elem2:null, charged:true }, // Elements must be charged
  570. "burning_ex": { elem1:null, elem2:null, burning1:true, burning2:true }, // elem1 and elem2 must be burning
  571. "height_ex": { elem1:null, elem2:null, "y":[81,71] } // Only at y-values between 81 and 71
  572. "setting_ex": { elem1:null, elem2:null, "setting":"clouds" } // Clouds setting must be toggled on
  573. },
  574. Product properties
  575. The properties of a reaction's product(s) can be overridden. These properties include:
  576.  
  577. Property name Description Reaction example
  578. elem1 What primary reactant becomes Almost all reactions
  579. elem2 What secondary reactant becomes Almost all reactions
  580. color1 Color(s) of primary reactant Brass + Ammonia
  581. color2 Color(s) of secondary reactant Dough + Milk
  582. temp1 Temperature of primary reactant Cloud + Electric
  583. temp2 Temperature of secondary reactant Neutron + Uranium
  584. attr1 Additional attribute of primary reactant, must be applicable Vinegar + Limestone
  585. attr2 Additional attribute of secondary reactant, must be applicable Yeast + Bleach
  586. Examples of implementation include:
  587.  
  588. reactions: {
  589. "elem_ex": { elem1:"water", elem2:"dirt" } // Primary reactant becomes Water, elem_ex becomes Dirt
  590. "color_ex": { color1:"#FFFFFF", color2:"#000000" }, // Primary reactant turns white, color_ex turns black
  591. "temp_ex": { temp1:500, color2:-800 }, // Primary reactant becomes 500°C, temp_ex becomes -80°C
  592. "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
  593. },
  594. The base game utilizes the "foam" attribute, which only takes effect if the reactant has a function utilizing it. For example, Sodium Acetate contains:
  595.  
  596. tick: function(pixel) {
  597. if ((pixel.foam || Math.random() < 0.25) && isEmpty(pixel.x,pixel.y-1)) {
  598. createPixel("foam",pixel.x,pixel.y-1);
  599. if (pixel.foam) {
  600. pixelMap[pixel.x][pixel.y-1].foam = pixel.foam;
  601. pixel.foam--;
  602. }
  603. }
  604. },
  605. 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.
  606.  
  607. Functions for properties
  608. A function can be used in a reaction statement to set any of an element's properties following the reaction. For example:
  609.  
  610. reactions: {
  611. "water": {func: (pixel1) => {pixel1.burning=true;pixel1.burnStart=pixelTicks}, // Primary reactant is burning starting at current tick
  612. elem2: ["caustic_potash", "fire"], temp2: 400}
  613. }
  614. 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