2024-01-02 16:04:32 -05:00
// Gallium is the best element
2024-04-09 18:34:17 -04:00
behaviors . RADSOLID = [
"XX|CR:radiation%1|XX" ,
"CR:radiation%1|XX|CR:radiation%1" ,
"XX|CR:radiation%1|XX"
]
2023-11-26 15:00:56 -05:00
elements . caesium = {
2024-01-02 15:10:11 -05:00
color : [ "#917921" , "#ebcb59" , "#a48b2d" , "#d6b84c" ] ,
behavior : behaviors . WALL ,
category : "solids" ,
state : "solid" ,
tempHigh : 28.44 ,
stateHigh : "molten_caesium" ,
density : 1873 ,
conduct : 0.90 ,
reactions : {
"water" : { "elem1" : "pop" , "elem2" : "hydrogen" } ,
"sugar_water" : { "elem1" : "pop" , "elem2" : "hydrogen" } ,
"dirty_water" : { "elem1" : "pop" , "elem2" : "hydrogen" } ,
"pool_water" : { "elem1" : "pop" , "elem2" : "hydrogen" } ,
"salt_water" : { "elem1" : "pop" , "elem2" : "hydrogen" } ,
"seltzer" : { "elem1" : "pop" , "elem2" : "hydrogen" } ,
}
2023-11-26 18:41:09 -05:00
} ,
2023-11-26 15:00:56 -05:00
elements . molten _caesium = {
color : [ "#735c0a" , "#a68e37" , "#7e6715" , "#9b832e" ] ,
behavior : behaviors . LIQUID ,
category : "states" ,
state : "liquid" ,
tempLow : 27.44 ,
stateLow : "caesium" ,
2024-04-09 18:34:17 -04:00
hidden : true ,
2023-11-26 15:00:56 -05:00
tempHigh : 671 ,
stateHigh : "caesium_vapor" ,
2024-04-07 14:26:05 -04:00
density : 1842 ,
2023-11-26 15:00:56 -05:00
temp : 29 ,
2024-01-02 15:10:11 -05:00
conduct : 0.90 ,
2023-11-26 15:00:56 -05:00
reactions : {
"water" : { "elem1" : "pop" , "elem2" : "hydrogen" } ,
"sugar_water" : { "elem1" : "pop" , "elem2" : "hydrogen" } ,
"dirty_water" : { "elem1" : "pop" , "elem2" : "hydrogen" } ,
"pool_water" : { "elem1" : "pop" , "elem2" : "hydrogen" } ,
"salt_water" : { "elem1" : "pop" , "elem2" : "hydrogen" } ,
"seltzer" : { "elem1" : "pop" , "elem2" : "hydrogen" } ,
}
2023-11-26 18:41:09 -05:00
} ,
2023-11-26 15:00:56 -05:00
elements . caesium _vapor = {
color : [ "#d89e77" , "#cd9064" , "#af6f34" , "#a26320" ] ,
behavior : behaviors . GAS ,
category : "states" ,
state : "gas" ,
tempLow : 660 ,
2024-04-09 18:34:17 -04:00
hidden : true ,
2023-11-26 15:00:56 -05:00
stateLow : "molten_caesium" ,
density : 1.7 ,
temp : 700
2024-04-09 18:34:17 -04:00
}
elements . caesium _137 = {
color : [ "#917921" , "#ebcb59" , "#a48b2d" , "#d6b84c" ] ,
behavior : behaviors . RADSOLID ,
category : "solids" ,
state : "solid" ,
tempHigh : 28.44 ,
stateHigh : "molten_caesium_137" ,
density : 1873 ,
conduct : 0.90 ,
reactions : {
"water" : { "elem1" : "pop" , "elem2" : "hydrogen" } ,
"sugar_water" : { "elem1" : "pop" , "elem2" : "hydrogen" } ,
"dirty_water" : { "elem1" : "pop" , "elem2" : "hydrogen" } ,
"pool_water" : { "elem1" : "pop" , "elem2" : "hydrogen" } ,
"salt_water" : { "elem1" : "pop" , "elem2" : "hydrogen" } ,
"seltzer" : { "elem1" : "pop" , "elem2" : "hydrogen" } ,
} ,
tick : function ( pixel ) {
if ( Math . random ( ) < 0.0002 ) {
changePixel ( pixel , "barium" , false )
if ( Math . random ( ) >= 0.946 ) {
pixelMap [ pixel . x ] [ pixel . y ] . excited = true
}
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
createPixel ( "electric" , x , y )
break ;
}
}
}
}
2023-11-26 18:41:09 -05:00
} ,
2024-04-09 18:34:17 -04:00
elements . molten _caesium _137 = {
color : [ "#735c0a" , "#a68e37" , "#7e6715" , "#9b832e" ] ,
behavior : behaviors . RADLIQUID ,
category : "states" ,
state : "liquid" ,
tempLow : 27.44 ,
stateLow : "caesium_137" ,
tempHigh : 671 ,
hidden : true ,
stateHigh : "caesium_vapor_137" ,
density : 1842 ,
temp : 29 ,
conduct : 0.90 ,
reactions : {
"water" : { "elem1" : "pop" , "elem2" : "hydrogen" } ,
"sugar_water" : { "elem1" : "pop" , "elem2" : "hydrogen" } ,
"dirty_water" : { "elem1" : "pop" , "elem2" : "hydrogen" } ,
"pool_water" : { "elem1" : "pop" , "elem2" : "hydrogen" } ,
"salt_water" : { "elem1" : "pop" , "elem2" : "hydrogen" } ,
"seltzer" : { "elem1" : "pop" , "elem2" : "hydrogen" } ,
} ,
tick : function ( pixel ) {
if ( Math . random ( ) < 0.0002 ) {
changePixel ( pixel , "barium" , false )
if ( Math . random ( ) >= 0.946 ) {
pixelMap [ pixel . x ] [ pixel . y ] . excited = true
}
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
createPixel ( "electric" , x , y )
break ;
}
}
}
}
} ,
2024-04-09 18:50:14 -04:00
elements . caesium _137 _vapor = {
2024-04-09 18:34:17 -04:00
color : [ "#d89e77" , "#cd9064" , "#af6f34" , "#a26320" ] ,
2024-04-09 18:50:14 -04:00
behavior : behaviors . RADSOLID ,
2024-04-09 18:34:17 -04:00
category : "states" ,
state : "gas" ,
tempLow : 660 ,
stateLow : "molten_caesium_137" ,
density : 1.7 ,
temp : 700 ,
hidden : true ,
tick : function ( pixel ) {
2024-04-09 18:50:14 -04:00
behaviors . GAS ( pixel )
2024-04-09 18:34:17 -04:00
if ( Math . random ( ) < 0.0002 ) {
changePixel ( pixel , "barium" , false )
if ( Math . random ( ) >= 0.946 ) {
pixelMap [ pixel . x ] [ pixel . y ] . excited = true
}
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
createPixel ( "electric" , x , y )
break ;
}
}
}
}
}
elements . barium = {
color : [ "#191f19" , "#2c332c" , "#3f483f" , "#545e54" , "#6a756a" ] ,
behavior : behaviors . STURDYPOWDER ,
reactions : elements . caesium . reactions ,
category : "powders" ,
state : "solid" ,
tempHigh : 730 ,
stateHigh : "molten_barium" ,
density : 3594 ,
tick : function ( pixel ) {
if ( pixel . excited && Math . random ( ) < 0.005 ) {
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
createPixel ( "laser" , x , y )
pixelMap [ x ] [ y ] . temp = pixel . temp + 120
delete pixel . excited
break ;
}
}
}
}
}
elements . molten _barium = {
color : [ "#c26d24" , "#cf8225" , "#da9727" , "#e4ad2b" , "#ecc432" ] ,
behavior : behaviors . MOLTEN ,
reactions : elements . caesium . reactions ,
category : "states" ,
state : "liquid" ,
tempLow : 728 ,
hidden : true ,
stateLow : "barium" ,
density : 3338 ,
tick : function ( pixel ) {
if ( pixel . excited && Math . random ( ) < 0.005 ) {
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
createPixel ( "laser" , x , y )
pixelMap [ x ] [ y ] . temp = pixel . temp + 120
delete pixel . excited
break ;
}
}
}
}
}
2023-11-26 18:41:09 -05:00
elements . subzero _grass _seed = {
color : [ "#022c14" , "#032911" , "#032205" , "#021f00" ] ,
behavior : [
"XX|M2%0.1|XX" ,
"XX|L2:subzero_grass AND C2:subzero_grass%15|XX" ,
"XX|M1|XX" ,
] ,
category : "life" ,
state : "solid" ,
tempHigh : 10 ,
temp : 0 ,
stateHigh : "dead_plant" ,
density : 1400
} ,
elements . subzero _grass = {
color : [ "#003220" , "#022a1a" , "#032314" , "#001c0d" ] ,
behavior : behaviors . STURDYPOWDER ,
category : "life" ,
state : "solid" ,
tempHigh : 13 ,
temp : 0 ,
stateHigh : "dead_plant" ,
density : 1400
} ,
2024-03-29 11:13:40 -04:00
elements . ruthenium = {
color : [ "#ffffff" , "#c9c9c9" , "#b1b1b1" , "#9e9e9e" , "#888888" ] ,
behavior : behaviors . STURDYPOWDER ,
category : "powders" ,
state : "liquid" ,
tempHigh : 2334 ,
stateHigh : "molten_ruthenium" ,
density : 12370 ,
}
elements . molten _ruthenium = {
color : [ "#ffc251" , "#dd562c" , "#e9a423" , "#d8722e" ] ,
behavior : behaviors . MOLTEN ,
category : "states" ,
state : "liquid" ,
hidden : true ,
density : 10650 ,
tempLow : 2330 ,
stateLow : "ruthenium"
}
elements . acid . ignore . push ( "ruthenium" ) ,
elements . acid . ignore . push ( "molten_ruthenium" ) ,
elements . acid _gas . ignore . push ( "ruthenium" ) ,
elements . acid _gas . ignore . push ( "molten_ruthenium" )
2023-11-26 18:41:09 -05:00
elements . technetium = {
color : [ "#e7d9bb" , "#bab195" , "#8f8a70" , "#66654e" ] ,
2024-04-09 18:34:17 -04:00
behavior : behaviors . RADSOLID ,
2024-03-29 11:13:40 -04:00
tick : function ( pixel ) {
if ( Math . random ( ) < 0.0007 ) {
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
createPixel ( "positron" , x , y )
break ;
}
}
changePixel ( pixel , "ruthenium" , false ) ;
}
} ,
2023-11-26 18:41:09 -05:00
category : "solids" ,
state : "solid" ,
tempHigh : 2157 ,
stateHigh : "molten_technetium" ,
2023-12-31 14:23:57 -05:00
density : 11500 ,
2024-01-02 15:10:11 -05:00
conduct : 0.9
2023-11-26 18:41:09 -05:00
} ,
elements . molten _technetium = {
color : [ "#d16b42" , "#da904c" , "#dfb360" , "#e2d57f" ] ,
2024-04-09 18:34:17 -04:00
behavior : behaviors . RADMOLTEN ,
2024-03-29 11:13:40 -04:00
tick : function ( pixel ) {
if ( Math . random ( ) < 0.0007 ) {
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
createPixel ( "positron" , x , y )
break ;
}
}
changePixel ( pixel , "ruthenium" , false ) ;
}
} ,
2023-11-26 18:41:09 -05:00
category : "states" ,
state : "liquid" ,
2024-03-29 11:13:40 -04:00
hidden : true ,
2023-11-26 18:41:09 -05:00
tempLow : 2140 ,
temp : 2200 ,
stateLow : "technetium" ,
density : 11400
2023-12-01 18:50:14 -05:00
} ,
elements . destroyable _pipe = {
color : "#414c4f" ,
tick : function ( pixel ) {
if ( ! pixel . stage && pixelTicks - pixel . start > 60 ) {
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
createPixel ( "brick" , x , y ) ;
2025-02-21 16:54:38 -05:00
pixelMap [ x ] [ y ] . color = pixelColorPick ( pixel , "#586879" ) ;
2023-12-01 18:50:14 -05:00
}
}
pixel . stage = 1 ;
}
else if ( pixel . stage === 1 && pixelTicks - pixel . start > 70 ) { //uninitialized
for ( var i = 0 ; i < adjacentCoords . length ; i ++ ) {
var coord = adjacentCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
pixel . stage = 2 ; //blue
pixel . color = pixelColorPick ( pixel , "#000036" ) ;
break ;
}
}
}
else if ( pixel . stage > 1 && pixelTicks % 3 === pixel . stage - 2 ) { //initialized
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
2023-12-03 20:55:19 -05:00
if ( ! isEmpty ( x , y , true ) && ( pixelMap [ x ] [ y ] . element === "destroyable_pipe" || pixelMap [ x ] [ y ] . element === "bridge_pipe" ) ) {
2023-12-01 18:50:14 -05:00
var newPixel = pixelMap [ x ] [ y ] ;
if ( newPixel . stage === 1 ) {
var newColor ;
switch ( pixel . stage ) {
case 2 : newPixel . stage = 3 ; newColor = "#003600" ; break ; //green
case 3 : newPixel . stage = 4 ; newColor = "#360000" ; break ; //red
case 4 : newPixel . stage = 2 ; newColor = "#000036" ; break ; //blue
}
newPixel . color = pixelColorPick ( newPixel , newColor ) ;
}
}
}
var moved = false ;
shuffleArray ( squareCoordsShuffle ) ;
for ( var i = 0 ; i < squareCoordsShuffle . length ; i ++ ) {
var coord = squareCoordsShuffle [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
2024-12-28 22:39:50 -05:00
if ( newPixel . element === "destroyable_pipe" || newPixel . element === "bridge_pipe" || newPixel . element === "pipe_transmitter" ) {
2023-12-01 18:50:14 -05:00
var nextStage ;
switch ( pixel . stage ) {
case 2 : nextStage = 4 ; break ; //green
case 3 : nextStage = 2 ; break ; //red
case 4 : nextStage = 3 ; break ; //blue
}
2024-12-28 22:39:50 -05:00
if ( pixel . con && ! newPixel . con && ( newPixel . stage === nextStage || newPixel . element === "pipe_transmitter" ) ) { //transfer to adjacent pipe
2023-12-01 18:50:14 -05:00
newPixel . con = pixel . con ;
newPixel . con . x = newPixel . x ;
newPixel . con . y = newPixel . y ;
pixel . con = null ;
moved = true ;
break ;
}
}
2024-05-12 15:57:45 -04:00
else if ( ! pixel . con && elements [ newPixel . element ] . movable && newPixel . element != "ray" ) { //suck up pixel
2023-12-01 18:50:14 -05:00
pixel . con = newPixel ;
deletePixel ( newPixel . x , newPixel . y ) ;
pixel . con . x = pixel . x ;
pixel . con . y = pixel . y ;
pixel . con . del ;
moved = true ;
break ;
}
}
}
if ( pixel . con && ! moved ) { // move to same stage if none other
for ( var i = 0 ; i < squareCoordsShuffle . length ; i ++ ) {
var coord = squareCoordsShuffle [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
delete pixel . con . del ;
pixel . con . x = x ;
pixel . con . y = y ;
pixelMap [ x ] [ y ] = pixel . con ;
currentPixels . push ( pixel . con ) ;
pixel . con = null ;
break ;
}
2023-12-03 20:55:19 -05:00
if ( ! isEmpty ( x , y , true ) && ( pixelMap [ x ] [ y ] . element === "destroyable_pipe" || pixelMap [ x ] [ y ] . element === "bridge_pipe" ) ) {
2023-12-01 18:50:14 -05:00
var newPixel = pixelMap [ x ] [ y ] ;
if ( pixel . con && ! newPixel . con && newPixel . stage === pixel . stage ) {
newPixel . con = pixel . con ;
newPixel . con . x = newPixel . x ;
newPixel . con . y = newPixel . y ;
pixel . con = null ;
break ;
}
}
}
}
}
doDefaults ( pixel ) ;
} ,
category : "machines" ,
movable : false ,
canContain : true ,
tempHigh : 1538 ,
stateHigh : "molten_iron" ,
breakInto : "metal_scrap" ,
} ,
elements . destroyable _superheater = {
color : "#dd1111" ,
behavior : [
"XX|HT:10|XX" ,
"HT:10|XX|HT:10" ,
"XX|HT:10|XX" ,
] ,
category : "machines" ,
stateLow : [ "iron" , "copper" ] ,
tempLow : - 7 ,
2024-08-24 15:14:04 -04:00
breakInto : [ "metal_scrap" , "oxidized_copper" ] ,
2023-12-01 18:50:14 -05:00
} ,
elements . destroyable _heater = {
color : "#881111" ,
behavior : [
"XX|HT:2|XX" ,
"HT:2|XX|HT:2" ,
"XX|HT:2|XX" ,
] ,
category : "machines" ,
stateLow : [ "iron" , "copper" ] ,
tempLow : - 7 ,
2024-08-24 15:14:04 -04:00
breakInto : [ "metal_scrap" , "oxidized_copper" ] ,
2023-12-01 18:50:14 -05:00
} ,
elements . destroyable _cooler = {
color : "#111188" ,
behavior : [
"XX|CO:2|XX" ,
"CO:2|XX|CO:2" ,
"XX|CO:2|XX" ,
] ,
category : "machines" ,
stateHigh : [ "iron" , "copper" ] ,
tempHigh : 49 ,
2024-08-24 15:14:04 -04:00
breakInto : [ "metal_scrap" , "oxidized_copper" ] ,
2023-12-01 18:50:14 -05:00
} ,
elements . destroyable _freezer = {
color : "#1111dd" ,
behavior : [
"XX|CO:10|XX" ,
"CO:10|XX|CO:10" ,
"XX|CO:10|XX" ,
] ,
category : "machines" ,
stateHigh : [ "iron" , "copper" ] ,
tempHigh : 49 ,
2023-12-03 08:37:26 -05:00
breakInto : [ "metal_scrap" , "oxidized_copper" ] ,
2023-12-01 18:50:14 -05:00
} ,
elements . destroyable _cloner = {
color : "#dddd00" ,
behavior : behaviors . CLONER ,
ignore : [ "ecloner" , "slow_cloner" , "clone_powder" , "floating_cloner" , "wall" , "ewall" , "destroyable_cloner" , "destroyable_clone_powder" , "cloner" ] ,
category : "machines" ,
darkText : true ,
breakInto : "destroyable_clone_powder" ,
tempHigh : 1538 ,
stateHigh : "molten_iron" ,
} ,
elements . destroyable _clone _powder = {
color : "#f0f000" ,
behavior : [
"XX|CF|XX" ,
"CF|XX|CF" ,
"M2|CF AND M1|M2" ,
] ,
ignore : [ "ecloner" , "slow_cloner" , "clone_powder" , "floating_cloner" , "wall" , "ewall" , "destroyable_cloner" , "destroyable_clone_powder" , "cloner" ] ,
category : "machines" ,
state : "solid" ,
density : 2710 ,
darkText : true ,
breakInto : "destroyable_clone_powder" ,
tempHigh : 1538 ,
stateHigh : "molten_iron" ,
} ,
eLists . CLONERS = [ "ecloner" , "slow_cloner" , "clone_powder" , "floating_cloner" , "wall" , "ewall" , "destroyable_cloner" , "destroyable_clone_powder" , "cloner" ] ;
elements . cloner . ignore = eLists . CLONERS ;
elements . slow _cloner . ignore = eLists . CLONERS ;
elements . clone _powder . ignore = eLists . CLONERS ;
elements . floating _cloner . ignore = eLists . CLONERS ;
2023-12-02 15:17:19 -05:00
elements . roomtemper = {
color : "#29632f" ,
2023-12-05 17:50:14 -05:00
behavior : behaviors . WALL ,
2023-12-02 15:17:19 -05:00
tick : function ( pixel ) {
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
2024-01-02 18:51:27 -05:00
if ( ! isEmpty ( x , y , true ) ) {
2023-12-03 08:37:26 -05:00
if ( pixelMap [ x ] [ y ] . temp < - 230 ) {
pixelMap [ x ] [ y ] . temp = ( pixelMap [ x ] [ y ] . temp + 7 )
} else if ( pixelMap [ x ] [ y ] . temp > 270 ) {
pixelMap [ x ] [ y ] . temp = ( pixelMap [ x ] [ y ] . temp - 7 )
} else if ( pixelMap [ x ] [ y ] . temp < 20 ) {
pixelMap [ x ] [ y ] . temp = ( pixelMap [ x ] [ y ] . temp + 2 )
} else if ( pixelMap [ x ] [ y ] . temp > 20 ) {
2023-12-02 15:17:19 -05:00
pixelMap [ x ] [ y ] . temp = ( pixelMap [ x ] [ y ] . temp - 2 )
}
}
}
} ,
category : "machines" ,
state : "solid" ,
insulate : true ,
2023-12-16 20:49:28 -05:00
noMix : true ,
movable : false ,
2023-12-02 15:17:19 -05:00
} ,
2023-12-03 08:37:26 -05:00
elements . destroyable _roomtemper = {
2023-12-02 15:17:19 -05:00
color : "#18401a" ,
2023-12-05 17:50:14 -05:00
behavior : behaviors . WALL ,
2023-12-02 15:17:19 -05:00
tick : function ( pixel ) {
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
2024-01-02 18:51:27 -05:00
if ( ! isEmpty ( x , y , true ) ) {
2023-12-03 08:37:26 -05:00
if ( pixelMap [ x ] [ y ] . temp < - 230 ) {
pixelMap [ x ] [ y ] . temp = ( pixelMap [ x ] [ y ] . temp + 7 )
} else if ( pixelMap [ x ] [ y ] . temp > 270 ) {
pixelMap [ x ] [ y ] . temp = ( pixelMap [ x ] [ y ] . temp - 7 )
} else if ( pixelMap [ x ] [ y ] . temp < 20 ) {
pixelMap [ x ] [ y ] . temp = ( pixelMap [ x ] [ y ] . temp + 2 )
} else if ( pixelMap [ x ] [ y ] . temp > 20 ) {
2023-12-02 15:17:19 -05:00
pixelMap [ x ] [ y ] . temp = ( pixelMap [ x ] [ y ] . temp - 2 )
}
}
}
} ,
category : "machines" ,
state : "solid" ,
tempHigh : 1538 ,
stateHigh : [ "steam" , "molten_iron" ] ,
tempLow : - 200 ,
stateLow : [ "ice" , "iron" ] ,
breakInto : [ "snow" , "metal_scrap" ] ,
2023-12-16 20:49:28 -05:00
noMix : true ,
movable : false ,
2023-12-03 08:37:26 -05:00
} ,
elements . customtemper = {
color : "#421b6b" ,
2023-12-05 17:50:14 -05:00
behavior : behaviors . WALL ,
2023-12-03 08:37:26 -05:00
tick : function ( pixel ) {
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
2024-01-02 18:51:27 -05:00
if ( ! isEmpty ( x , y , true ) ) {
2023-12-03 08:37:26 -05:00
if ( pixelMap [ x ] [ y ] . temp < ( pixel . temp - 250 ) ) {
pixelMap [ x ] [ y ] . temp = ( pixelMap [ x ] [ y ] . temp + 7 )
} else if ( pixelMap [ x ] [ y ] . temp > ( pixel . temp + 250 ) ) {
pixelMap [ x ] [ y ] . temp = ( pixelMap [ x ] [ y ] . temp - 7 )
} else if ( pixelMap [ x ] [ y ] . temp < pixel . temp ) {
pixelMap [ x ] [ y ] . temp = ( pixelMap [ x ] [ y ] . temp + 2 )
} else if ( pixelMap [ x ] [ y ] . temp > pixel . temp ) {
pixelMap [ x ] [ y ] . temp = ( pixelMap [ x ] [ y ] . temp - 2 )
}
}
}
} ,
category : "machines" ,
state : "solid" ,
insulate : true ,
2023-12-16 20:49:28 -05:00
noMix : true ,
movable : false ,
2023-12-03 08:37:26 -05:00
} ,
elements . destroyable _customtemper = {
color : "#261047" ,
2023-12-05 17:50:14 -05:00
behavior : behaviors . WALL ,
2023-12-03 08:37:26 -05:00
tick : function ( pixel ) {
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
2024-01-02 18:51:27 -05:00
if ( ! isEmpty ( x , y , true ) ) {
2023-12-03 08:37:26 -05:00
if ( pixelMap [ x ] [ y ] . temp < ( pixel . temp - 250 ) ) {
pixelMap [ x ] [ y ] . temp = ( pixelMap [ x ] [ y ] . temp + 7 )
} else if ( pixelMap [ x ] [ y ] . temp > ( pixel . temp + 250 ) ) {
pixelMap [ x ] [ y ] . temp = ( pixelMap [ x ] [ y ] . temp - 7 )
} else if ( pixelMap [ x ] [ y ] . temp < pixel . temp ) {
pixelMap [ x ] [ y ] . temp = ( pixelMap [ x ] [ y ] . temp + 2 )
} else if ( pixelMap [ x ] [ y ] . temp > pixel . temp ) {
pixelMap [ x ] [ y ] . temp = ( pixelMap [ x ] [ y ] . temp - 2 )
}
}
}
} ,
category : "machines" ,
state : "solid" ,
insulate : true ,
breakInto : [ "snow" , "metal_scrap" , "oxidized_copper" , "wire" ] ,
2023-12-16 20:49:28 -05:00
noMix : true ,
movable : false ,
2023-12-03 16:16:13 -05:00
} ,
elements . e _pipe = {
color : "#414c4f" ,
onSelect : function ( ) {
logMessage ( "Draw a pipe, wait for walls to appear, then erase the exit hole." ) ;
} ,
tick : function ( pixel ) {
if ( ! pixel . stage && pixelTicks - pixel . start > 60 ) {
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
2025-01-22 16:15:27 -05:00
createPixel ( "pipe_wall" , x , y ) ;
2025-02-21 16:54:38 -05:00
pixelMap [ x ] [ y ] . color = pixelColorPick ( pixel , "#586879" ) ;
2023-12-03 16:16:13 -05:00
}
}
pixel . stage = 1 ;
}
else if ( pixel . stage === 1 && pixelTicks - pixel . start > 70 ) { //uninitialized
for ( var i = 0 ; i < adjacentCoords . length ; i ++ ) {
var coord = adjacentCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
pixel . stage = 2 ; //blue
pixel . color = pixelColorPick ( pixel , "#000036" ) ;
break ;
}
}
}
else if ( pixel . stage > 1 && pixelTicks % 3 === pixel . stage - 2 ) { //initialized
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
2023-12-03 20:55:19 -05:00
if ( ! isEmpty ( x , y , true ) && ( pixelMap [ x ] [ y ] . element === "e_pipe" || pixelMap [ x ] [ y ] . element === "bridge_pipe" ) ) {
2023-12-03 16:16:13 -05:00
var newPixel = pixelMap [ x ] [ y ] ;
if ( newPixel . stage === 1 ) {
var newColor ;
switch ( pixel . stage ) {
case 2 : newPixel . stage = 3 ; newColor = "#003600" ; break ; //green
case 3 : newPixel . stage = 4 ; newColor = "#360000" ; break ; //red
case 4 : newPixel . stage = 2 ; newColor = "#000036" ; break ; //blue
}
newPixel . color = pixelColorPick ( newPixel , newColor ) ;
}
}
}
var moved = false ;
shuffleArray ( squareCoordsShuffle ) ;
for ( var i = 0 ; i < squareCoordsShuffle . length ; i ++ ) {
var coord = squareCoordsShuffle [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
2024-12-28 22:39:50 -05:00
if ( newPixel . element === "e_pipe" || newPixel . element === "bridge_pipe" || newPixel . element === "pipe_transmitter" ) {
2023-12-03 16:16:13 -05:00
var nextStage ;
switch ( pixel . stage ) {
case 2 : nextStage = 4 ; break ; //green
case 3 : nextStage = 2 ; break ; //red
case 4 : nextStage = 3 ; break ; //blue
}
2024-12-28 22:39:50 -05:00
if ( pixel . con && ! newPixel . con && ( newPixel . stage === nextStage || newPixel . element === "pipe_transmitter" ) && ( pixel . charge || pixel . chargeCD ) ) { //transfer to adjacent pipe
2023-12-03 16:16:13 -05:00
newPixel . con = pixel . con ;
newPixel . con . x = newPixel . x ;
newPixel . con . y = newPixel . y ;
pixel . con = null ;
moved = true ;
break ;
}
}
2024-05-12 15:57:45 -04:00
else if ( ! pixel . con && elements [ newPixel . element ] . movable && ( pixel . charge || pixel . chargeCD ) && newPixel . element != "ray" ) { //suck up pixel
2023-12-03 16:16:13 -05:00
pixel . con = newPixel ;
deletePixel ( newPixel . x , newPixel . y ) ;
pixel . con . x = pixel . x ;
pixel . con . y = pixel . y ;
pixel . con . del ;
moved = true ;
break ;
}
}
}
if ( pixel . con && ! moved && ( pixel . charge || pixel . chargeCD ) ) { // move to same stage if none other
for ( var i = 0 ; i < squareCoordsShuffle . length ; i ++ ) {
var coord = squareCoordsShuffle [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
delete pixel . con . del ;
pixel . con . x = x ;
pixel . con . y = y ;
pixelMap [ x ] [ y ] = pixel . con ;
currentPixels . push ( pixel . con ) ;
pixel . con = null ;
break ;
}
2023-12-03 20:55:19 -05:00
if ( ! isEmpty ( x , y , true ) && ( pixelMap [ x ] [ y ] . element === "e_pipe" || pixelMap [ x ] [ y ] . element === "bridge_pipe" ) ) {
2023-12-03 16:16:13 -05:00
var newPixel = pixelMap [ x ] [ y ] ;
if ( pixel . con && ! newPixel . con && newPixel . stage === pixel . stage ) {
newPixel . con = pixel . con ;
newPixel . con . x = newPixel . x ;
newPixel . con . y = newPixel . y ;
pixel . con = null ;
break ;
}
}
}
}
}
doDefaults ( pixel ) ;
} ,
category : "machines" ,
movable : false ,
canContain : true ,
conduct : 1 ,
2024-03-09 12:37:36 -05:00
insulate : true ,
2023-12-03 16:16:13 -05:00
} ,
elements . destroyable _e _pipe = {
color : "#414c4f" ,
onSelect : function ( ) {
logMessage ( "Draw a pipe, wait for walls to appear, then erase the exit hole." ) ;
} ,
tick : function ( pixel ) {
if ( ! pixel . stage && pixelTicks - pixel . start > 60 ) {
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
createPixel ( "brick" , x , y ) ;
2025-02-21 16:54:38 -05:00
pixelMap [ x ] [ y ] . color = pixelColorPick ( pixel , "#586879" ) ;
2023-12-03 16:16:13 -05:00
}
}
pixel . stage = 1 ;
}
else if ( pixel . stage === 1 && pixelTicks - pixel . start > 70 ) { //uninitialized
for ( var i = 0 ; i < adjacentCoords . length ; i ++ ) {
var coord = adjacentCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
pixel . stage = 2 ; //blue
pixel . color = pixelColorPick ( pixel , "#000036" ) ;
break ;
}
}
}
else if ( pixel . stage > 1 && pixelTicks % 3 === pixel . stage - 2 ) { //initialized
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
2023-12-03 20:55:19 -05:00
if ( ! isEmpty ( x , y , true ) && ( pixelMap [ x ] [ y ] . element === "destroyable_e_pipe" || pixelMap [ x ] [ y ] . element === "bridge_pipe" ) ) {
2023-12-03 16:16:13 -05:00
var newPixel = pixelMap [ x ] [ y ] ;
if ( newPixel . stage === 1 ) {
var newColor ;
switch ( pixel . stage ) {
case 2 : newPixel . stage = 3 ; newColor = "#003600" ; break ; //green
case 3 : newPixel . stage = 4 ; newColor = "#360000" ; break ; //red
case 4 : newPixel . stage = 2 ; newColor = "#000036" ; break ; //blue
}
newPixel . color = pixelColorPick ( newPixel , newColor ) ;
}
}
}
var moved = false ;
shuffleArray ( squareCoordsShuffle ) ;
for ( var i = 0 ; i < squareCoordsShuffle . length ; i ++ ) {
var coord = squareCoordsShuffle [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
2024-12-28 22:39:50 -05:00
if ( newPixel . element === "destroyable_e_pipe" || newPixel . element === "bridge_pipe" || newPixel . element === "pipe_transmitter" ) {
2023-12-03 16:16:13 -05:00
var nextStage ;
switch ( pixel . stage ) {
case 2 : nextStage = 4 ; break ; //green
case 3 : nextStage = 2 ; break ; //red
case 4 : nextStage = 3 ; break ; //blue
}
2024-12-28 22:39:50 -05:00
if ( pixel . con && ! newPixel . con && ( newPixel . stage === nextStage || newPixel . element === "pipe_transmitter" ) && ( pixel . charge || pixel . chargeCD ) ) { //transfer to adjacent pipe
2023-12-03 16:16:13 -05:00
newPixel . con = pixel . con ;
newPixel . con . x = newPixel . x ;
newPixel . con . y = newPixel . y ;
pixel . con = null ;
moved = true ;
break ;
}
}
2024-05-12 15:57:45 -04:00
else if ( ! pixel . con && elements [ newPixel . element ] . movable && ( pixel . charge || pixel . chargeCD ) && newPixel . element != "ray" ) { //suck up pixel
2023-12-03 16:16:13 -05:00
pixel . con = newPixel ;
deletePixel ( newPixel . x , newPixel . y ) ;
pixel . con . x = pixel . x ;
pixel . con . y = pixel . y ;
pixel . con . del ;
moved = true ;
break ;
}
}
}
if ( pixel . con && ! moved && ( pixel . charge || pixel . chargeCD ) ) { // move to same stage if none other
for ( var i = 0 ; i < squareCoordsShuffle . length ; i ++ ) {
var coord = squareCoordsShuffle [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
delete pixel . con . del ;
pixel . con . x = x ;
pixel . con . y = y ;
pixelMap [ x ] [ y ] = pixel . con ;
currentPixels . push ( pixel . con ) ;
pixel . con = null ;
break ;
}
2023-12-03 20:55:19 -05:00
if ( ! isEmpty ( x , y , true ) && ( pixelMap [ x ] [ y ] . element === "destroyable_e_pipe" || pixelMap [ x ] [ y ] . element === "bridge_pipe" ) ) {
2023-12-03 16:16:13 -05:00
var newPixel = pixelMap [ x ] [ y ] ;
if ( pixel . con && ! newPixel . con && newPixel . stage === pixel . stage ) {
newPixel . con = pixel . con ;
newPixel . con . x = newPixel . x ;
newPixel . con . y = newPixel . y ;
pixel . con = null ;
break ;
}
}
}
}
}
doDefaults ( pixel ) ;
} ,
category : "machines" ,
movable : false ,
canContain : true ,
conduct : 1 ,
tempHigh : 1538 ,
stateHigh : "molten_iron" ,
breakInto : [ "metal_scrap" , "wire" ]
2023-12-03 20:55:19 -05:00
} ,
currentChannel = 0 ;
elements . channel _pipe = {
color : "#414c4f" ,
onSelect : function ( ) {
var answer3 = prompt ( "Please input the desired channel of this pipe strand. Warning: It wont work if you do multiple strand types while paused." , ( currentChannel || undefined ) ) ;
if ( ! answer3 ) { return }
currentChannel = answer3 ;
logMessage ( "Draw a pipe, wait for walls to appear, then erase the exit hole. Use the prop tool to set channel to a number before erasing the holes." ) ;
} ,
tick : function ( pixel ) {
if ( pixel . start === pixelTicks ) {
pixel . channel = currentChannel ;
}
if ( ! pixel . stage && pixelTicks - pixel . start > 60 ) {
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
2025-01-22 16:15:27 -05:00
createPixel ( "pipe_wall" , x , y ) ;
2025-02-21 16:54:38 -05:00
pixelMap [ x ] [ y ] . color = pixelColorPick ( pixel , "#586879" ) ;
2023-12-03 20:55:19 -05:00
}
}
pixel . stage = 1 ;
}
else if ( pixel . stage === 1 && pixelTicks - pixel . start > 70 ) { //uninitialized
for ( var i = 0 ; i < adjacentCoords . length ; i ++ ) {
var coord = adjacentCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
pixel . stage = 2 ; //blue
pixel . color = pixelColorPick ( pixel , "#000036" ) ;
break ;
}
}
}
else if ( pixel . stage > 1 && pixelTicks % 3 === pixel . stage - 2 ) { //initialized
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) && ( ( pixelMap [ x ] [ y ] . element === "channel_pipe" && pixelMap [ x ] [ y ] . channel == pixel . channel ) || pixelMap [ x ] [ y ] . element === "bridge_pipe" ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
if ( newPixel . stage === 1 ) {
var newColor ;
switch ( pixel . stage ) {
case 2 : newPixel . stage = 3 ; newColor = "#003600" ; break ; //green
case 3 : newPixel . stage = 4 ; newColor = "#360000" ; break ; //red
case 4 : newPixel . stage = 2 ; newColor = "#000036" ; break ; //blue
}
newPixel . color = pixelColorPick ( newPixel , newColor ) ;
}
}
}
var moved = false ;
shuffleArray ( squareCoordsShuffle ) ;
for ( var i = 0 ; i < squareCoordsShuffle . length ; i ++ ) {
var coord = squareCoordsShuffle [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
2024-12-28 22:39:50 -05:00
if ( ( newPixel . element === "channel_pipe" && pixelMap [ x ] [ y ] . channel == pixel . channel || newPixel . element === "bridge_pipe" || ( newPixel . element === "pipe_transmitter" && pixelMap [ x ] [ y ] . channel == pixel . channel ) ) ) {
2023-12-03 20:55:19 -05:00
var nextStage ;
switch ( pixel . stage ) {
case 2 : nextStage = 4 ; break ; //green
case 3 : nextStage = 2 ; break ; //red
case 4 : nextStage = 3 ; break ; //blue
}
2024-12-28 22:39:50 -05:00
if ( pixel . con && ! newPixel . con && ( newPixel . stage === nextStage || newPixel . element === "pipe_transmitter" ) ) { //transfer to adjacent pipe
2023-12-03 20:55:19 -05:00
newPixel . con = pixel . con ;
newPixel . con . x = newPixel . x ;
newPixel . con . y = newPixel . y ;
pixel . con = null ;
moved = true ;
break ;
}
}
2024-05-12 15:57:45 -04:00
else if ( ! pixel . con && elements [ newPixel . element ] . movable && newPixel . element != "ray" ) { //suck up pixel
2023-12-03 20:55:19 -05:00
pixel . con = newPixel ;
deletePixel ( newPixel . x , newPixel . y ) ;
pixel . con . x = pixel . x ;
pixel . con . y = pixel . y ;
pixel . con . del ;
moved = true ;
break ;
}
}
}
if ( pixel . con && ! moved ) { // move to same stage if none other
for ( var i = 0 ; i < squareCoordsShuffle . length ; i ++ ) {
var coord = squareCoordsShuffle [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
delete pixel . con . del ;
pixel . con . x = x ;
pixel . con . y = y ;
pixelMap [ x ] [ y ] = pixel . con ;
currentPixels . push ( pixel . con ) ;
pixel . con = null ;
break ;
}
if ( ! isEmpty ( x , y , true ) && ( ( pixelMap [ x ] [ y ] . element === "channel_pipe" && pixelMap [ x ] [ y ] . channel == pixel . channel ) || pixelMap [ x ] [ y ] . element === "bridge_pipe" ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
if ( pixel . con && ! newPixel . con && newPixel . stage === pixel . stage ) {
newPixel . con = pixel . con ;
newPixel . con . x = newPixel . x ;
newPixel . con . y = newPixel . y ;
pixel . con = null ;
break ;
}
}
}
}
}
doDefaults ( pixel ) ;
} ,
category : "machines" ,
movable : false ,
canContain : true ,
2024-03-09 12:37:36 -05:00
insulate : true ,
2023-12-03 20:55:19 -05:00
} ,
elements . destroyable _channel _pipe = {
color : "#414c4f" ,
onSelect : function ( ) {
var answer3 = prompt ( "Please input the desired channel of this pipe strand. Warning: It wont work if you do multiple strand types while paused." , ( currentChannel || undefined ) ) ;
if ( ! answer3 ) { return }
currentChannel = answer3 ;
logMessage ( "Draw a pipe, wait for walls to appear, then erase the exit hole. Use the prop tool to set channel to a number before erasing the holes." ) ;
} ,
tick : function ( pixel ) {
if ( pixel . start === pixelTicks ) {
pixel . channel = currentChannel ;
}
if ( ! pixel . stage && pixelTicks - pixel . start > 60 ) {
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
createPixel ( "brick" , x , y ) ;
2025-02-21 16:54:38 -05:00
pixelMap [ x ] [ y ] . color = pixelColorPick ( pixel , "#586879" ) ;
2023-12-03 20:55:19 -05:00
}
}
pixel . stage = 1 ;
}
else if ( pixel . stage === 1 && pixelTicks - pixel . start > 70 ) { //uninitialized
for ( var i = 0 ; i < adjacentCoords . length ; i ++ ) {
var coord = adjacentCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
pixel . stage = 2 ; //blue
pixel . color = pixelColorPick ( pixel , "#000036" ) ;
break ;
}
}
}
else if ( pixel . stage > 1 && pixelTicks % 3 === pixel . stage - 2 ) { //initialized
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) && ( pixelMap [ x ] [ y ] . element === "destroyable_channel_pipe" && pixelMap [ x ] [ y ] . channel == pixel . channel || pixelMap [ x ] [ y ] . element === "bridge_pipe" ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
if ( newPixel . stage === 1 ) {
var newColor ;
switch ( pixel . stage ) {
case 2 : newPixel . stage = 3 ; newColor = "#003600" ; break ; //green
case 3 : newPixel . stage = 4 ; newColor = "#360000" ; break ; //red
case 4 : newPixel . stage = 2 ; newColor = "#000036" ; break ; //blue
}
newPixel . color = pixelColorPick ( newPixel , newColor ) ;
}
}
}
var moved = false ;
shuffleArray ( squareCoordsShuffle ) ;
for ( var i = 0 ; i < squareCoordsShuffle . length ; i ++ ) {
var coord = squareCoordsShuffle [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
2024-12-28 22:39:50 -05:00
if ( ( newPixel . element === "destroyable_channel_pipe" && pixelMap [ x ] [ y ] . channel == pixel . channel ) || newPixel . element === "bridge_pipe" || ( newPixel . element === "pipe_transmitter" && pixelMap [ x ] [ y ] . channel == pixel . channel ) ) {
2023-12-03 20:55:19 -05:00
var nextStage ;
switch ( pixel . stage ) {
case 2 : nextStage = 4 ; break ; //green
case 3 : nextStage = 2 ; break ; //red
case 4 : nextStage = 3 ; break ; //blue
}
2024-12-28 22:39:50 -05:00
if ( pixel . con && ! newPixel . con && ( newPixel . stage === nextStage || newPixel . element === "pipe_transmitter" ) ) { //transfer to adjacent pipe
2023-12-03 20:55:19 -05:00
newPixel . con = pixel . con ;
newPixel . con . x = newPixel . x ;
newPixel . con . y = newPixel . y ;
pixel . con = null ;
moved = true ;
break ;
}
}
2024-05-12 15:57:45 -04:00
else if ( ! pixel . con && elements [ newPixel . element ] . movable && newPixel . element != "ray" ) { //suck up pixel
2023-12-03 20:55:19 -05:00
pixel . con = newPixel ;
deletePixel ( newPixel . x , newPixel . y ) ;
pixel . con . x = pixel . x ;
pixel . con . y = pixel . y ;
pixel . con . del ;
moved = true ;
break ;
}
}
}
if ( pixel . con && ! moved ) { // move to same stage if none other
for ( var i = 0 ; i < squareCoordsShuffle . length ; i ++ ) {
var coord = squareCoordsShuffle [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
delete pixel . con . del ;
pixel . con . x = x ;
pixel . con . y = y ;
pixelMap [ x ] [ y ] = pixel . con ;
currentPixels . push ( pixel . con ) ;
pixel . con = null ;
break ;
}
if ( ! isEmpty ( x , y , true ) && ( ( pixelMap [ x ] [ y ] . element === "destroyable_channel_pipe" && pixelMap [ x ] [ y ] . channel == pixel . channel ) || pixelMap [ x ] [ y ] . element === "bridge_pipe" ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
if ( pixel . con && ! newPixel . con && newPixel . stage === pixel . stage ) {
newPixel . con = pixel . con ;
newPixel . con . x = newPixel . x ;
newPixel . con . y = newPixel . y ;
pixel . con = null ;
break ;
}
}
}
}
}
doDefaults ( pixel ) ;
} ,
category : "machines" ,
movable : false ,
canContain : true ,
} ,
2024-12-28 22:39:50 -05:00
listPipes = [ "pipe" , "destroyable_pipe" , "destroyable_e_pipe" , "channel_pipe" , "destroyable_channel_pipe" , "bridge_pipe" , "e_pipe" , "pipe_transmitter" ] ;
2023-12-03 20:55:19 -05:00
elements . bridge _pipe = {
color : "#414c4f" ,
onSelect : function ( ) {
logMessage ( "Draw a pipe, wait for walls to appear, then erase the exit hole." ) ;
} ,
tick : function ( pixel ) {
if ( ! pixel . stage && pixelTicks - pixel . start > 60 ) {
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
2025-01-22 16:15:27 -05:00
createPixel ( "pipe_wall" , x , y ) ;
2025-02-21 16:54:38 -05:00
pixelMap [ x ] [ y ] . color = pixelColorPick ( pixel , "#586879" ) ;
2023-12-03 20:55:19 -05:00
}
}
pixel . stage = 1 ;
}
else if ( pixel . stage === 1 && pixelTicks - pixel . start > 70 ) { //uninitialized
for ( var i = 0 ; i < adjacentCoords . length ; i ++ ) {
var coord = adjacentCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
pixel . stage = 2 ; //blue
pixel . color = pixelColorPick ( pixel , "#000036" ) ;
break ;
}
}
}
else if ( pixel . stage > 1 && pixelTicks % 3 === pixel . stage - 2 ) { //initialized
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) && listPipes . includes ( pixelMap [ x ] [ y ] . element ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
if ( newPixel . stage === 1 ) {
var newColor ;
switch ( pixel . stage ) {
case 2 : newPixel . stage = 3 ; newColor = "#003600" ; break ; //green
case 3 : newPixel . stage = 4 ; newColor = "#360000" ; break ; //red
case 4 : newPixel . stage = 2 ; newColor = "#000036" ; break ; //blue
}
newPixel . color = pixelColorPick ( newPixel , newColor ) ;
}
}
}
var moved = false ;
shuffleArray ( squareCoordsShuffle ) ;
for ( var i = 0 ; i < squareCoordsShuffle . length ; i ++ ) {
var coord = squareCoordsShuffle [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
if ( listPipes . includes ( newPixel . element ) ) {
var nextStage ;
switch ( pixel . stage ) {
case 2 : nextStage = 4 ; break ; //green
case 3 : nextStage = 2 ; break ; //red
case 4 : nextStage = 3 ; break ; //blue
}
2024-12-28 22:39:50 -05:00
if ( pixel . con && ! newPixel . con && ( newPixel . stage === nextStage || newPixel . element === "pipe_transmitter" ) ) { //transfer to adjacent pipe
2023-12-03 20:55:19 -05:00
newPixel . con = pixel . con ;
newPixel . con . x = newPixel . x ;
newPixel . con . y = newPixel . y ;
pixel . con = null ;
moved = true ;
break ;
}
}
2024-05-12 15:57:45 -04:00
else if ( ! pixel . con && elements [ newPixel . element ] . movable && newPixel . element != "ray" ) { //suck up pixel
2023-12-03 20:55:19 -05:00
pixel . con = newPixel ;
deletePixel ( newPixel . x , newPixel . y ) ;
pixel . con . x = pixel . x ;
pixel . con . y = pixel . y ;
pixel . con . del ;
moved = true ;
break ;
}
}
}
if ( pixel . con && ! moved ) { // move to same stage if none other
for ( var i = 0 ; i < squareCoordsShuffle . length ; i ++ ) {
var coord = squareCoordsShuffle [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
delete pixel . con . del ;
pixel . con . x = x ;
pixel . con . y = y ;
pixelMap [ x ] [ y ] = pixel . con ;
currentPixels . push ( pixel . con ) ;
pixel . con = null ;
break ;
}
if ( ! isEmpty ( x , y , true ) && listPipes . includes ( pixelMap [ x ] [ y ] . element ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
if ( pixel . con && ! newPixel . con && newPixel . stage === pixel . stage ) {
newPixel . con = pixel . con ;
newPixel . con . x = newPixel . x ;
newPixel . con . y = newPixel . y ;
pixel . con = null ;
break ;
}
}
}
}
}
doDefaults ( pixel ) ;
} ,
category : "machines" ,
movable : false ,
canContain : true ,
2024-03-09 12:37:36 -05:00
insulate : true ,
2023-12-03 20:55:19 -05:00
} ,
2025-02-21 16:54:38 -05:00
elements . pipe . tick = function ( pixel ) {
2023-12-03 20:55:19 -05:00
if ( ! pixel . stage && pixelTicks - pixel . start > 60 ) {
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
2025-02-21 16:56:00 -05:00
if ( ! isEmpty ( x , y , true ) && elements [ pixelMap [ x ] [ y ] . element ] . movable && newPixel . element != "ray" ) {
2025-02-21 16:54:38 -05:00
deletePixel ( x , y )
}
2023-12-03 20:55:19 -05:00
if ( isEmpty ( x , y ) ) {
2024-01-09 18:50:54 -05:00
createPixel ( "pipe_wall" , x , y ) ;
2023-12-03 20:55:19 -05:00
}
}
pixel . stage = 1 ;
}
else if ( pixel . stage === 1 && pixelTicks - pixel . start > 70 ) { //uninitialized
for ( var i = 0 ; i < adjacentCoords . length ; i ++ ) {
var coord = adjacentCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
pixel . stage = 2 ; //blue
pixel . color = pixelColorPick ( pixel , "#000036" ) ;
break ;
}
}
}
else if ( pixel . stage > 1 && pixelTicks % 3 === pixel . stage - 2 ) { //initialized
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) && ( pixelMap [ x ] [ y ] . element === "pipe" || pixelMap [ x ] [ y ] . element === "bridge_pipe" ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
if ( newPixel . stage === 1 ) {
var newColor ;
switch ( pixel . stage ) {
case 2 : newPixel . stage = 3 ; newColor = "#003600" ; break ; //green
case 3 : newPixel . stage = 4 ; newColor = "#360000" ; break ; //red
case 4 : newPixel . stage = 2 ; newColor = "#000036" ; break ; //blue
}
newPixel . color = pixelColorPick ( newPixel , newColor ) ;
}
}
}
var moved = false ;
shuffleArray ( squareCoordsShuffle ) ;
for ( var i = 0 ; i < squareCoordsShuffle . length ; i ++ ) {
var coord = squareCoordsShuffle [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
2024-12-28 22:39:50 -05:00
if ( newPixel . element === "pipe" || newPixel . element === "bridge_pipe" || newPixel . element === "pipe_transmitter" ) {
2023-12-03 20:55:19 -05:00
var nextStage ;
switch ( pixel . stage ) {
case 2 : nextStage = 4 ; break ; //green
case 3 : nextStage = 2 ; break ; //red
case 4 : nextStage = 3 ; break ; //blue
}
2024-12-28 22:39:50 -05:00
if ( pixel . con && ! newPixel . con && ( newPixel . stage === nextStage || newPixel . element === "pipe_transmitter" ) ) { //transfer to adjacent pipe
2023-12-03 20:55:19 -05:00
newPixel . con = pixel . con ;
newPixel . con . x = newPixel . x ;
newPixel . con . y = newPixel . y ;
pixel . con = null ;
moved = true ;
break ;
}
}
2025-02-21 16:56:00 -05:00
else if ( ! pixel . con && elements [ newPixel . element ] . movable && newPixel . element != "ray" ) { //suck up pixel
2023-12-03 20:55:19 -05:00
pixel . con = newPixel ;
deletePixel ( newPixel . x , newPixel . y ) ;
pixel . con . x = pixel . x ;
pixel . con . y = pixel . y ;
pixel . con . del ;
moved = true ;
break ;
}
}
}
if ( pixel . con && ! moved ) { // move to same stage if none other
for ( var i = 0 ; i < squareCoordsShuffle . length ; i ++ ) {
var coord = squareCoordsShuffle [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
delete pixel . con . del ;
pixel . con . x = x ;
pixel . con . y = y ;
pixelMap [ x ] [ y ] = pixel . con ;
currentPixels . push ( pixel . con ) ;
pixel . con = null ;
break ;
}
if ( ! isEmpty ( x , y , true ) && ( pixelMap [ x ] [ y ] . element === "pipe" || pixelMap [ x ] [ y ] . element === "bridge_pipe" ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
if ( pixel . con && ! newPixel . con && newPixel . stage === pixel . stage ) {
newPixel . con = pixel . con ;
newPixel . con . x = newPixel . x ;
newPixel . con . y = newPixel . y ;
pixel . con = null ;
break ;
}
}
}
}
}
doDefaults ( pixel ) ;
2025-02-21 16:54:38 -05:00
}
2024-03-09 12:37:36 -05:00
elements . pipe . insulate = true ,
2023-12-04 20:46:59 -05:00
filterTypeVar = 0 ;
elements . filter = {
color : "#599fc2" ,
onSelect : function ( ) {
var answer4 = prompt ( "Please input the desired element of this filter. It will not work if you do multiple filter types while paused." , ( filterTypeVar || undefined ) ) ;
if ( ! answer4 ) { return }
filterTypeVar = answer4 ;
} ,
tick : function ( pixel ) {
if ( pixel . start === pixelTicks ) {
pixel . filterType = filterTypeVar
}
if ( 1 === 2 ) {
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
// createPixel("brick",x,y);
// pixelMap[x][y].color = pixelColorPick(pixel,"#808080");
}
}
// pixel.stage = 1;
}
else if ( 1 === 2 ) { //uninitialized
for ( var i = 0 ; i < adjacentCoords . length ; i ++ ) {
var coord = adjacentCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
// pixel.stage = 2; //blue
// pixel.color = pixelColorPick(pixel,"#000036");
break ;
}
}
}
else if ( 1 === 1 ) { //initialized
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) && listPipes . includes ( pixelMap [ x ] [ y ] . element ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
if ( newPixel . stage === 1 ) {
var newColor ;
switch ( pixel . stage ) {
// case 2: newPixel.stage = 3; newColor = "#003600"; break; //green
// case 3: newPixel.stage = 4; newColor = "#360000"; break; //red
// case 4: newPixel.stage = 2; newColor = "#000036"; break; //blue
}
// newPixel.color = pixelColorPick(newPixel,newColor);
}
}
}
var moved = false ;
shuffleArray ( squareCoordsShuffle ) ;
for ( var i = 0 ; i < squareCoordsShuffle . length ; i ++ ) {
var coord = squareCoordsShuffle [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
if ( listPipes . includes ( newPixel . element ) ) {
var nextStage ;
switch ( pixel . stage ) {
// case 2: nextStage = 4; break; //green
// case 3: nextStage = 2; break; //red
// case 4: nextStage = 3; break; //blue
}
if ( pixel . con && ! newPixel . con ) { //transfer to adjacent pipe
newPixel . con = pixel . con ;
newPixel . con . x = newPixel . x ;
newPixel . con . y = newPixel . y ;
pixel . con = null ;
moved = true ;
break ;
}
}
2024-03-03 16:54:43 -05:00
else if ( ! pixel . con && ( newPixel . element == pixel . filterType ) ) { //suck up pixel
2023-12-04 20:46:59 -05:00
pixel . con = newPixel ;
deletePixel ( newPixel . x , newPixel . y ) ;
pixel . con . x = pixel . x ;
pixel . con . y = pixel . y ;
pixel . con . del ;
moved = true ;
break ;
}
}
}
if ( pixel . con && ! moved ) { // move to same stage if none other
for ( var i = 0 ; i < squareCoordsShuffle . length ; i ++ ) {
var coord = squareCoordsShuffle [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
delete pixel . con . del ;
pixel . con . x = x ;
pixel . con . y = y ;
pixelMap [ x ] [ y ] = pixel . con ;
currentPixels . push ( pixel . con ) ;
pixel . con = null ;
break ;
}
if ( ! isEmpty ( x , y , true ) && listPipes . includes ( pixelMap [ x ] [ y ] . element ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
if ( pixel . con && ! newPixel . con ) {
newPixel . con = pixel . con ;
newPixel . con . x = newPixel . x ;
newPixel . con . y = newPixel . y ;
pixel . con = null ;
break ;
}
}
}
}
}
doDefaults ( pixel ) ;
} ,
category : "machines" ,
movable : false ,
canContain : true ,
2023-12-05 17:50:14 -05:00
noMix : true ,
2024-03-09 12:37:36 -05:00
insulate : true ,
2023-12-05 17:50:14 -05:00
} ,
elements . heat _test = {
2023-12-15 17:02:48 -05:00
onSelect : function ( ) {
logMessage ( "Use heatglow.js for more elements to glow when they are hot." ) ;
} ,
2023-12-05 17:50:14 -05:00
color : "#787878" ,
behavior : behaviors . WALL ,
category : "solids" ,
state : "solid" ,
tempHigh : 1538 ,
stateHigh : "molten_iron" ,
2023-12-16 20:49:28 -05:00
movable : false ,
2023-12-05 17:50:14 -05:00
tick : function ( pixel ) {
if ( pixel . start == pixelTicks ) {
pixel . ogR = parseInt ( pixel . color . slice ( 4 , pixel . color . indexOf ( ',' ) ) , 10 )
pixel . ogG = parseInt ( pixel . color . slice ( pixel . color . indexOf ( ',' ) + 1 , pixel . color . lastIndexOf ( ',' ) ) , 10 )
pixel . ogB = parseInt ( pixel . color . slice ( pixel . color . lastIndexOf ( ',' ) + 1 , - 1 ) , 10 )
} else if ( pixelTicks > pixel . start ) {
if ( pixel . temp <= ( elements . heat _test . tempHigh ) - 700 ) { // replace 700 with lower limit of range
pixel . ctemp = 0 ;
} else if ( pixel . temp > ( elements . heat _test . tempHigh ) - 700 && pixel . temp <= elements . heat _test . tempHigh ) { // replace 700 with lower limit of range
pixel . ctemp = ( ( 1 / 700 ) * pixel . temp ) - ( ( ( elements . heat _test . tempHigh ) - 700 ) / 700 ) // replace 700 with lower limit of range
}
if ( pixel . ctemp <= 0.5 ) {
pixel . newR = ( ( ( 510 - ( 2 * pixel . ogR ) ) * pixel . ctemp ) + pixel . ogR ) ;
pixel . newG = ( ( 0 - ( ( 2 * pixel . ogG ) * pixel . ctemp ) ) + pixel . ogG ) ;
2023-12-14 14:24:02 -05:00
pixel . newB = ( ( 0 - ( ( 2 * pixel . ogB ) * pixel . ctemp ) ) + pixel . ogB ) ;
2023-12-05 17:50:14 -05:00
} else if ( pixel . ctemp > 0.5 ) {
pixel . newR = 255 ;
pixel . newG = ( ( 510 * pixel . ctemp ) - 256 ) ;
pixel . newB = ( ( 280 * pixel . ctemp ) - 140 ) ;
}
pixel . color = "rgb(" + pixel . newR + "," + pixel . newG + "," + pixel . newB + ")" ;
}
} ,
2023-12-06 21:14:53 -05:00
} ,
2024-06-21 14:38:01 -04:00
/ *
2023-12-06 21:14:53 -05:00
elements . soup = {
color : "#3d2812" ,
behavior : behaviors . LIQUID ,
category : "food" ,
onMix : function ( soup , ingredient ) {
if ( elements [ ingredient . element ] . isFood && elements [ ingredient . element ] . id !== elements . soup . id && elements [ ingredient . element ] . id !== elements . broth . id ) {
var rgb1 = soup . color . match ( /\d+/g ) ;
var rgb2 = ingredient . color . match ( /\d+/g ) ;
// average the colors
var rgb = [
Math . round ( ( parseInt ( rgb1 [ 0 ] ) + parseInt ( rgb2 [ 0 ] ) ) / 2 ) ,
Math . round ( ( parseInt ( rgb1 [ 1 ] ) + parseInt ( rgb2 [ 1 ] ) ) / 2 ) ,
Math . round ( ( parseInt ( rgb1 [ 2 ] ) + parseInt ( rgb2 [ 2 ] ) ) / 2 )
] ;
2023-12-14 14:20:47 -05:00
if ( ! soup . elemlist ) {
soup . elemlist = [ ] ;
}
soup . decidedHigh = soup . elemlist [ Math . floor ( Math . random ( ) * soup . elemlist . length ) ] ;
soup . elemlist . push ( ingredient . element )
soup . stateHigh = soup . elemlist ;
changePixel ( ingredient , "soup" ) ;
2023-12-06 21:14:53 -05:00
// convert rgb to hex
var hex = RGBToHex ( rgb ) ;
soup . color = pixelColorPick ( soup , hex ) ;
// 50% change to delete ingredient
if ( Math . random ( ) < 0.5 ) { deletePixel ( ingredient . x , ingredient . y ) ; }
else {
ingredient . color = pixelColorPick ( ingredient , hex ) ;
}
}
} ,
2023-12-14 14:20:47 -05:00
tick : function ( pixel ) {
if ( ! pixel . decidedHigh ) {
pixel . decidedHigh = "steam" ;
}
if ( pixel . temp > 100 ) {
if ( Math . random ( ) < 0.5 ) {
changePixel ( pixel , "steam" ) ;
} else {
changePixel ( pixel , pixel . decidedHigh )
}
}
} ,
2023-12-06 21:14:53 -05:00
density : 1100 ,
stain : 0.02 ,
state : "liquid" ,
} ,
elements . broth . onMix = function ( pixel ) {
changePixel ( pixel , "soup" )
2023-12-21 17:06:43 -05:00
} ,
2024-06-21 14:38:01 -04:00
* /
2023-12-21 17:06:43 -05:00
converter1Var = 0 ;
converter2Var = 0 ;
elements . converter = {
color : "#296127" ,
behavior : behaviors . WALL ,
category : "machines" ,
tick : function ( pixel ) {
if ( pixel . start === pixelTicks ) {
pixel . contype = converter2Var ;
pixel . specialturn = converter1Var ;
}
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
2024-01-02 18:51:27 -05:00
if ( ! isEmpty ( x , y , true ) ) {
2023-12-21 17:06:43 -05:00
var otherPixel = pixelMap [ x ] [ y ] ;
if ( ( otherPixel . element == pixel . specialturn || pixel . specialturn == "all" ) && ! elements . converter . ignore . includes ( otherPixel . element ) ) {
changePixel ( otherPixel , pixel . contype )
}
}
}
} ,
onSelect : function ( ) {
var answer5 = prompt ( "Please input what type of element should be converted. Write \"all\" to include everything." , ( converter1Var || undefined ) ) ;
if ( ! answer5 ) { return }
converter1Var = answer5 ;
var answer6 = prompt ( "Please input what it should turn into." , ( converter2Var || undefined ) ) ;
if ( ! answer6 ) { return }
converter2Var = answer6 ;
} ,
ignore : [ "converter" , "wall" , "ewall" , "border" ] ,
2023-12-21 23:04:08 -05:00
movable : false ,
2023-12-23 13:59:17 -05:00
} ,
elements . blackhole _storage = {
color : "#171717" ,
behavior : behaviors . WALL ,
category : "machines" ,
tick : function ( pixel ) {
if ( ! pixel . bhcontents ) {
pixel . bhcontents = [ ] ;
}
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
2024-01-02 18:51:27 -05:00
if ( ! isEmpty ( x , y , true ) && ( ! pixel . charge && ! pixel . chargeCD ) ) {
2023-12-23 13:59:17 -05:00
var otherPixel = pixelMap [ x ] [ y ] ;
if ( elements [ otherPixel . element ] . movable == true ) {
pixel . bhcontents . push ( otherPixel ) ;
deletePixel ( otherPixel . x , otherPixel . y ) ;
}
2025-02-16 18:15:40 -05:00
} else if ( pixel . charge && isEmpty ( x , y ) && pixel . bhcontents . length ) {
let randomindex = Math . floor ( Math . random ( ) * pixel . bhcontents . length ) ;
let releasedPixel = pixel . bhcontents [ randomindex ]
pixel . bhcontents . splice ( randomindex , 1 )
delete releasedPixel . del
releasedPixel . x = x
releasedPixel . y = y
pixelMap [ x ] [ y ] = releasedPixel
currentPixels . push ( releasedPixel )
2023-12-23 13:59:17 -05:00
}
}
} ,
movable : false ,
conduct : 1 ,
2023-12-25 16:51:40 -05:00
} ,
elements . plutonium = {
2024-04-06 17:32:27 -04:00
color : [ "#212121" , "#2b1c1c" , "#371616" , "#430e0e" , "#510606" , "#212121" , "#1e1e1e" , "#1b1b1b" , "#171717" , "#141414" , "#212121" , "#1e1e1e" , "#1b1b1b" , "#171717" , "#141414" ] ,
2023-12-25 16:51:40 -05:00
behavior : behaviors . STURDYPOWDER ,
category : "powders" ,
tempHigh : 640 ,
stateHigh : "molten_plutonium" ,
state : "solid" ,
tick : function ( pixel ) {
2024-04-06 17:32:27 -04:00
if ( Math . random ( ) < 0.0007 ) {
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
createPixel ( "helium" , x , y )
pixelMap [ x ] [ y ] . temp = pixel . temp + 200
break ;
}
}
if ( Math . random ( ) < 0.5 ) {
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
createPixel ( "neutron" , x , y )
pixelMap [ x ] [ y ] . temp = pixel . temp + 200
break ;
}
}
}
changePixel ( pixel , "uranium" , false ) ;
pixelMap [ x ] [ y ] . temp += 200
for ( var i = 0 ; i < adjacentCoords . length ; i ++ ) {
var coord = adjacentCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
pixelMap [ x ] [ y ] . temp += 175
}
}
}
2024-04-09 18:34:17 -04:00
behaviors . RADSOLID
2024-04-06 17:32:27 -04:00
} ,
2023-12-25 16:51:40 -05:00
reactions : {
"neutron" : { elem1 : "pn_explosion" , tempMin : 400 , chance : 0.1 } ,
} ,
density : 19186 ,
}
elements . molten _plutonium = {
color : [ "#6b5133" , "#743f26" , "#7c2727" ] ,
2024-04-09 18:34:17 -04:00
behavior : behaviors . RADMOLTEN ,
2023-12-25 16:51:40 -05:00
category : "states" ,
state : "liquid" ,
tempLow : 620 ,
2024-06-19 20:55:15 -04:00
hidden : true ,
2023-12-25 16:51:40 -05:00
stateLow : "plutonium" ,
tick : function ( pixel ) {
2024-04-06 17:32:27 -04:00
if ( Math . random ( ) < 0.0007 ) {
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
createPixel ( "helium" , x , y )
pixelMap [ x ] [ y ] . temp = pixel . temp + 200
break ;
}
}
if ( Math . random ( ) < 0.5 ) {
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
createPixel ( "neutron" , x , y )
pixelMap [ x ] [ y ] . temp = pixel . temp + 200
break ;
}
}
}
changePixel ( pixel , "uranium" , false ) ;
pixelMap [ x ] [ y ] . temp += 200
for ( var i = 0 ; i < adjacentCoords . length ; i ++ ) {
var coord = adjacentCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
pixelMap [ x ] [ y ] . temp += 175
}
}
}
} ,
2023-12-25 16:51:40 -05:00
reactions : {
"neutron" : { elem1 : "pn_explosion" , tempMin : 400 , chance : 0.1 } ,
} ,
density : 16629 ,
2023-12-26 14:45:35 -05:00
} ,
2024-04-06 17:32:27 -04:00
elements . neutron . reactions . plutonium = { temp2 : 200 } ;
elements . neutron . reactions . molten _plutonium = { temp2 : 200 }
2023-12-25 16:51:40 -05:00
elements . pn _explosion = {
color : [ "#ffb48f" , "#ffd991" , "#ffad91" ] ,
behavior : [
"XX|XX|XX" ,
"XX|EX:80>plasma,plasma,plasma,plasma,radiation,rad_steam,neutron|XX" ,
"XX|XX|XX" ,
] ,
temp : 100000000 ,
category : "energy" ,
state : "gas" ,
density : 1000 ,
excludeRandom : true ,
hidden : true ,
alias : "plutonium nuclear explosion" ,
noMix : true
2023-12-27 11:40:47 -05:00
} ,
elements . smasher = {
color : "#606060" ,
behavior : behaviors . WALL ,
2024-05-15 16:16:44 -04:00
category : "deprecated" ,
2023-12-27 11:40:47 -05:00
tick : function ( pixel ) {
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
2024-01-02 18:51:27 -05:00
if ( ! isEmpty ( x , y , true ) ) {
2023-12-27 11:40:47 -05:00
var otherPixel = pixelMap [ x ] [ y ] ;
breakPixel ( otherPixel ) ;
}
}
} ,
2023-12-28 13:09:05 -05:00
movable : false ,
2024-05-15 16:16:44 -04:00
hidden : true
2023-12-27 11:40:47 -05:00
} ,
2024-05-15 16:17:50 -04:00
/ *
elements . mixer = {
2023-12-27 11:40:47 -05:00
color : "#F0F0F0" ,
behavior : behaviors . WALL ,
2024-05-15 16:16:44 -04:00
category : "deprecated" ,
2023-12-27 11:40:47 -05:00
tick : function ( pixel ) {
pixel . mixList = [ ] ;
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
2024-01-02 18:35:31 -05:00
if ( ! isEmpty ( x , y , true ) && ! elements [ pixelMap [ x ] [ y ] . element ] . noMix ) {
2023-12-27 11:40:47 -05:00
var otherPixel = pixelMap [ x ] [ y ] ;
pixel . mixList . push ( otherPixel ) ;
}
}
for ( var i = 0 ; i < pixel . mixList . length ; i ++ ) {
var pixel1 = pixel . mixList [ Math . floor ( Math . random ( ) * pixel . mixList . length ) ] ;
var pixel2 = pixel . mixList [ Math . floor ( Math . random ( ) * pixel . mixList . length ) ] ;
swapPixels ( pixel1 , pixel2 ) ;
pixel . mixList . splice ( pixel . mixList . indexOf ( pixel1 ) , 1 ) ;
pixel . mixList . splice ( pixel . mixList . indexOf ( pixel2 ) , 1 ) ;
if ( elements [ pixel1 . element ] . onMix ) {
elements [ pixel1 . element ] . onMix ( pixel1 , pixel2 ) ;
}
if ( elements [ pixel2 . element ] . onMix ) {
elements [ pixel2 . element ] . onMix ( pixel2 , pixel1 ) ;
}
}
2023-12-28 13:09:05 -05:00
} ,
movable : false ,
2024-02-17 11:10:24 -05:00
noMix : true ,
2024-05-15 16:16:44 -04:00
hidden : true ,
2023-12-31 14:23:57 -05:00
} ,
2024-05-15 16:17:50 -04:00
* /
2023-12-31 14:23:57 -05:00
elements . invisiblesupport = {
color : "#000000" ,
behavior : behaviors . WALL ,
tick : function ( pixel ) {
var x = pixel . x
var y = pixel . y
if ( currentElement == "invisiblesupport" ) {
pixel . color = "rgb(15, 15, 15)" ;
} else {
pixel . color = "rgba(0, 0, 0, -1)" ;
}
if ( ( isEmpty ( x - 1 , y ) || isEmpty ( x + 1 , y ) ) && isEmpty ( x , y + 1 ) ) {
deletePixel ( pixel . x , pixel . y ) ;
}
} ,
category : "powders" ,
2024-01-02 13:09:35 -05:00
} ,
elements . invisiblewall = {
color : "#000000" ,
behavior : behaviors . WALL ,
tick : function ( pixel ) {
if ( currentElement == "invisiblewall" ) {
pixel . color = "rgb(15, 15, 15)" ;
} else {
pixel . color = "rgba(0, 0, 0, -1)" ;
}
} ,
category : "solids" ,
2024-01-24 12:51:15 -05:00
movable : false ,
noMix : true ,
2024-04-26 18:22:38 -04:00
hardness : 1 ,
2024-01-03 14:25:31 -05:00
} ,
elements . bismuth = {
color : [ "#818181" , "#989898" , "#b0b0b0" , "#c9c9c9" ] ,
behavior : behaviors . WALL ,
category : "solids" ,
tempHigh : 271.4 ,
stateHigh : "molten_bismuth" ,
density : 9780 ,
state : "solid"
}
function RGBtoHSV ( r , g , b ) {
if ( arguments . length === 1 ) {
g = r . g , b = r . b , r = r . r ;
}
var max = Math . max ( r , g , b ) , min = Math . min ( r , g , b ) ,
d = max - min ,
h ,
s = ( max === 0 ? 0 : d / max ) ,
v = max / 255 ;
switch ( max ) {
case min : h = 0 ; break ;
case r : h = ( g - b ) + d * ( g < b ? 6 : 0 ) ; h /= 6 * d ; break ;
case g : h = ( b - r ) + d * 2 ; h /= 6 * d ; break ;
case b : h = ( r - g ) + d * 4 ; h /= 6 * d ; break ;
}
return {
h : h ,
s : s ,
v : v
} ;
}
function HSVtoRGB ( h , s , v ) {
var r , g , b , i , f , p , q , t ;
if ( arguments . length === 1 ) {
s = h . s , v = h . v , h = h . h ;
}
i = Math . floor ( h * 6 ) ;
f = h * 6 - i ;
p = v * ( 1 - s ) ;
q = v * ( 1 - f * s ) ;
t = v * ( 1 - ( 1 - f ) * s ) ;
switch ( i % 6 ) {
case 0 : r = v , g = t , b = p ; break ;
case 1 : r = q , g = v , b = p ; break ;
case 2 : r = p , g = v , b = t ; break ;
case 3 : r = p , g = q , b = v ; break ;
case 4 : r = t , g = p , b = v ; break ;
case 5 : r = v , g = p , b = q ; break ;
}
return {
r : Math . round ( r * 255 ) ,
g : Math . round ( g * 255 ) ,
b : Math . round ( b * 255 )
} ;
}
elements . molten _bismuth = {
color : [ "#ee8d63" , "#ef7e5e" , "#f06e5c" , "#f05c5c" ] ,
behavior : behaviors . MOLTEN ,
2024-06-19 20:55:15 -04:00
hidden : true ,
2024-01-03 14:25:31 -05:00
category : "states" ,
state : "liquid" ,
2024-01-05 23:16:10 -05:00
temp : 280 ,
2024-01-03 14:25:31 -05:00
tick : function ( pixel ) {
if ( pixel . temp <= 261.4 ) {
pixel . tHue = 0 ;
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
if ( pixelMap [ x ] [ y ] . element == "bismuth" ) {
var otherPixel = pixelMap [ x ] [ y ]
var nR = parseInt ( otherPixel . color . slice ( 4 , otherPixel . color . indexOf ( ',' ) ) , 10 )
var nG = parseInt ( otherPixel . color . slice ( otherPixel . color . indexOf ( ',' ) + 1 , otherPixel . color . lastIndexOf ( ',' ) ) , 10 )
var nB = parseInt ( otherPixel . color . slice ( otherPixel . color . lastIndexOf ( ',' ) + 1 , - 1 ) , 10 )
var hsvResult = RGBtoHSV ( nR , nG , nB )
if ( ( pixel . tHue + 1 ) % 1 < hsvResult . h ) {
pixel . tHue = hsvResult . h ;
}
}
}
}
changePixel ( pixel , "bismuth" )
2024-04-15 20:57:40 -04:00
var rgbResult = HSVtoRGB ( pixel . tHue + 0.02 , 0.5 , 0.9 ) ;
2024-01-03 14:25:31 -05:00
const hexR = rgbResult . r . toString ( 16 ) . padStart ( 2 , '0' ) ;
const hexG = rgbResult . g . toString ( 16 ) . padStart ( 2 , '0' ) ;
const hexB = rgbResult . b . toString ( 16 ) . padStart ( 2 , '0' ) ;
const hexCode = ` # ${ hexR } ${ hexG } ${ hexB } ` ;
pixel . color = pixelColorPick ( pixel , hexCode )
}
} ,
density : 10049 ,
2023-12-14 14:20:47 -05:00
}
2024-01-07 12:40:20 -05:00
const powderList = [ behaviors . POWDER , behaviors . STURDYPOWDER , behaviors . POWDER _OLD , behaviors . AGPOWDER , behaviors . LIGHTWEIGHT , behaviors . SUPPORT , behaviors . SUPPORTPOWDER , behaviors . RADPOWDER ]
const liquidList = [ behaviors . LIQUID , behaviors . LIQUID _OLD , behaviors . SUPERFLUID _OLD , behaviors . SUPERFLUID , behaviors . AGLIQUID , behaviors . FOAM , behaviors . BUBBLE , behaviors . MOLTEN , behaviors . RADMOLTEN , behaviors . RADLIQUID ]
const gasList = [ behaviors . UL _UR , behaviors . UL _UR _OPTIMIZED , behaviors . GAS _OLD , behaviors . GAS , behaviors . DGAS ]
elements . powder _filter = {
color : "#599fc2" ,
tick : function ( pixel ) {
if ( 1 === 2 ) {
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
// createPixel("brick",x,y);
// pixelMap[x][y].color = pixelColorPick(pixel,"#808080");
}
}
// pixel.stage = 1;
}
else if ( 1 === 2 ) { //uninitialized
for ( var i = 0 ; i < adjacentCoords . length ; i ++ ) {
var coord = adjacentCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
// pixel.stage = 2; //blue
// pixel.color = pixelColorPick(pixel,"#000036");
break ;
}
}
}
else if ( 1 === 1 ) { //initialized
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) && listPipes . includes ( pixelMap [ x ] [ y ] . element ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
if ( newPixel . stage === 1 ) {
var newColor ;
switch ( pixel . stage ) {
// case 2: newPixel.stage = 3; newColor = "#003600"; break; //green
// case 3: newPixel.stage = 4; newColor = "#360000"; break; //red
// case 4: newPixel.stage = 2; newColor = "#000036"; break; //blue
}
// newPixel.color = pixelColorPick(newPixel,newColor);
}
}
}
var moved = false ;
shuffleArray ( squareCoordsShuffle ) ;
for ( var i = 0 ; i < squareCoordsShuffle . length ; i ++ ) {
var coord = squareCoordsShuffle [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
if ( listPipes . includes ( newPixel . element ) ) {
var nextStage ;
switch ( pixel . stage ) {
// case 2: nextStage = 4; break; //green
// case 3: nextStage = 2; break; //red
// case 4: nextStage = 3; break; //blue
}
if ( pixel . con && ! newPixel . con ) { //transfer to adjacent pipe
newPixel . con = pixel . con ;
newPixel . con . x = newPixel . x ;
newPixel . con . y = newPixel . y ;
pixel . con = null ;
moved = true ;
break ;
}
}
else if ( ! pixel . con && elements [ newPixel . element ] . movable && ( elements [ newPixel . element ] . state == "solid" ) ) { //suck up pixel
pixel . con = newPixel ;
deletePixel ( newPixel . x , newPixel . y ) ;
pixel . con . x = pixel . x ;
pixel . con . y = pixel . y ;
pixel . con . del ;
moved = true ;
break ;
}
}
}
if ( pixel . con && ! moved ) { // move to same stage if none other
for ( var i = 0 ; i < squareCoordsShuffle . length ; i ++ ) {
var coord = squareCoordsShuffle [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
delete pixel . con . del ;
pixel . con . x = x ;
pixel . con . y = y ;
pixelMap [ x ] [ y ] = pixel . con ;
currentPixels . push ( pixel . con ) ;
pixel . con = null ;
break ;
}
if ( ! isEmpty ( x , y , true ) && listPipes . includes ( pixelMap [ x ] [ y ] . element ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
if ( pixel . con && ! newPixel . con ) {
newPixel . con = pixel . con ;
newPixel . con . x = newPixel . x ;
newPixel . con . y = newPixel . y ;
pixel . con = null ;
break ;
}
}
}
}
}
doDefaults ( pixel ) ;
} ,
category : "machines" ,
movable : false ,
canContain : true ,
noMix : true ,
2024-03-09 12:37:36 -05:00
insulate : true ,
2024-01-07 12:40:20 -05:00
}
elements . liquid _filter = {
color : "#599fc2" ,
tick : function ( pixel ) {
if ( 1 === 2 ) {
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
// createPixel("brick",x,y);
// pixelMap[x][y].color = pixelColorPick(pixel,"#808080");
}
}
// pixel.stage = 1;
}
else if ( 1 === 2 ) { //uninitialized
for ( var i = 0 ; i < adjacentCoords . length ; i ++ ) {
var coord = adjacentCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
// pixel.stage = 2; //blue
// pixel.color = pixelColorPick(pixel,"#000036");
break ;
}
}
}
else if ( 1 === 1 ) { //initialized
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) && listPipes . includes ( pixelMap [ x ] [ y ] . element ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
if ( newPixel . stage === 1 ) {
var newColor ;
switch ( pixel . stage ) {
// case 2: newPixel.stage = 3; newColor = "#003600"; break; //green
// case 3: newPixel.stage = 4; newColor = "#360000"; break; //red
// case 4: newPixel.stage = 2; newColor = "#000036"; break; //blue
}
// newPixel.color = pixelColorPick(newPixel,newColor);
}
}
}
var moved = false ;
shuffleArray ( squareCoordsShuffle ) ;
for ( var i = 0 ; i < squareCoordsShuffle . length ; i ++ ) {
var coord = squareCoordsShuffle [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
if ( listPipes . includes ( newPixel . element ) ) {
var nextStage ;
switch ( pixel . stage ) {
// case 2: nextStage = 4; break; //green
// case 3: nextStage = 2; break; //red
// case 4: nextStage = 3; break; //blue
}
if ( pixel . con && ! newPixel . con ) { //transfer to adjacent pipe
newPixel . con = pixel . con ;
newPixel . con . x = newPixel . x ;
newPixel . con . y = newPixel . y ;
pixel . con = null ;
moved = true ;
break ;
}
}
else if ( ! pixel . con && elements [ newPixel . element ] . movable && ( elements [ newPixel . element ] . state == "liquid" ) ) { //suck up pixel
pixel . con = newPixel ;
deletePixel ( newPixel . x , newPixel . y ) ;
pixel . con . x = pixel . x ;
pixel . con . y = pixel . y ;
pixel . con . del ;
moved = true ;
break ;
}
}
}
if ( pixel . con && ! moved ) { // move to same stage if none other
for ( var i = 0 ; i < squareCoordsShuffle . length ; i ++ ) {
var coord = squareCoordsShuffle [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
delete pixel . con . del ;
pixel . con . x = x ;
pixel . con . y = y ;
pixelMap [ x ] [ y ] = pixel . con ;
currentPixels . push ( pixel . con ) ;
pixel . con = null ;
break ;
}
if ( ! isEmpty ( x , y , true ) && listPipes . includes ( pixelMap [ x ] [ y ] . element ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
if ( pixel . con && ! newPixel . con ) {
newPixel . con = pixel . con ;
newPixel . con . x = newPixel . x ;
newPixel . con . y = newPixel . y ;
pixel . con = null ;
break ;
}
}
}
}
}
doDefaults ( pixel ) ;
} ,
category : "machines" ,
movable : false ,
canContain : true ,
noMix : true ,
2024-03-09 12:37:36 -05:00
insulate : true ,
2024-01-07 12:40:20 -05:00
}
elements . gas _filter = {
color : "#599fc2" ,
tick : function ( pixel ) {
if ( 1 === 2 ) {
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
// createPixel("brick",x,y);
// pixelMap[x][y].color = pixelColorPick(pixel,"#808080");
}
}
// pixel.stage = 1;
}
else if ( 1 === 2 ) { //uninitialized
for ( var i = 0 ; i < adjacentCoords . length ; i ++ ) {
var coord = adjacentCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
// pixel.stage = 2; //blue
// pixel.color = pixelColorPick(pixel,"#000036");
break ;
}
}
}
else if ( 1 === 1 ) { //initialized
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) && listPipes . includes ( pixelMap [ x ] [ y ] . element ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
if ( newPixel . stage === 1 ) {
var newColor ;
switch ( pixel . stage ) {
// case 2: newPixel.stage = 3; newColor = "#003600"; break; //green
// case 3: newPixel.stage = 4; newColor = "#360000"; break; //red
// case 4: newPixel.stage = 2; newColor = "#000036"; break; //blue
}
// newPixel.color = pixelColorPick(newPixel,newColor);
}
}
}
var moved = false ;
shuffleArray ( squareCoordsShuffle ) ;
for ( var i = 0 ; i < squareCoordsShuffle . length ; i ++ ) {
var coord = squareCoordsShuffle [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
if ( listPipes . includes ( newPixel . element ) ) {
var nextStage ;
switch ( pixel . stage ) {
// case 2: nextStage = 4; break; //green
// case 3: nextStage = 2; break; //red
// case 4: nextStage = 3; break; //blue
}
if ( pixel . con && ! newPixel . con ) { //transfer to adjacent pipe
newPixel . con = pixel . con ;
newPixel . con . x = newPixel . x ;
newPixel . con . y = newPixel . y ;
pixel . con = null ;
moved = true ;
break ;
}
}
else if ( ! pixel . con && elements [ newPixel . element ] . movable && ( elements [ newPixel . element ] . state == "gas" ) ) { //suck up pixel
pixel . con = newPixel ;
deletePixel ( newPixel . x , newPixel . y ) ;
pixel . con . x = pixel . x ;
pixel . con . y = pixel . y ;
pixel . con . del ;
moved = true ;
break ;
}
}
}
if ( pixel . con && ! moved ) { // move to same stage if none other
for ( var i = 0 ; i < squareCoordsShuffle . length ; i ++ ) {
var coord = squareCoordsShuffle [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y ) ) {
delete pixel . con . del ;
pixel . con . x = x ;
pixel . con . y = y ;
pixelMap [ x ] [ y ] = pixel . con ;
currentPixels . push ( pixel . con ) ;
pixel . con = null ;
break ;
}
if ( ! isEmpty ( x , y , true ) && listPipes . includes ( pixelMap [ x ] [ y ] . element ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
if ( pixel . con && ! newPixel . con ) {
newPixel . con = pixel . con ;
newPixel . con . x = newPixel . x ;
newPixel . con . y = newPixel . y ;
pixel . con = null ;
break ;
}
}
}
}
}
doDefaults ( pixel ) ;
} ,
category : "machines" ,
movable : false ,
canContain : true ,
noMix : true ,
2024-03-09 12:37:36 -05:00
insulate : true ,
2024-01-07 12:40:20 -05:00
}
2024-01-08 17:18:58 -05:00
function weightedAverage ( num1 , num2 , weight ) {
return ( ( weight * num1 ) + ( ( 1 - weight ) * num2 ) )
}
2025-02-10 11:16:32 -05:00
function getPixelColor ( pixel ) {
let rgb2 ;
if ( pixel . color . startsWith ( "#" ) ) {
rgb2 = pixel . color . match ( /[0-9A-F]{2}/ig ) . map ( x => parseInt ( x , 16 ) ) ;
} else if ( pixel . color . startsWith ( "hsl" ) ) {
var hsl = pixel . color . match ( /\d+/g ) ;
hsl [ 0 ] = ( hsl [ 0 ] / 360 ) % 360 ; if ( hsl [ 0 ] < 0 ) { hsl [ 0 ] ++ } ;
hsl [ 1 ] = Math . max ( Math . min ( hsl [ 1 ] / 100 , 1 ) , 0 ) ;
hsl [ 2 ] = Math . max ( Math . min ( hsl [ 2 ] / 100 , 1 ) , 0 ) ;
rgb2 = HSLtoRGB ( hsl )
} else {
rgb2 = pixel . color . match ( /\d+/g ) ;
}
return rgb2
}
2024-01-08 17:18:58 -05:00
elements . dyer = {
customColor : true ,
color : [ "#ff0000" , "#ff8800" , "#ffff00" , "#00ff00" , "#00ffff" , "#0000ff" , "#ff00ff" ] ,
behavior : behaviors . wall ,
movable : false ,
state : "solid" ,
category : "machines" ,
tick : function ( pixel ) {
for ( var i = 0 ; i < squareCoordsShuffle . length ; i ++ ) {
var coord = squareCoordsShuffle [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
if ( ! ( pixelMap [ x ] [ y ] . element == "dyer" ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
var rgb1 = pixel . color . match ( /\d+/g ) ;
2025-02-10 11:16:32 -05:00
var rgb2 = getPixelColor ( newPixel )
2024-01-08 17:18:58 -05:00
// average the colors
var rgb = [
weightedAverage ( parseInt ( rgb1 [ 0 ] ) , parseInt ( rgb2 [ 0 ] ) , 0.2 ) ,
weightedAverage ( parseInt ( rgb1 [ 1 ] ) , parseInt ( rgb2 [ 1 ] ) , 0.2 ) ,
weightedAverage ( parseInt ( rgb1 [ 2 ] ) , parseInt ( rgb2 [ 2 ] ) , 0.2 ) ,
] ;
// convert rgb to hex
var hex = RGBToHex ( rgb ) ;
newPixel . color = pixelColorPick ( newPixel , hex ) ;
}
}
}
}
2024-01-15 14:02:31 -05:00
}
elemfillerVar = 0 ;
elements . element _filler = {
category : "special" ,
color : elements . filler . color ,
2024-02-09 18:11:48 -05:00
excludeRandom : true ,
2024-01-15 14:02:31 -05:00
state : "solid" ,
movable : "false" ,
onSelect : function ( ) {
2024-03-03 16:54:43 -05:00
var answer6 = prompt ( "Please input the desired element of this filler. It will not work if you do multiple filler types while paused." , ( elemfillerVar || undefined ) ) ;
2024-01-15 14:02:31 -05:00
if ( ! answer6 ) { return }
2024-01-24 12:51:15 -05:00
elemfillerVar = mostSimilarElement ( answer6 ) ;
2024-01-15 14:02:31 -05:00
} ,
tick : function ( pixel ) {
var neighbors = 0 ;
if ( ! pixel . changeElem ) {
pixel . changeElem = elemfillerVar ;
}
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
neighbors = neighbors + 1 ;
} else if ( isEmpty ( x , y ) ) {
createPixel ( "element_filler" , x , y )
pixelMap [ x ] [ y ] . changeElem = pixel . changeElem ;
} else (
changePixel ( pixel , pixel . changeElem )
)
}
if ( neighbors >= 8 ) {
changePixel ( pixel , pixel . changeElem )
}
}
2024-02-06 16:58:05 -05:00
}
var outlinerVar = 0
2024-07-03 00:07:33 -04:00
elements . inner _outliner = {
2024-02-06 16:58:05 -05:00
color : elements . filler . color ,
category : elements . filler . category ,
2024-02-09 18:11:48 -05:00
excludeRandom : true ,
2024-02-06 16:58:05 -05:00
onSelect : function ( ) {
2024-03-03 16:54:43 -05:00
var answerot = prompt ( "Please input the desired element of this outliner. It will not work if you do multiple outliner types while paused." , ( outlinerVar || undefined ) ) ;
2024-02-06 16:58:05 -05:00
if ( ! answerot ) { return }
outlinerVar = mostSimilarElement ( answerot ) ;
} ,
tick : function ( pixel ) {
var neighbors = 0 ;
if ( ! pixel . changeElem ) {
pixel . changeElem = outlinerVar ;
if ( pixel . nDelete == undefined ) {
pixel . nDelete = false
}
}
if ( pixel . nDelete ) {
deletePixel ( pixel . x , pixel . y )
}
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
neighbors = neighbors + 1 ;
}
}
if ( neighbors >= 8 ) {
pixel . nDelete = true
} else {
changePixel ( pixel , pixel . changeElem )
}
}
2024-02-09 19:57:48 -05:00
}
textures . transparency = [
"wwwggg" ,
"wwwggg" ,
"wwwggg" ,
"gggwww" ,
"gggwww" ,
"gggwww"
]
2024-02-16 21:05:00 -05:00
textures . steel = [
"hHhhd" ,
"Hnnnd" ,
"hnnnd" ,
"hnnnD" ,
"dddDD"
]
textures . sponge = [
"hddddnnddd" ,
"Ddhddhnhdd" ,
"ddDdnNnNdd" ,
"dddhnnnnnh" ,
"dhdNnhnnnN" ,
"nNnhnNnddd" ,
"dhnNnnddhd" ,
"dDnnnhddDd" ,
"dhnnnNdhdd" ,
"ddddnddDdd"
]
textures . copper = [
"uuuuum" ,
"unhhnd" ,
"uhhnnD" ,
"uhnnHd" ,
"unnHnD" ,
"mdDdDD"
]
textures . gold = [
"hnnndbHHHhhnbHHHh" ,
"nnndbhnnnnndDbnnn" ,
"nnddbnnnnnddDbnnn" ,
"dddbnnnddddDDDbnd" ,
"DDDbDDDDDDDDDDbDD" ,
"BBBBBBBBBBBBBBBBB"
]
2024-02-17 14:30:19 -05:00
textures . diamond = [
"llcccLbLl" ,
"lcccccbbC" ,
"CScccBbCC" ,
"SSScBBBLC" ,
"SSSSLBbLS" ,
"SSSCLbbbL" ,
"BSCCCnbBL" ,
"BBBCnnBBB" ,
"lBBcLnLbL"
]
2024-02-09 19:57:48 -05:00
elements . transparency = {
2024-02-09 19:59:12 -05:00
color : [ "#d4d4d4" , "#ffffff" ] ,
2024-02-09 19:57:48 -05:00
colorPattern : textures . transparency ,
colorKey : {
"g" : "#D4D4D4" ,
"w" : "#ffffff"
} ,
behavior : behaviors . WALL ,
category : "special" ,
state : "solid"
2024-02-16 21:05:00 -05:00
}
elements . textured _steel = {
color : [ "#708196" , "#8895ad" , "#596B77" , "#525D6B" , "#404954" ] ,
colorPattern : textures . steel ,
colorKey : {
"h" : "#708196" ,
"H" : "#8895ad" ,
"n" : "#596B77" ,
"d" : "#525D6B" ,
"D" : "#404954"
} ,
behavior : behaviors . WALL ,
category : "solids" ,
state : "solid" ,
tick : function ( pixel ) {
if ( pixelTicks - pixel . start == 1 ) {
pixel . element = "steel"
}
}
}
elements . textured _sponge = {
color : [ "#ccaa00" , "#c1a100" , "#967d00" , "#b89a00" , "#ae9100" ] ,
colorPattern : textures . sponge ,
colorKey : {
"n" : "#ccaa00" ,
"N" : "#c1a100" ,
"h" : "#967d00" ,
"d" : "#b89a00" ,
"D" : "#ae9100"
} ,
behavior : behaviors . WALL ,
category : "solids" ,
state : "solid" ,
tick : function ( pixel ) {
if ( pixelTicks - pixel . start == 1 ) {
pixel . element = "sponge"
}
}
}
elements . textured _copper = {
color : [ "#772F22" , "#AB533F" , "#9E3F2D" , "#9E3F2D" , "#4C1C11" ] ,
colorPattern : textures . copper ,
colorKey : {
"u" : "#772F22" ,
"H" : "#AB533F" ,
"h" : "#C0725A" ,
"n" : "#9E3F2D" ,
"D" : "#4C1C11" ,
"d" : "#622516" ,
"m" : "#712C1E"
} ,
behavior : behaviors . WALL ,
category : "solids" ,
state : "solid" ,
tick : function ( pixel ) {
if ( pixelTicks - pixel . start == 1 ) {
pixel . element = "copper"
}
}
}
elements . textured _gold = {
color : [ "#E4B038" , "#FFCA59" , "#BF8A18" , "#7F5A10" , "#674611" ] ,
colorPattern : textures . gold ,
colorKey : {
"h" : "#FFCA59" ,
"H" : "#FFFFCC" ,
"n" : "#E4B038" ,
"B" : "#513412" ,
"b" : "#674611" ,
"d" : "#BF8A18" ,
"D" : "#7F5A10"
} ,
behavior : behaviors . WALL ,
category : "solids" ,
state : "solid" ,
tick : function ( pixel ) {
if ( pixelTicks - pixel . start == 1 ) {
pixel . element = "gold"
}
}
2024-02-16 23:20:38 -05:00
}
2024-02-17 14:30:19 -05:00
elements . solid _diamond = {
color : elements . diamond . color ,
category : "solids" ,
colorPattern : textures . diamond ,
colorKey : {
"c" : "#36BDF3" ,
"C" : "#7DD1F2" ,
"B" : "#4B94ED" ,
"b" : "#97BEED" ,
"L" : "#C2D5ED" ,
"n" : "#7BAEED" ,
"l" : "#A2DBF2" ,
"S" : "#BDF8FF"
} ,
2025-01-10 20:30:36 -05:00
reactions : elements . diamond . reactions ,
2024-02-17 14:30:19 -05:00
state : "solid" ,
2024-06-16 10:10:24 -04:00
density : elements . diamond . density ,
hardness : elements . diamond . hardness ,
behavior : behaviors . WALL ,
2024-02-17 14:30:19 -05:00
}
2024-02-16 23:20:38 -05:00
elements . textured _rose _gold = {
color : [ "#FF5991" , "#E4386F" , "#7F1037" , "#FFCCCD" , "#671133" ] ,
colorPattern : textures . gold ,
colorKey : {
"h" : "#FF5991" ,
"H" : "#FFCCCD" ,
"n" : "#E4386F" ,
"B" : "#511230" ,
"b" : "#671133" ,
"d" : "#BF1850" ,
"D" : "#7F1037"
} ,
behavior : behaviors . WALL ,
category : "solids" ,
state : "solid" ,
tick : function ( pixel ) {
if ( pixelTicks - pixel . start == 1 ) {
pixel . element = "rose_gold"
}
}
2024-03-09 12:37:36 -05:00
}
elements . insulating _filler = {
color : elements . filler . color ,
2024-03-10 13:23:54 -04:00
behavior : behaviors . FILL ,
2024-03-09 12:37:36 -05:00
category : elements . filler . category ,
state : elements . filler . state ,
insulate : true
2024-03-11 17:33:52 -04:00
}
selvoid = 0 ;
elements . selective _void = {
category : "special" ,
color : elements . void . color ,
excludeRandom : true ,
state : "solid" ,
movable : "false" ,
onSelect : function ( ) {
var selvoidans = prompt ( "Please input the desired element of this void. It will not work if you do multiple void types while paused." , ( selvoid || undefined ) ) ;
if ( ! selvoidans ) { return }
selvoid = mostSimilarElement ( selvoidans ) ;
} ,
tick : function ( pixel ) {
if ( ! pixel . changeElem ) {
pixel . changeElem = selvoid ;
}
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
var otherPixel = pixelMap [ x ] [ y ]
if ( otherPixel . element == pixel . changeElem )
deletePixel ( x , y )
}
}
}
2024-03-17 14:49:54 -04:00
}
2024-07-03 00:07:33 -04:00
let circleElem = "wood"
2024-03-17 14:49:54 -04:00
elements . scuffed _circle _brush = {
category : "special" ,
color : elements . drag . color ,
excludeRandom : true ,
state : "solid" ,
2024-03-18 20:20:44 -04:00
movable : false ,
2024-03-17 14:49:54 -04:00
onSelect : function ( ) {
var answerE = prompt ( "Element of the brush." , ( circleElem || undefined ) ) ;
if ( ! answerE ) { return }
2024-07-03 00:07:33 -04:00
circleElem = mostSimilarElement ( answerE ) ;
2024-03-17 14:49:54 -04:00
} ,
tick : function ( pixel ) {
2024-07-03 00:07:33 -04:00
let radius = mouseSize / 2
//pyhtagoreas time
if ( Math . sqrt ( Math . pow ( pixel . x - mousePos . x , 2 ) + Math . pow ( pixel . y - mousePos . y , 2 ) ) < radius ) {
deletePixel ( pixel . x , pixel . y )
createPixel ( circleElem , pixel . x , pixel . y )
} else {
deletePixel ( pixel . x , pixel . y )
}
2024-03-17 14:49:54 -04:00
}
2024-03-21 20:02:51 -04:00
}
2024-08-24 15:14:04 -04:00
elements . scuffed _triangle _brush = {
category : "special" ,
color : elements . drag . color ,
excludeRandom : true ,
state : "solid" ,
movable : false ,
onSelect : function ( ) {
var answerE = prompt ( "Element of the brush." , ( circleElem || undefined ) ) ;
if ( ! answerE ) { return }
circleElem = mostSimilarElement ( answerE ) ;
} ,
tick : function ( pixel ) {
let radius = mouseSize / 2
if ( ( pixel . y - mousePos . y + mouseSize > 2 * ( pixel . x - mousePos . x ) + 0.5 * mouseSize ) && ( pixel . y - mousePos . y + mouseSize > - 2 * ( pixel . x - mousePos . x ) + 0.5 * mouseSize ) ) {
deletePixel ( pixel . x , pixel . y )
createPixel ( circleElem , pixel . x , pixel . y )
} else {
deletePixel ( pixel . x , pixel . y )
}
}
}
2024-04-09 18:34:17 -04:00
function randomIntFromInterval ( min , max ) { // min and max included
return Math . floor ( Math . random ( ) * ( max - min + 1 ) + min )
}
2024-03-21 20:02:51 -04:00
elements . spacedust _cola = {
color : [ "#090033" , "#0a0027" , "#0a001b" , "#0b000f" ] ,
behavior : elements . soda . behavior ,
tempHigh : 104 ,
stateHigh : [ "steam" , "carbon_dioxide" , "spacedust" , "spacedust" ] ,
category : "liquids" ,
state : "liquid" ,
reactions : { head : { elem1 : null , chance : 0.02 } } ,
density : elements . tungsten . density ,
2025-01-10 20:30:36 -05:00
isFood : true ,
2024-03-21 20:02:51 -04:00
}
elements . spacedust = {
color : [ "#090033" , "#0a0027" , "#0a001b" , "#0b000f" , "#090033" , "#0a0027" , "#0a001b" , "#0b000f" , "#090033" , "#0a0027" , "#0a001b" , "#0b000f" , "#090033" , "#0a0027" , "#0a001b" , "#0b000f" , "#090033" , "#0a0027" , "#0a001b" , "#0b000f" , "#090033" , "#0a0027" , "#0a001b" , "#0b000f" , "#ffffff" ] ,
behavior : behaviors . POWDER ,
category : "special" ,
state : "solid" ,
reactions : {
"acid" : { elem1 : null , elem2 : [ "hydrogen" , "helium" , "hydrogen" , "helium" , "hydrogen" , "helium" , "hydrogen" , "hydrogen" , "hydrogen" , "hydrogen" , "metal_scrap" ] , chance : 0.02 } ,
"seltzer" : { elem1 : null , elem2 : "spacedust_cola" } ,
"soda" : { elem1 : null , elem2 : "spacedust_cola" } ,
} ,
density : elements . tungsten . density ,
}
elements . acid . ignore . push ( "spacedust" )
2024-03-21 21:52:15 -04:00
elements . acid . ignore . push ( "spacedust_cola" )
2024-03-23 18:48:26 -04:00
elements . sun . breakInto = "spacedust"
var gridElem = 0
2024-03-23 18:48:54 -04:00
elements . grid _brush = {
2024-03-23 18:48:26 -04:00
color : elements . lattice . color ,
behavior : behaviors . WALL ,
category : "special" ,
movable : false ,
onSelect : function ( ) {
2024-03-23 18:48:54 -04:00
var gridans = prompt ( "Please input the desired element of this grid brush" , ( gridElem || undefined ) ) ;
2024-03-23 18:48:26 -04:00
if ( ! gridans ) { return }
gridElem = mostSimilarElement ( gridans ) ;
} ,
tick : function ( pixel ) {
if ( pixel . x % 2 || pixel . y % 2 ) {
deletePixel ( pixel . x , pixel . y )
createPixel ( gridElem , pixel . x , pixel . y )
} else {
deletePixel ( pixel . x , pixel . y )
}
}
2024-04-07 14:26:05 -04:00
}
2024-04-20 23:20:00 -04:00
elements . healing _serum = {
color : [ "#79d2c5" , "#77d8c0" , "#78ddb9" , "#7de1b0" , "#85e6a6" , "#91e99a" , "#9fec8e" ] ,
behavior : behaviors . LIQUID ,
category : "liquids" ,
state : "liquid" ,
properties : {
wait : 15 ,
waitReduce : false ,
} ,
tick : function ( pixel ) {
if ( pixel . waitReduce ) { pixel . wait -= 1 }
2025-01-18 23:36:29 -05:00
if ( ! pixel . decidedPixel ) {
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
let otherPixel = pixelMap [ x ] [ y ]
if ( otherPixel . element != "healing_serum" ) {
pixel . decidedPixel = otherPixel
pixel . waitReduce = true
break ;
2024-04-20 23:20:00 -04:00
}
}
}
2025-01-18 23:36:29 -05:00
}
if ( pixel . wait <= 0 ) {
const { x , y , ... remainingProperties } = pixel . decidedPixel ;
Object . assign ( pixel , remainingProperties ) ;
delete pixel . decidedPixel
return ;
}
} ,
renderer : function ( pixel , ctx ) {
// interpolate pixel color and decidedpixel's color (if it has one!)
if ( pixel . decidedPixel ) {
var color1 = pixel . color . match ( /\d+/g ) ;
2025-02-10 11:16:32 -05:00
var color2 = getPixelColor ( pixel . decidedPixel )
2025-01-18 23:36:29 -05:00
var ratio = pixel . wait / 15
drawSquare ( ctx , ` rgb( ${ color1 [ 0 ] * ratio + color2 [ 0 ] * ( 1 - ratio ) } , ${ color1 [ 1 ] * ratio + color2 [ 1 ] * ( 1 - ratio ) } , ${ color1 [ 2 ] * ratio + color2 [ 2 ] * ( 1 - ratio ) } ) ` , pixel . x , pixel . y )
}
else {
drawSquare ( ctx , pixel . color , pixel . x , pixel . y )
2024-04-20 23:20:00 -04:00
}
}
2024-05-11 16:49:18 -04:00
}
2024-05-11 16:50:26 -04:00
var rayElement = "ray"
2024-05-11 16:49:18 -04:00
var rayStoppedByWalls = false
elements . ray _emitter = {
color : "#ff9c07" ,
behavior : behaviors . WALL ,
category : "machines" ,
movable : false ,
onSelect : function ( pixel ) {
var rayans = prompt ( "Please input the desired element of this ray emitter" , ( rayElement || undefined ) ) ;
if ( ! rayans ) { return }
rayElement = mostSimilarElement ( rayans ) ;
2024-05-12 09:51:07 -04:00
var rayans2 = prompt ( "Should the ray be stopped by walls? Write true or false." , ( rayStoppedByWalls || false ) ) ;
2024-05-11 20:20:20 -04:00
if ( rayans2 == "false" ) { rayStoppedByWalls = false } else { rayStoppedByWalls = true }
2024-05-11 16:49:18 -04:00
} ,
hoverStat : function ( pixel ) {
2025-02-01 17:00:01 -05:00
return ( pixel . rayElement || "unset" ) . toUpperCase ( ) + ", " + ( pixel . rayStoppedByWalls || "unset" ) . toString ( ) . toUpperCase ( )
2024-05-11 16:49:18 -04:00
} ,
tick : function ( pixel ) {
if ( pixelTicks == pixel . start ) {
pixel . rayElement = rayElement
pixel . rayStoppedByWalls = rayStoppedByWalls
}
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
2024-05-16 17:03:14 -04:00
if ( pixelMap [ x ] [ y ] . charge && ( pixelMap [ x ] [ y ] . element == "wire" || pixelMap [ x ] [ y ] . element == "insulated_wire" ) ) {
if ( ( Math . abs ( coord [ 0 ] ) + Math . abs ( coord [ 1 ] ) == 2 ) && pixelMap [ x ] [ y ] . element == "insulated_wire" ) { return }
2024-05-11 16:49:18 -04:00
var dir = [ 0 - squareCoords [ i ] [ 0 ] , 0 - squareCoords [ i ] [ 1 ] ]
var startx = pixel . x + dir [ 0 ]
var starty = pixel . y + dir [ 1 ]
var magnitude = 0
if ( width > height ) { magnitude = width } else { magnitude = height }
var endx = startx + ( magnitude * dir [ 0 ] )
var endy = starty + ( magnitude * dir [ 1 ] )
// console.log("Direction seems to be " + dir)
var jcoords = lineCoords ( startx , starty , endx , endy , 1 )
// console.log(startx + " is the starting x, " + starty + " is the starting y, " + endx + " is the ending x, " + endy + " is the ending y. Result is " + jcoords)
for ( var j = 0 ; j < jcoords . length ; j ++ ) {
var lcoord = jcoords [ j ] ;
var lx = lcoord [ 0 ] ;
var ly = lcoord [ 1 ] ;
// console.log(lcoord)
if ( isEmpty ( lx , ly ) ) {
createPixel ( pixel . rayElement , lx , ly )
2024-05-14 16:26:10 -04:00
pixelMap [ lx ] [ ly ] . temp = pixel . temp
2024-05-11 19:38:35 -04:00
if ( pixel . rayElement == "ray" ) {
pixelMap [ lx ] [ ly ] . rColor = pixel . color
2024-05-11 19:47:20 -04:00
pixelMap [ lx ] [ ly ] . color = pixel . color
2024-05-11 19:38:35 -04:00
}
2024-05-11 16:49:18 -04:00
} else if ( ! isEmpty ( lx , ly , true ) ) {
if ( pixelMap [ lx ] [ ly ] . element != pixel . rayElement && pixel . rayStoppedByWalls ) {
break ;
2024-05-11 19:38:35 -04:00
} else if ( pixelMap [ lx ] [ ly ] . element == "ray" && pixel . rayElement == "ray" ) {
pixelMap [ lx ] [ ly ] . rColor = pixel . color
2024-05-12 09:51:07 -04:00
pixelMap [ lx ] [ ly ] . life = 10
2024-05-11 19:47:20 -04:00
pixelMap [ lx ] [ ly ] . color = pixel . color
2024-05-11 16:49:18 -04:00
}
}
}
}
}
}
} ,
insulate : true ,
}
elements . indestructible _battery = {
color : elements . battery . color ,
behavior : elements . battery . behavior ,
category : elements . battery . category
}
elements . ray = {
color : "#ffffff" ,
behavior : behaviors . WALL ,
2024-05-11 19:38:35 -04:00
movable : true ,
2024-05-11 16:49:18 -04:00
category : "special" ,
hoverStat : function ( pixel ) {
2025-02-10 11:16:32 -05:00
return ( pixel . life || "unset" ) . toString ( )
2024-05-11 16:49:18 -04:00
} ,
properties : {
2024-05-18 13:48:13 -04:00
life : 10 ,
maxLife : 10 ,
2024-05-11 16:49:18 -04:00
} ,
tick : function ( pixel ) {
2024-05-11 19:38:35 -04:00
if ( pixel . rColor ) {
pixel . rgb = pixel . rColor . match ( /\d+/g ) ;
} else {
pixel . rgb = [ 255 , 255 , 255 ]
}
2024-05-11 16:49:18 -04:00
pixel . life -= 1
2024-05-18 13:48:13 -04:00
if ( pixel . life < pixel . maxLife ) {
pixel . color = "rgba(" + pixel . rgb [ 0 ] + "," + pixel . rgb [ 1 ] + "," + pixel . rgb [ 2 ] + "," + ( pixel . life / pixel . maxLife ) + ")"
2024-05-11 19:38:35 -04:00
} else { pixel . color = "rgba(" + pixel . rgb [ 0 ] + "," + pixel . rgb [ 1 ] + "," + pixel . rgb [ 2 ] + ",1)" }
2024-06-18 21:50:05 -04:00
// lightmap.js integration
if ( enabledMods . includes ( "mods/lightmap.js" ) ) {
let x = Math . floor ( pixel . x / lightmapScale ) ;
let y = Math . floor ( pixel . y / lightmapScale ) ;
lightmap [ y ] [ x ] = { color : [ parseInt ( pixel . rgb [ 0 ] ) * ( ( pixel . life / pixel . maxLife ) ) , parseInt ( pixel . rgb [ 1 ] ) * ( ( pixel . life / pixel . maxLife ) ) , parseInt ( pixel . rgb [ 2 ] ) * ( ( pixel . life / pixel . maxLife ) ) ] } ;
}
2024-05-11 16:49:18 -04:00
if ( pixel . life <= 0 ) {
deletePixel ( pixel . x , pixel . y )
}
2024-05-12 09:51:07 -04:00
} ,
canPlace : true ,
tool : function ( pixel ) {
if ( pixel . element == "ray" ) {
pixel . life = 10
pixel . color = pixel . rColor
}
2024-05-11 16:49:18 -04:00
}
2024-05-12 19:49:19 -04:00
}
var specificRayStart = 0
var specificRayEnd = 20
var specificRayAngle = 0
var stopAtElement = "wall"
2024-05-18 13:48:13 -04:00
var rayLife = 10
var rainbowMode = "no"
2024-05-12 19:49:19 -04:00
elements . specific _ray _emitter = {
color : "#e73e63" ,
behavior : behaviors . WALL ,
category : "machines" ,
movable : false ,
onSelect : function ( pixel ) {
var rayans = prompt ( "Please input the desired element of this ray emitter" , ( rayElement || undefined ) ) ;
if ( ! rayans ) { return }
rayElement = mostSimilarElement ( rayans ) ;
2024-06-28 22:48:35 -04:00
if ( rayElement != "ray" ) { rainbowMode = false }
2024-05-12 19:49:19 -04:00
var rayans2 = prompt ( "Should the ray be stopped by walls? Write true or false." , ( rayStoppedByWalls || false ) ) ;
if ( rayans2 == "false" ) { rayStoppedByWalls = false } else { rayStoppedByWalls = true }
var rayans3 = prompt ( "How much should the beginning of the ray be offset from the emitter?" , ( specificRayStart || 0 ) ) ;
if ( ! rayans3 ) { return }
specificRayStart = rayans3
var rayans4 = prompt ( "How much should the end of the ray be offset from the emitter?" , ( specificRayEnd || 0 ) ) ;
if ( ! rayans4 ) { return }
specificRayEnd = rayans4
var rayans5 = prompt ( "What angle should the ray be emitted at? Type anything that isnt a number to use default angle logic." , ( specificRayAngle || 0 ) ) ;
if ( ! rayans5 ) { return }
specificRayAngle = rayans5
if ( isNaN ( parseFloat ( specificRayAngle ) ) ) {
specificRayAngle = "nah"
}
var rayans6 = prompt ( "What element should the ray stop at?" , ( stopAtElement || "wall" ) ) ;
if ( ! rayans6 ) { return }
stopAtElement = mostSimilarElement ( rayans6 )
2024-05-18 13:48:13 -04:00
let rayans7
2024-06-15 22:49:53 -04:00
if ( rayans == "ray" ) { rayans7 = prompt ( "How long should the ray stay on screen in ticks?" , ( rayLife || 10 ) ) ;
2024-05-18 13:48:13 -04:00
if ( ! rayans7 ) { return }
if ( isNaN ( parseFloat ( rayans7 ) ) ) {
rayLife = 10
} else {
rayLife = rayans7
}
var rayans8 = prompt ( "Would you like rainbow mode to be enabled? Type yes or no." , ( rainbowMode || "no" ) ) ;
if ( rayans8 == "yes" ) { rainbowMode = true } else { rainbowMode = false }
2024-06-15 22:49:53 -04:00
}
2024-05-12 19:49:19 -04:00
} ,
hoverStat : function ( pixel ) {
return ( pixel . rayElement . toUpperCase ( ) || "unset" ) + ", " + ( pixel . rayStoppedByWalls . toString ( ) . toUpperCase ( ) || "unset" ) + ", " + ( pixel . specificRayStart || "unset" ) + ", " + ( pixel . specificRayEnd || "unset" ) + ", " + ( pixel . specificRayAngle || "unset" )
} ,
tick : function ( pixel ) {
if ( pixelTicks == pixel . start ) {
pixel . rayElement = rayElement
pixel . rayStoppedByWalls = rayStoppedByWalls
pixel . specificRayStart = specificRayStart
pixel . specificRayEnd = specificRayEnd
pixel . specificRayAngle = specificRayAngle
pixel . stopAtElement = stopAtElement
2024-05-18 13:48:13 -04:00
pixel . life = rayLife
pixel . rainbowMode = rainbowMode
}
if ( pixel . rainbowMode ) {
pixel . specificRayAngle ++
pixel . rgb = pixel . color . match ( /\d+/g ) ;
pixel . rgb [ 0 ] = parseInt ( pixel . rgb [ 0 ] )
pixel . rgb [ 1 ] = parseInt ( pixel . rgb [ 1 ] )
pixel . rgb [ 2 ] = parseInt ( pixel . rgb [ 2 ] )
2024-06-21 22:05:33 -04:00
//console.log(pixel.rgb)
2024-05-18 13:48:13 -04:00
var hsvResult = RGBtoHSV ( pixel . rgb [ 0 ] , pixel . rgb [ 1 ] , pixel . rgb [ 2 ] ) ;
pixel . tHue = hsvResult . h ;
var rgbResult = HSVtoRGB ( pixel . tHue + ( 1 / 360 ) , 1 , 1 ) ;
2024-06-21 22:05:33 -04:00
//console.log(rgbResult)
2024-05-18 13:48:13 -04:00
const hexR = rgbResult . r . toString ( 16 ) . padStart ( 2 , '0' ) ;
const hexG = rgbResult . g . toString ( 16 ) . padStart ( 2 , '0' ) ;
const hexB = rgbResult . b . toString ( 16 ) . padStart ( 2 , '0' ) ;
const hexCode = ` # ${ hexR } ${ hexG } ${ hexB } ` ;
2024-06-21 22:05:33 -04:00
//console.log(hexCode)
2024-05-18 13:48:13 -04:00
pixel . color = pixelColorPick ( pixel , hexCode ) }
2024-05-12 19:49:19 -04:00
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
2024-05-16 17:03:14 -04:00
if ( pixelMap [ x ] [ y ] . charge && ( pixelMap [ x ] [ y ] . element == "wire" || pixelMap [ x ] [ y ] . element == "insulated_wire" ) ) {
if ( ( Math . abs ( coord [ 0 ] ) + Math . abs ( coord [ 1 ] ) == 2 ) && pixelMap [ x ] [ y ] . element == "insulated_wire" ) { return }
2024-05-12 19:49:19 -04:00
var dir = [ 0 - squareCoords [ i ] [ 0 ] , 0 - squareCoords [ i ] [ 1 ] ]
let startx , starty , endx , endy , magnitude
if ( pixel . specificRayAngle == "nah" ) {
2024-05-17 19:51:48 -04:00
startx = pixel . x + ( dir [ 0 ] * pixel . specificRayStart )
starty = pixel . y + ( dir [ 1 ] * pixel . specificRayStart )
magnitude = pixel . specificRayEnd
2024-05-12 19:49:19 -04:00
endx = startx + ( magnitude * dir [ 0 ] )
endy = starty + ( magnitude * dir [ 1 ] )
} else {
let angleInRadians = pixel . specificRayAngle * Math . PI / 180 ;
2024-05-18 13:48:13 -04:00
//console.log("Angle in radians is " + angleInRadians)
2024-05-12 19:49:19 -04:00
dir = [ ( Math . cos ( angleInRadians ) ) , ( Math . sin ( angleInRadians ) ) ]
2024-05-17 19:51:48 -04:00
startx = pixel . x + Math . round ( ( dir [ 0 ] * pixel . specificRayStart ) )
starty = pixel . y + Math . round ( ( dir [ 1 ] * pixel . specificRayStart ) )
magnitude = pixel . specificRayEnd
2024-05-12 19:49:19 -04:00
endx = startx + Math . round ( ( magnitude * dir [ 0 ] ) )
endy = starty + Math . round ( ( magnitude * dir [ 1 ] ) )
}
2024-05-18 13:48:13 -04:00
//console.log("Direction seems to be " + dir)
2024-05-12 19:49:19 -04:00
var jcoords = lineCoords ( startx , starty , endx , endy , 1 )
//console.log(startx + " is the starting x, " + starty + " is the starting y, " + endx + " is the ending x, " + endy + " is the ending y. Result is " + jcoords)
for ( var j = 0 ; j < jcoords . length ; j ++ ) {
var lcoord = jcoords [ j ] ;
var lx = lcoord [ 0 ] ;
var ly = lcoord [ 1 ] ;
// console.log(lcoord)
if ( isEmpty ( lx , ly ) ) {
createPixel ( pixel . rayElement , lx , ly )
2024-05-14 16:26:10 -04:00
pixelMap [ lx ] [ ly ] . temp = pixel . temp
2024-05-12 19:49:19 -04:00
if ( pixel . rayElement == "ray" ) {
pixelMap [ lx ] [ ly ] . rColor = pixel . color
pixelMap [ lx ] [ ly ] . color = pixel . color
2024-05-18 13:48:13 -04:00
pixelMap [ lx ] [ ly ] . life = pixel . life
pixelMap [ lx ] [ ly ] . maxLife = pixel . life
2024-05-12 19:49:19 -04:00
}
} else if ( ! isEmpty ( lx , ly , true ) ) {
if ( ( pixelMap [ lx ] [ ly ] . element != pixel . rayElement && pixel . rayStoppedByWalls ) || pixelMap [ lx ] [ ly ] . element == pixel . stopAtElement ) {
break ;
} else if ( pixelMap [ lx ] [ ly ] . element == "ray" && pixel . rayElement == "ray" ) {
pixelMap [ lx ] [ ly ] . rColor = pixel . color
2024-05-18 13:48:13 -04:00
pixelMap [ lx ] [ ly ] . life = pixel . life
pixelMap [ lx ] [ ly ] . maxLife = pixel . life
2024-05-12 19:49:19 -04:00
pixelMap [ lx ] [ ly ] . color = pixel . color
}
}
}
}
}
}
} ,
insulate : true ,
2024-05-15 16:27:02 -04:00
}
elements . run _some _code = {
color : "#68b2cf" ,
category : "tools" ,
canPlace : false ,
2024-08-02 16:21:02 -04:00
tool : function ( ) { } ,
2024-05-15 16:27:02 -04:00
onSelect : function ( ) {
let code = prompt ( "Enter code to run" )
if ( code ) {
eval ( code )
}
}
2024-05-16 17:03:14 -04:00
}
elements . insulated _wire = {
color : "#5e2d2c" ,
category : "machines" ,
conduct : 1 ,
tick : function ( pixel ) {
{
if ( pixel . charge ) {
// Check each adjacent pixel, if that pixel's charge is false, set it to the same charge
for ( var i = 0 ; i < adjacentCoords . length ; i ++ ) {
var x = pixel . x + adjacentCoords [ i ] [ 0 ] ;
var y = pixel . y + adjacentCoords [ i ] [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
var con = newPixel . element ;
2024-06-15 21:45:36 -04:00
if ( con == "insulated_wire" || con == "wire_bridge" ) {
if ( 1 == 1 ) { // If random number is less than conductivity
if ( ! newPixel . charge && ! newPixel . chargeCD ) {
newPixel . charge = 1 ;
}
}
}
}
}
pixel . charge -= 0.25 ;
if ( pixel . charge <= 0 ) {
delete pixel . charge ;
// pixel.chargeCD = 4;
pixel . chargeCD = Math . round ( 4 + ( 4 * ( 1 - elements [ pixel . element ] . conduct ) ) ) || 4 ;
}
}
// Lower charge cooldown
else if ( pixel . chargeCD ) {
pixel . chargeCD -= 1 ;
if ( pixel . chargeCD <= 0 ) {
delete pixel . chargeCD ;
if ( elements [ pixel . element ] . colorOn ) {
pixel . color = pixelColorPick ( pixel ) ;
}
}
}
}
doHeat ( pixel )
}
}
elements . wire _bridge = {
color : "#461716" ,
category : "machines" ,
conduct : 1 ,
tick : function ( pixel ) {
{
if ( pixel . charge ) {
// Check each adjacent pixel, if that pixel's charge is false, set it to the same charge
for ( var i = 0 ; i < adjacentCoords . length ; i ++ ) {
var x = pixel . x + adjacentCoords [ i ] [ 0 ] ;
var y = pixel . y + adjacentCoords [ i ] [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
var con = newPixel . element ;
if ( con == "insulated_wire" || con == "wire" || con == "wire_bridge" ) {
2024-05-16 17:03:14 -04:00
if ( 1 == 1 ) { // If random number is less than conductivity
if ( ! newPixel . charge && ! newPixel . chargeCD ) {
newPixel . charge = 1 ;
}
}
}
}
}
pixel . charge -= 0.25 ;
if ( pixel . charge <= 0 ) {
delete pixel . charge ;
// pixel.chargeCD = 4;
pixel . chargeCD = Math . round ( 4 + ( 4 * ( 1 - elements [ pixel . element ] . conduct ) ) ) || 4 ;
}
}
// Lower charge cooldown
else if ( pixel . chargeCD ) {
pixel . chargeCD -= 1 ;
if ( pixel . chargeCD <= 0 ) {
delete pixel . chargeCD ;
if ( elements [ pixel . element ] . colorOn ) {
pixel . color = pixelColorPick ( pixel ) ;
}
}
}
}
doHeat ( pixel )
}
}
elements . insulated _wire . desc = "Insulated wire. Only conducts to other insulated wires. Pairs with ray emitters to not make diagonal rays."
elements . e _pipe . desc = "Electric pipe. Only passes elements while charged."
2024-05-27 12:17:14 -04:00
elements . destroyable _e _pipe . desc = elements . e _pipe . desc
2024-05-16 17:03:14 -04:00
elements . channel _pipe . desc = "Channel pipe. Only passes elements to pipes of the same channel."
elements . bridge _pipe . desc = "Bridge pipe. Can pass and receive from any other type of pipe."
elements . ray _emitter . desc = "Emits a ray of the specified element in the opposite direction it was shocked from."
elements . specific _ray _emitter . desc = "Emits a ray of the specified element in a specific direction and a specific length."
2024-05-29 17:12:02 -04:00
elements . blackhole _storage . desc = "Stores elements inside of itself. Can be released by shocking it."
let pullOrPush = 1
2025-01-12 16:20:43 -05:00
elements . anchor = {
color : "#020c20" ,
category : "machines" ,
behavior : behaviors . WALL ,
desc : "Anchor; unpushable and unpullable by pistons." ,
onSelect : function ( ) {
logMessage ( "Unpushable and unpullable by pistons." )
}
}
2024-05-29 17:12:02 -04:00
elements . piston _ray _emitter = {
color : "#143b5f" ,
behavior : behaviors . WALL ,
category : "machines" ,
movable : false ,
onSelect : function ( ) {
var ans1 = prompt ( "Would you like this piston to pull or push?" , "pull" ) . toLowerCase ( ) ;
if ( ans1 == "pull" ) { pullOrPush = 1 }
else if ( ans1 == "push" ) { pullOrPush = 2 }
} ,
tick : function ( pixel ) {
if ( pixelTicks == pixel . start ) {
pixel . pullOrPush = pullOrPush
}
if ( ! pixel . cooldown ) { pixel . cooldown = 0 }
if ( pixel . cooldown < 1 ) {
for ( var i = 0 ; i < adjacentCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
if ( pixelMap [ x ] [ y ] . charge && ( pixelMap [ x ] [ y ] . element == "wire" || pixelMap [ x ] [ y ] . element == "insulated_wire" ) ) {
pixel . cooldown = 6
var dir = [ 0 - squareCoords [ i ] [ 0 ] , 0 - squareCoords [ i ] [ 1 ] ]
var startx = pixel . x + dir [ 0 ]
var starty = pixel . y + dir [ 1 ]
var magnitude = 0
if ( width > height ) { magnitude = width } else { magnitude = height }
var endx = startx + ( magnitude * dir [ 0 ] )
var endy = starty + ( magnitude * dir [ 1 ] )
// console.log("Direction seems to be " + dir)
var jcoords
if ( pixel . pullOrPush == 1 ) { jcoords = lineCoords ( startx , starty , endx , endy , 1 ) }
else { jcoords = lineCoords ( endx , endy , startx , starty , 1 ) }
// console.log(startx + " is the starting x, " + starty + " is the starting y, " + endx + " is the ending x, " + endy + " is the ending y. Result is " + jcoords)
let pCoord = jcoords [ 0 ]
for ( var j = 0 ; j < jcoords . length ; j ++ ) {
var lcoord = jcoords [ j ] ;
var lx = lcoord [ 0 ] ;
var ly = lcoord [ 1 ] ;
if ( ! isEmpty ( lx , ly , true ) ) {
2025-01-12 16:20:43 -05:00
if ( ! ( pixelMap [ lx ] [ ly ] . element == "anchor" ) ) {
tryMove ( pixelMap [ lx ] [ ly ] , pCoord [ 0 ] , pCoord [ 1 ] , null , true )
}
2024-05-29 17:12:02 -04:00
}
pCoord [ 0 ] = lx ;
pCoord [ 1 ] = ly ;
}
}
}
} } else { pixel . cooldown -= 1 }
} ,
insulate : true ,
}
let pistonStart = 0
let pistonEnd = 0
2024-06-27 14:00:34 -04:00
let pistonDistance = 1
let pistonCooldown = 10
2024-08-24 15:14:04 -04:00
let pistonRepeat = 1
let pistonRepeatCooldown = 1
function pistonEmit ( pixel , i ) {
pixel . cooldown = pixel . pistonCooldown
pixel . rcooldown = pixel . pistonRepeatCooldown
var dir = [ 0 - squareCoords [ i ] [ 0 ] , 0 - squareCoords [ i ] [ 1 ] ]
var startx = pixel . x + ( dir [ 0 ] * ( pixel . pistonStart + 1 ) )
var starty = pixel . y + ( dir [ 1 ] * ( pixel . pistonStart + 1 ) )
var magnitude = pixel . pistonEnd
var endx = startx + ( magnitude * dir [ 0 ] )
var endy = starty + ( magnitude * dir [ 1 ] )
// console.log("Direction seems to be " + dir)
var jcoords
if ( pixel . pullOrPush == 1 ) { jcoords = lineCoords ( startx , starty , endx , endy , 1 ) }
else { jcoords = lineCoords ( endx , endy , startx , starty , 1 ) }
// console.log(startx + " is the starting x, " + starty + " is the starting y, " + endx + " is the ending x, " + endy + " is the ending y. Result is " + jcoords)
let pCoord = jcoords [ 0 ]
for ( var j = 0 ; j < jcoords . length ; j ++ ) {
var lcoord = jcoords [ j ] ;
var lx = lcoord [ 0 ] ;
var ly = lcoord [ 1 ] ;
if ( ! isEmpty ( lx , ly , true ) ) {
2025-01-12 16:20:43 -05:00
if ( ! ( pixelMap [ lx ] [ ly ] . element == "anchor" ) ) {
tryMove ( pixelMap [ lx ] [ ly ] , pCoord [ 0 ] , pCoord [ 1 ] , null , true )
}
2024-08-24 15:14:04 -04:00
}
pCoord [ 0 ] = lx ;
pCoord [ 1 ] = ly ;
}
}
2024-05-29 17:12:02 -04:00
elements . specific _piston _ray _emitter = {
color : "#517597" ,
behavior : behaviors . WALL ,
category : "machines" ,
movable : false ,
onSelect : function ( ) {
var ans1 = prompt ( "Would you like this piston to pull or push?" , "pull" ) . toLowerCase ( ) ;
if ( ans1 == "pull" ) { pullOrPush = 1 }
else if ( ans1 == "push" ) { pullOrPush = 2 }
var ans2 = parseInt ( prompt ( "How offset should the start of the push/pulling be?" , "0" ) )
pistonStart = ans2
var ans3 = parseInt ( prompt ( "How offset should the end of the push/pulling be?" , "20" ) )
pistonEnd = ans3
2024-06-27 14:00:34 -04:00
var ans4 = parseInt ( prompt ( "How far should it push the pixels each charge?" , "1" ) )
pistonDistance = ans4
var ans5 = parseInt ( prompt ( "How many ticks should it wait to be charged again?" , "6" ) )
pistonCooldown = ans5
2024-08-24 15:14:04 -04:00
var ans6 = parseInt ( prompt ( "How many times should it repeat the push/pulling?" , "1" ) )
pistonRepeat = ans6
if ( pistonRepeat != 1 ) {
var ans7 = parseInt ( prompt ( "How many ticks should it wait between repeats?" , "1" ) )
pistonRepeatCooldown = ans7
}
2024-05-29 17:12:02 -04:00
} ,
tick : function ( pixel ) {
if ( pixelTicks == pixel . start ) {
pixel . pullOrPush = pullOrPush
pixel . pistonStart = pistonStart
pixel . pistonEnd = pistonEnd
2024-06-27 14:00:34 -04:00
pixel . pistonDistance = pistonDistance
pixel . pistonCooldown = pistonCooldown
2024-08-24 15:14:04 -04:00
pixel . pistonRepeat = pistonRepeat
pixel . pistonRepeatCooldown = pistonRepeatCooldown
2024-05-29 17:12:02 -04:00
}
2024-08-24 15:15:21 -04:00
if ( ! pixel . pistonRepeat ) {
pixel . pistonRepeat = pistonRepeat
pixel . pistonRepeatCooldown = pistonRepeatCooldown
}
2024-05-29 17:12:02 -04:00
if ( ! pixel . cooldown ) { pixel . cooldown = 0 }
2024-08-24 15:14:04 -04:00
if ( ! pixel . rcooldown ) { pixel . rcooldown = 0 }
if ( ! pixel . repeatAmounts ) { pixel . repeatAmounts = 0 }
if ( ! pixel . fakei ) { pixel . fakei = 0 }
2024-05-29 17:12:02 -04:00
if ( pixel . cooldown < 1 ) {
for ( var i = 0 ; i < adjacentCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
if ( pixelMap [ x ] [ y ] . charge && ( pixelMap [ x ] [ y ] . element == "wire" || pixelMap [ x ] [ y ] . element == "insulated_wire" ) ) {
2024-08-24 15:14:04 -04:00
pixel . repeatAmounts = pixel . pistonRepeat
pixel . fakei = i
2024-06-27 14:00:34 -04:00
for ( let r = 0 ; r < pixel . pistonDistance ; r ++ ) {
2024-08-24 15:14:04 -04:00
pistonEmit ( pixel , i ) ;
}
pixel . repeatAmounts --
2024-05-29 17:12:02 -04:00
}
}
2024-08-24 15:14:04 -04:00
} } else { pixel . cooldown -- }
if ( pixel . rcooldown < 1 && pixel . repeatAmounts > 0 ) {
for ( let r = 0 ; r < pixel . pistonDistance ; r ++ ) {
pistonEmit ( pixel , pixel . fakei ) ;
}
pixel . repeatAmounts --
} else { pixel . rcooldown -- }
2024-05-29 17:12:02 -04:00
} ,
insulate : true ,
2024-06-15 21:45:36 -04:00
}
if ( ! elements . molten _gallium . reactions ) { elements . gallium . reactions = { } }
elements . molten _gallium . reactions . nitrogen = { elem1 : "gallium_nitride" , elem2 : null , chance : 0.02 , tempMin : 1200 }
elements . gallium _nitride = {
color : "#dedf9d" ,
behavior : behaviors . WALL ,
colorOn : "#493ee9" ,
category : "solids" ,
tempHigh : 1650 ,
density : 6100 ,
stateHigh : "molten_gallium_nitride" ,
state : "solid" ,
conduct : 0.84 ,
tick : function ( pixel ) {
if ( pixel . charge ) {
for ( var i = 0 ; i < adjacentCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y , true ) ) {
if ( Math . random ( ) < 0.3 ) {
createPixel ( "light" , x , y )
pixelMap [ x ] [ y ] . color = pixelColorPick ( pixelMap [ x ] [ y ] , "#493ee9" )
}
}
}
}
2024-06-21 19:50:02 -04:00
} ,
movable : false ,
2024-06-15 21:45:36 -04:00
}
elements . molten _gallium _nitride = {
color : [ "#d29d70" , "#cf8e5e" , "#cd7e4e" , "#ca6d40" , "#c75b33" ] ,
behavior : behaviors . MOLTEN ,
category : "states" ,
hidden : true ,
state : "liquid" ,
tempLow : 1640 ,
stateLow : "gallium_nitride" ,
density : 6050 ,
}
elements . gallium _phosphide = {
color : "#be6008" ,
behavior : behaviors . WALL ,
colorOn : "#00ff15" ,
category : "solids" ,
tempHigh : 1457 ,
density : 4138 ,
stateHigh : "molten_gallium_phosphide" ,
state : "solid" ,
conduct : 0.84 ,
tick : function ( pixel ) {
if ( pixel . charge ) {
for ( var i = 0 ; i < adjacentCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( isEmpty ( x , y , true ) ) {
if ( Math . random ( ) < 0.3 ) {
createPixel ( "light" , x , y )
pixelMap [ x ] [ y ] . color = pixelColorPick ( pixelMap [ x ] [ y ] , "#00ff15" )
}
}
}
}
2024-06-21 19:50:02 -04:00
} ,
movable : false ,
2024-06-15 21:45:36 -04:00
}
elements . molten _gallium _phosphide = {
color : [ "#a36936" , "#cf8e5e" , "#9b4c1c" , "#ca6d40" , "#a13d19" ] ,
behavior : behaviors . MOLTEN ,
category : "states" ,
hidden : true ,
state : "liquid" ,
tempLow : 1447 ,
stateLow : "gallium_phosphide" ,
density : 4100 ,
2024-06-18 21:50:05 -04:00
}
2024-06-25 13:40:02 -04:00
/ *
2024-06-18 21:50:05 -04:00
let funcRadius = 10
let functionScope = "pixel"
let funcFunction = "function(){console.log('Hello World')}"
let functionStorage = function ( ) { }
elements . function _machine = {
color : "#56999e" ,
behavior : behaviors . WALL ,
category : "machines" ,
state : "solid" ,
onSelect : function ( ) {
let ans1 = prompt ( "What radius should the function be executed at? (Ignore if you plan on making it a global one." , funcRadius || 10 )
funcRadius = parseInt ( ans1 )
let ans2 = prompt ( "What scope should the function be executed in? Type \"global\" or \"pixel\" (without the quotes of course.)" , functionScope || "pixel" )
if ( ans2 == "global" ) { functionScope = "global" } else { functionScope = "pixel" }
let ans3 = prompt ( "Type the entire function. Example: function(pixel){pixel.temp = 1000}}" , funcFunction || "function(){console.log('Hello World')}" )
funcFunction = ans3
} ,
tick : function ( pixel ) {
if ( pixelTicks == pixel . start ) {
pixel . radius = funcRadius
pixel . scope = functionScope
pixel . function = funcFunction
}
if ( pixel . scope == "global" ) {
eval ( "functionStorage = " + pixel . function )
functionStorage ( )
} else {
var circlec = circleCoords ( pixel . x , pixel . y , pixel . radius )
for ( var i = 0 ; i < circlec . length ; i ++ ) {
var coord = circlec [ i ]
var x = coord . x
var y = coord . y
if ( ! isEmpty ( x , y , true ) ) {
eval ( "functionStorage = " + pixel . function )
functionStorage ( pixelMap [ x ] [ y ] )
}
}
}
2024-06-21 22:05:33 -04:00
} ,
excludeRandom : true ,
2024-06-21 14:38:01 -04:00
}
2024-06-25 13:40:02 -04:00
* /
2024-08-05 10:30:12 -04:00
/ *
2024-06-21 14:38:01 -04:00
elements . galvanized _steel = {
color : "#4c585f" ,
behavior : behaviors . WALL ,
tempHigh : 1455.5 ,
category : "solids" ,
density : 7850 ,
conduct : 0.42 ,
hardness : 0.8 ,
tick : function ( pixel ) {
for ( var i = 0 ; i < adjacentCoords . length ; i ++ ) {
var coord = squareCoords [ i ] ;
var x = pixel . x + coord [ 0 ] ;
var y = pixel . y + coord [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
let otherPixel = pixelMap [ x ] [ y ]
if ( otherPixel . element == "molten_zinc" ) {
if ( Math . random ( ) < 0.005 ) {
deletePixel ( x , y )
if ( ! pixel . absorbedZinc ) { pixel . absorbedZinc = 0 }
pixel . absorbedZinc ++
}
} else if ( otherPixel . element == "steel" ) {
if ( pixel . absorbedZinc && Math . random ( ) < 0.02 ) {
changePixel ( otherPixel , "galvanized_steel" )
pixel . absorbedZinc --
}
}
else if ( otherPixel . element == "galvanized_steel" ) {
if ( ! otherPixel . absorbedZinc ) { otherPixel . absorbedZinc = 0 }
if ( pixel . absorbedZinc > otherPixel . absorbedZinc && Math . random ( ) < 0.1 ) {
otherPixel . absorbedZinc ++
pixel . absorbedZinc --
}
}
}
}
2024-06-21 19:50:02 -04:00
} ,
movable : false
2024-06-21 14:38:01 -04:00
}
if ( ! eLists . metals ) { eLists . metals = [ ] }
eLists . metals = eLists . metals . concat ( [ "galvanized_steel" ] )
if ( ! elements . steel . reactions ) { elements . steel . reactions = { } }
elements . steel . reactions . molten _zinc = { elem1 : "galvanized_steel" , chance : 0.035 }
if ( ! elements . molten _zinc . reactions ) { elements . zinc . reactions = { } }
2024-07-02 11:49:59 -04:00
elements . molten _zinc . reactions . steel = { elem1 : "null" , chance : 0.2 }
2024-08-05 10:30:12 -04:00
* /
2024-07-02 11:49:59 -04:00
elements . super _heat _conductor = {
color : "#b66b61" ,
behavior : behaviors . WALL ,
category : "solids" ,
density : 10000 ,
tick : function ( pixel ) {
for ( let j = 0 ; j <= 10 ; j ++ ) {
for ( var i = 0 ; i < adjacentCoords . length ; i ++ ) {
var x = pixel . x + adjacentCoords [ i ] [ 0 ] ;
var y = pixel . y + adjacentCoords [ i ] [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
// Skip if both temperatures are the same
if ( pixel . temp == newPixel . temp || elements [ newPixel . element ] . insulate == true ) {
continue ;
}
// Set both pixel temperatures to their average
var avg = ( pixel . temp + newPixel . temp ) / 2 ;
pixel . temp = avg ;
newPixel . temp = avg ;
pixelTempCheck ( pixel ) ;
pixelTempCheck ( newPixel ) ;
}
}
}
}
}
2024-08-02 16:21:02 -04:00
runEveryTick ( function ( ) {
// run any code after pixels are simulated per tick
2024-07-02 11:49:59 -04:00
var heatpixels = currentPixels . filter ( function ( pixelToCheck ) {
if ( pixelToCheck . element == "global_heat_conductor" ) {
return true ;
}
} )
for ( var i = 0 ; i < heatpixels . length ; i ++ ) {
var newPixel = heatpixels [ i ] ;
var randomPixel = heatpixels [ Math . floor ( Math . random ( ) * heatpixels . length ) ] ;
var avg = ( randomPixel . temp + newPixel . temp ) / 2 ;
randomPixel . temp = avg ;
newPixel . temp = avg ;
2024-08-02 16:21:02 -04:00
}
} )
2024-07-02 11:49:59 -04:00
elements . global _heat _conductor = {
color : "#55251e" ,
behavior : behaviors . WALL ,
category : "solids" ,
density : 10000 ,
2024-07-03 00:07:33 -04:00
}
let latticeElem = "wood"
elements . lattice _brush = {
color : elements . grid _brush . color ,
behavior : behaviors . WALL ,
category : "special" ,
onSelect : function ( ) {
let ans1 = prompt ( "Enter the element you want to use for the lattice" , latticeElem || "wood" )
latticeElem = mostSimilarElement ( ans1 )
} ,
tick : function ( pixel ) {
let modx = pixel . x % 2
let mody = pixel . y % 2
let valid = {
1 : 0 ,
0 : 1
}
if ( valid [ modx ] == mody ) {
changePixel ( pixel , latticeElem )
} else {
deletePixel ( pixel . x , pixel . y )
}
}
}
elements . spaced _lattice _brush = {
color : elements . grid _brush . color ,
behavior : behaviors . WALL ,
category : "special" ,
onSelect : function ( ) {
let ans1 = prompt ( "Enter the element you want to use for the lattice" , latticeElem || "wood" )
latticeElem = mostSimilarElement ( ans1 )
} ,
tick : function ( pixel ) {
let modx = pixel . x % 5
let mody = pixel . y % 5
let valid = {
1 : 3 ,
2 : 0 ,
3 : 2 ,
4 : 4 ,
0 : 1
}
if ( valid [ modx ] == mody ) {
changePixel ( pixel , latticeElem )
} else {
deletePixel ( pixel . x , pixel . y )
}
}
}
let outlinerElem = "wood"
elements . outer _outliner = {
color : elements . inner _outliner . color ,
behavior : behaviors . WALL ,
category : "special" ,
onSelect : function ( ) {
let ans1 = prompt ( "Enter the element you want to use for the outliner. The outliner will ignore pixels of this type." , outlinerElem || "wood" )
outlinerElem = mostSimilarElement ( ans1 )
} ,
tick : function ( pixel ) {
// this just checks if theres any neighboring coord non-outliner elem pixels. yuh that simple
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var x = pixel . x + squareCoords [ i ] [ 0 ] ;
var y = pixel . y + squareCoords [ i ] [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
var newPixel = pixelMap [ x ] [ y ] ;
if ( newPixel . element != outlinerElem && newPixel . element != "outer_outliner" ) {
deletePixel ( pixel . x , pixel . y )
createPixel ( outlinerElem , pixel . x , pixel . y )
return ;
}
}
}
deletePixel ( pixel . x , pixel . y )
}
2024-08-02 16:21:02 -04:00
}
function highestValueObjectKey ( object ) {
let max = - Infinity
for ( var key in object ) {
if ( object [ key ] > ( object [ max ] || - Infinity ) ) {
max = key
}
}
return max
}
function sumOfObjectValues ( object ) {
let sum = 0
for ( var key in object ) {
sum += object [ key ]
}
return sum
}
neighborRandomChance = {
1 : 0.015 ,
2 : 0.03 ,
3 : 0.06 ,
4 : 0.12 ,
5 : 0.2 ,
6 : 0.5 ,
7 : 0.8 ,
8 : 1
}
elements . colored _filler = {
color : elements . rainbow . color ,
behavior : behaviors . WALL ,
category : "special" ,
customColor : true ,
properties : {
"initalized" : false ,
} ,
tick : function ( pixel ) {
let fillerNeighbors = { }
for ( var i = 0 ; i < adjacentCoords . length ; i ++ ) {
var x = pixel . x + adjacentCoords [ i ] [ 0 ] ;
var y = pixel . y + adjacentCoords [ i ] [ 1 ] ;
2024-08-05 10:30:12 -04:00
if ( isEmpty ( x , y ) && pixel . initalized ) {
2024-08-02 16:21:02 -04:00
createPixel ( "colored_filler" , x , y )
pixelMap [ x ] [ y ] . color = pixel . color ;
pixelMap [ x ] [ y ] . initalized = true
}
}
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var x = pixel . x + squareCoords [ i ] [ 0 ] ;
var y = pixel . y + squareCoords [ i ] [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
var otherPixel = pixelMap [ x ] [ y ] ;
if ( otherPixel . element == "colored_filler" && otherPixel . color != pixel . color ) {
fillerNeighbors [ otherPixel . color ] = ( fillerNeighbors [ otherPixel . color ] || 0 ) + 1 ;
}
}
}
if ( Object . keys ( fillerNeighbors ) . length > 0 ) {
let mostSeenColor = highestValueObjectKey ( fillerNeighbors )
let opposingCount = sumOfObjectValues ( fillerNeighbors )
if ( Math . random ( ) < neighborRandomChance [ opposingCount ] ) {
pixel . color = mostSeenColor ;
}
}
} ,
renderer : function ( pixel , ctx ) {
if ( ! pixel . initalized ) {
var rgb = hexToRGB ( currentColor ) ;
pixel . color = "rgb(" + rgb . r + "," + rgb . g + "," + rgb . b + ")" ;
pixel . initalized = true ;
}
if ( pixel . color != "monochrome" && pixel . color != "rainbow" ) {
drawSquare ( ctx , pixel . color , pixel . x , pixel . y ) ;
} else {
if ( pixel . color == "monochrome" ) {
drawSquare ( ctx , "hsl(0, 0%, " + 100 * Math . abs ( Math . asin ( Math . sin ( pixelTicks / 30 ) ) ) / ( 0.5 * Math . PI ) + "%)" , pixel . x , pixel . y ) ;
} else if ( pixel . color == "rainbow" ) {
drawSquare ( ctx , "hsl(" + ( ( pixelTicks % 60 ) / 60 ) * 360 + ", 100%, 50%)" , pixel . x , pixel . y ) ;
}
}
}
2024-08-06 15:28:02 -04:00
}
let copycatfillerElem = "sand"
elements . copycat _filler = {
color : elements . random . color ,
behavior : behaviors . WALL ,
category : "special" ,
onSelect : function ( ) {
let ans1 = prompt ( "Enter the element you want to use for the copycat filler" , copycatfillerElem || "sand" )
copycatfillerElem = mostSimilarElement ( ans1 )
} ,
tick : function ( pixel ) {
let fillerNeighbors = { }
if ( ! pixel . copycatElement ) {
pixel . copycatElement = copycatfillerElem
}
if ( ! pixel . rSeed ) {
pixel . rSeed = [ Math . random ( ) , Math . random ( ) , Math . random ( ) , Math . random ( ) ]
}
for ( var i = 0 ; i < adjacentCoords . length ; i ++ ) {
var x = pixel . x + adjacentCoords [ i ] [ 0 ] ;
var y = pixel . y + adjacentCoords [ i ] [ 1 ] ;
if ( isEmpty ( x , y ) ) {
createPixel ( "copycat_filler" , x , y )
pixelMap [ x ] [ y ] . copycatElement = pixel . copycatElement
}
}
for ( var i = 0 ; i < squareCoords . length ; i ++ ) {
var x = pixel . x + squareCoords [ i ] [ 0 ] ;
var y = pixel . y + squareCoords [ i ] [ 1 ] ;
if ( ! isEmpty ( x , y , true ) ) {
var otherPixel = pixelMap [ x ] [ y ] ;
if ( otherPixel . element == "copycat_filler" && otherPixel . copycatElement != pixel . copycatElement ) {
fillerNeighbors [ otherPixel . copycatElement ] = ( fillerNeighbors [ otherPixel . copycatElement ] || 0 ) + 1 ;
}
}
}
if ( Object . keys ( fillerNeighbors ) . length > 0 ) {
let mostSeenColor = highestValueObjectKey ( fillerNeighbors )
let opposingCount = sumOfObjectValues ( fillerNeighbors )
if ( Math . random ( ) < neighborRandomChance [ opposingCount ] ) {
pixel . copycatElement = mostSeenColor ;
}
}
} ,
renderer : function ( pixel , ctx ) {
if ( ! pixel . copycatElement ) { pixel . copycatElement = copycatfillerElem }
if ( ! pixel . rSeed ) { pixel . rSeed = [ Math . random ( ) , Math . random ( ) , Math . random ( ) , Math . random ( ) ] }
if ( typeof elements [ pixel . copycatElement ] . color == "object" ) {
let selectedColor = elements [ pixel . copycatElement ] . color [ Math . floor ( pixel . rSeed [ 1 ] * elements [ pixel . copycatElement ] . color . length ) ]
let rgb = {
r : parseInt ( selectedColor . match ( /\d+/g ) [ 0 ] ) ,
g : parseInt ( selectedColor . match ( /\d+/g ) [ 1 ] ) ,
b : parseInt ( selectedColor . match ( /\d+/g ) [ 2 ] )
}
for ( let c in rgb ) {
rgb [ c ] += Math . floor ( pixel . rSeed [ 0 ] * ( pixel . rSeed [ 2 ] > 0.5 ? - 1 : 1 ) * pixel . rSeed [ 3 ] * 15 ) ;
rgb [ c ] = Math . max ( 0 , Math . min ( 255 , rgb [ c ] ) ) ;
}
if ( elements [ pixel . copycatElement ] . glow || elements [ pixel . copycatElement ] . isGas ) {
drawPlus ( ctx , "rgb(" + rgb . r + "," + rgb . g + "," + rgb . b + ")" , pixel . x , pixel . y , 1 ) ;
} else {
drawSquare ( ctx , "rgb(" + rgb . r + "," + rgb . g + "," + rgb . b + ")" , pixel . x , pixel . y ) ;
}
} else {
let rgb = {
r : parseInt ( elements [ pixel . copycatElement ] . color . match ( /\d+/g ) [ 0 ] ) ,
g : parseInt ( elements [ pixel . copycatElement ] . color . match ( /\d+/g ) [ 1 ] ) ,
b : parseInt ( elements [ pixel . copycatElement ] . color . match ( /\d+/g ) [ 2 ] )
}
for ( let c in rgb ) {
rgb [ c ] += Math . floor ( pixel . rSeed [ 0 ] * ( pixel . rSeed [ 2 ] > 0.5 ? - 1 : 1 ) * pixel . rSeed [ 3 ] * 15 ) ;
rgb [ c ] = Math . max ( 0 , Math . min ( 255 , rgb [ c ] ) ) ;
}
if ( elements [ pixel . copycatElement ] . glow || elements [ pixel . copycatElement ] . isGas ) {
drawPlus ( ctx , "rgb(" + rgb . r + "," + rgb . g + "," + rgb . b + ")" , pixel . x , pixel . y , 1 ) ;
} else {
drawSquare ( ctx , "rgb(" + rgb . r + "," + rgb . g + "," + rgb . b + ")" , pixel . x , pixel . y ) ;
}
}
}
2024-08-24 15:14:04 -04:00
}
/ *
top left : canvasCoord ( x ) , canvasCoord ( y )
top right : canvasCoord ( x ) + pixelSize , canvasCoord ( y )
bottom left : canvasCoord ( x ) , canvasCoord ( y ) + pixelSize
bottom right : canvasCoord ( x ) + pixelSize , canvasCoord ( y ) + pixelSize
* /
adjacentSidesToCanvas = function ( x , y , px , py ) {
if ( x == 0 && y == - 1 ) {
return [ canvasCoord ( px ) + ( 0.5 * pixelSize ) , canvasCoord ( py ) ]
}
else if ( x == 0 && y == 1 ) {
return [ canvasCoord ( px ) + ( 0.5 * pixelSize ) , canvasCoord ( py ) + pixelSize ]
}
else if ( x == - 1 && y == 0 ) {
return [ canvasCoord ( px ) , canvasCoord ( py ) + ( 0.5 * pixelSize ) ]
}
else if ( x == 1 && y == 0 ) {
return [ canvasCoord ( px ) + pixelSize , canvasCoord ( py ) + ( 0.5 * pixelSize ) ]
}
}
drawRectangle = function ( ctx , color , x , y , width , height , xoffset , yoffset ) {
ctx . fillStyle = color ;
ctx . fillRect ( canvasCoord ( x + xoffset ) , canvasCoord ( y + yoffset ) , pixelSize * width , pixelSize * height )
}
elements . thin _pixel = {
color : "#747474" ,
behavior : behaviors . WALL ,
category : "special" ,
renderer : function ( pixel , ctx ) {
let differentAdjacent = [ ] ;
for ( let i = 0 ; i < adjacentCoords . length ; i ++ ) {
let x = adjacentCoords [ i ] [ 0 ] + pixel . x ;
let y = adjacentCoords [ i ] [ 1 ] + pixel . y ;
if ( ! isEmpty ( x , y , true ) && pixelMap [ x ] [ y ] . element == "thin_pixel" ) {
differentAdjacent . push ( adjacentCoords [ i ] ) ;
}
}
ctx . globalAlpha = 1
differentAdjacent . forEach ( adj => {
let canvasadjacentCoords = adjacentSidesToCanvas ( adj [ 0 ] , adj [ 1 ] , pixel . x , pixel . y ) ;
// if (!canvasadjacentCoords){
// console.log(adj)
// return;
// }
//console.log(canvasadjacentCoords);
ctx . beginPath ( ) ;
ctx . moveTo ( canvasCoord ( pixel . x ) + ( 0.5 * pixelSize ) , canvasCoord ( pixel . y ) + ( 0.5 * pixelSize ) ) ;
ctx . lineTo ( canvasadjacentCoords [ 0 ] , canvasadjacentCoords [ 1 ] ) ;
ctx . strokeStyle = pixel . color ;
if ( pixelSize * 0.24 >= 2 ) { ctx . lineWidth = pixelSize * 0.24 } else { ctx . lineWidth = 2 }
ctx . stroke ( ) ;
//console.log("line")
} ) ;
ctx . fillStyle = pixel . color ;
ctx . fillRect ( canvasCoord ( pixel . x + 0.38 ) , canvasCoord ( pixel . y + 0.38 ) , pixelSize * 0.24 , pixelSize * 0.24 ) ;
}
2024-09-20 06:38:28 -04:00
}
elements . cooler _sensor = {
color : "#5499e7" ,
behavior : behaviors . WALL ,
category : "machines" ,
insulate : true ,
conduct : 1 ,
tick : function ( pixel ) {
let temp = pixel . temp
for ( i = 0 ; i < adjacentCoords . length ; i ++ ) {
let x = adjacentCoords [ i ] [ 0 ] + pixel . x ;
let y = adjacentCoords [ i ] [ 1 ] + pixel . y ;
if ( ! isEmpty ( x , y , true ) ) {
if ( pixelMap [ x ] [ y ] . temp < temp ) {
pixel . charge = 1
}
}
}
}
}
elements . hotter _sensor = {
color : "#e75454" ,
behavior : behaviors . WALL ,
category : "machines" ,
insulate : true ,
conduct : 1 ,
tick : function ( pixel ) {
let temp = pixel . temp
for ( i = 0 ; i < adjacentCoords . length ; i ++ ) {
let x = adjacentCoords [ i ] [ 0 ] + pixel . x ;
let y = adjacentCoords [ i ] [ 1 ] + pixel . y ;
if ( ! isEmpty ( x , y , true ) ) {
if ( pixelMap [ x ] [ y ] . temp > temp ) {
pixel . charge = 1
}
}
}
}
2024-12-28 22:39:50 -05:00
}
let pipe _transmitter _channelVar = 0 ;
elements . pipe _transmitter = {
color : "#6e6250" ,
2025-02-21 16:54:38 -05:00
category : "deprecated" ,
2024-12-28 22:39:50 -05:00
movable : false ,
canContain : true ,
insulate : true ,
onSelect : ( ) => {
let newChannel = prompt ( "Enter the channel of this pipe transmitter. It will not work if you do multiple while paused." , pipe _transmitter _channelVar ) ;
pipe _transmitter _channelVar = newChannel ;
} ,
tick : ( pixel ) => {
if ( ! pixel . channel ) {
pixel . channel = pipe _transmitter _channelVar ;
}
if ( pixel . channel && pixel . con ) {
2025-02-10 11:16:32 -05:00
let valid = currentPixels . filter ( pixel2 =>
pixel2 . element == "pipe_receiver" && pixel2 . channel === pixel . channel && ! ( pixel2 . con )
)
if ( valid . length ) {
console . log ( valid )
shuffleArray ( valid ) ;
console . log ( valid )
pixel . con . x = valid [ 0 ] . x
pixel . con . y = valid [ 0 ] . y
pixelMap [ valid [ 0 ] . x ] [ valid [ 0 ] . y ] . con = pixel . con
delete pixel . con
2024-12-28 22:39:50 -05:00
}
}
}
}
let pipe _receiver _channelVar = 0 ;
elements . pipe _receiver = {
color : "#4d4b63" ,
2025-02-21 16:54:38 -05:00
category : "deprecated" ,
2024-12-28 22:39:50 -05:00
movable : false ,
canContain : true ,
insulate : true ,
onSelect : ( ) => {
let newChannel = prompt ( "Enter the channel of this pipe receiver. It will not work if you do multiple while paused." , pipe _receiver _channelVar ) ;
pipe _receiver _channelVar = newChannel ;
} ,
tick : ( pixel ) => {
if ( ! pixel . channel ) {
pixel . channel = pipe _receiver _channelVar ;
}
if ( pixel . channel && pixel . con ) {
// just scan neighbors for elements on the pipe list; transfer con to them. if its a type of channel pipe, also check if channel matches
for ( i = 0 ; i < squareCoords . length ; i ++ ) {
let x = squareCoords [ i ] [ 0 ] + pixel . x ;
let y = squareCoords [ i ] [ 1 ] + pixel . y ;
if ( ! isEmpty ( x , y , true ) ) {
if ( listPipes . includes ( pixelMap [ x ] [ y ] . element ) ) {
if ( [ "channel_pipe" , "destroyable_channel_pipe" ] . includes ( pixelMap [ x ] [ y ] . element ) ) {
2025-01-10 20:30:36 -05:00
if ( pixelMap [ x ] [ y ] . channel == pixel . channel && ! pixelMap [ x ] [ y ] . con ) {
2024-12-28 22:39:50 -05:00
pixelMap [ x ] [ y ] . con = pixel . con ;
delete pixel . con ;
2025-02-10 11:16:32 -05:00
break ;
2024-12-28 22:39:50 -05:00
}
} else {
pixel . con . x = x ;
pixel . con . y = y ;
pixelMap [ x ] [ y ] . con = pixel . con ;
delete pixel . con ;
2025-02-10 11:16:32 -05:00
break ;
2024-12-28 22:39:50 -05:00
}
}
}
}
}
}
2025-02-10 11:16:32 -05:00
}
elements . false _vacuum _decay _bomb = {
color : "#3f0b0b" ,
category : "weapons" ,
behavior : behaviors . STURDYPOWDER ,
tick : function ( pixel ) {
if ( ! isEmpty ( pixel . x , pixel . y + 1 , true ) ) {
changePixel ( pixel , "false_vacuum" )
}
}
}
elements . false _vacuum = {
color : "#b41b1b" ,
category : "special" ,
hidden : true ,
tick : function ( pixel ) {
if ( ! pixel . timeAlive ) {
pixel . timeAlive = 0
}
pixel . color = ` rgb( ${ 180 / ( pixel . timeAlive + 2 ) } , ${ 27 / ( pixel . timeAlive + 2 ) } , ${ 27 / ( pixel . timeAlive + 2 ) } ) `
if ( pixel . timeAlive === 0 ) {
for ( i = 0 ; i < squareCoords . length ; i ++ ) {
let x = squareCoords [ i ] [ 0 ] + pixel . x ;
let y = squareCoords [ i ] [ 1 ] + pixel . y ;
if ( ! isEmpty ( x , y , true ) ) {
if ( pixelMap [ x ] [ y ] . element !== "false_vacuum" ) {
deletePixel ( x , y )
createPixel ( "false_vacuum" , x , y )
}
} else if ( isEmpty ( x , y ) ) {
createPixel ( "false_vacuum" , x , y )
}
}
}
pixel . timeAlive ++ ;
if ( pixel . timeAlive > 20 ) {
deletePixel ( pixel . x , pixel . y )
return
}
} ,
movable : false ,
hardness : 1
2025-02-16 18:15:40 -05:00
}
let signInput = "Hello World!" ;
elements . sign = {
color : "#FFFFFF" ,
darkText : true ,
category : "special" ,
onSelect : function ( ) {
let signi = prompt ( "What text should the sign display?" , signInput || "Hello World!" )
signInput = signi ;
} ,
renderer : function ( pixel , ctx ) {
if ( ! pixel . sign ) { pixel . sign = signInput }
} ,
movable : false
}
2025-02-18 16:53:15 -05:00
elements . e _sign = {
color : "#f3ff88" ,
darkText : true ,
category : "special" ,
movable : false ,
onSelect : ( ) => {
let signi = prompt ( "What text should the sign display?" , signInput || "Hello World!" )
signInput = signi ;
} ,
renderer : function ( pixel , ctx ) {
if ( ! pixel . sign ) { pixel . sign = signInput }
} ,
conduct : 1
}
2025-02-16 18:15:40 -05:00
renderPostPixel ( function ( ctx ) {
for ( pixel of currentPixels ) {
2025-02-18 16:53:15 -05:00
if ( ( pixel . element == "sign" ) && pixel . sign ) {
2025-02-16 18:18:21 -05:00
ctx . font = ` 12pt Arial `
2025-02-16 18:15:40 -05:00
ctx . fillStyle = pixel . color ;
ctx . fillText ( pixel . sign , canvasCoord ( pixel . x ) , canvasCoord ( pixel . y ) )
2025-02-18 16:53:15 -05:00
} else if ( pixel . element == "e_sign" && pixel . sign ) {
if ( pixel . charge || pixel . chargeCD ) {
ctx . font = ` 12pt Arial `
ctx . fillStyle = pixel . color ;
ctx . fillText ( pixel . sign , canvasCoord ( pixel . x ) , canvasCoord ( pixel . y ) )
} else {
drawSquare ( ctx , pixel . color , pixel . x , pixel . y )
}
}
}
} )
let machinemodName = "nousersthings.js"
elements . mod _dectector = {
color : "#54681d" ,
behavior : behaviors . WALL ,
category : "machines" ,
movable : false ,
excludeRandom : true ,
onSelect : ( ) => {
let newMod = prompt ( "What mod should this machine detect?" , "nousersthings.js" || modName )
machinemodName = newMod
} ,
tick : ( pixel ) => {
if ( ! pixel . mod ) { pixel . mod = machinemodName }
if ( enabledMods . includes ( "mods/" + pixel . mod ) ) {
for ( let i = 0 ; i < adjacentCoords . length ; i ++ ) {
let x = adjacentCoords [ i ] [ 0 ] + pixel . x ;
let y = adjacentCoords [ i ] [ 1 ] + pixel . y ;
if ( ! isEmpty ( x , y , true ) && elements [ pixelMap [ x ] [ y ] . element ] . conduct ) {
pixelMap [ x ] [ y ] . charge = 1
}
}
2025-02-16 18:15:40 -05:00
}
}
2025-02-18 16:53:15 -05:00
}