2023-11-26 15:00:56 -05:00
elements . caesium = {
color : [ "#917921" , "#ebcb59" , "#a48b2d" , "#d6b84c" ] ,
2023-12-05 17:50:14 -05:00
behavior : behaviors . WALL ,
2023-11-26 15:00:56 -05:00
category : "solids" ,
state : "solid" ,
tempHigh : 28.44 ,
stateHigh : "molten_caesium" ,
density : 1873 ,
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" ,
tempHigh : 671 ,
stateHigh : "caesium_vapor" ,
density : 1843 ,
temp : 29 ,
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 ,
stateLow : "molten_caesium" ,
density : 1.7 ,
temp : 700
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
} ,
elements . technetium = {
color : [ "#e7d9bb" , "#bab195" , "#8f8a70" , "#66654e" ] ,
behavior : [
"XX|XX|XX" ,
"XX|CH:neutron%0.07|XX" ,
"XX|XX|XX" ,
] ,
category : "solids" ,
state : "solid" ,
tempHigh : 2157 ,
stateHigh : "molten_technetium" ,
density : 11500
} ,
elements . molten _technetium = {
color : [ "#d16b42" , "#da904c" , "#dfb360" , "#e2d57f" ] ,
behavior : behaviors . LIQUID ,
tick : function ( pixel ) {
if ( Math . random ( ) < 0.0007 ) {
changePixel ( pixel , "neutron" , false ) ;
}
} ,
category : "states" ,
state : "liquid" ,
tempLow : 2140 ,
temp : 2200 ,
stateLow : "technetium" ,
density : 11400
2023-12-01 18:50:14 -05:00
} ,
elements . destroyable _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 ) ;
pixelMap [ x ] [ y ] . color = pixelColorPick ( pixel , "#808080" ) ;
}
}
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 ] ;
2023-12-03 20:55:19 -05:00
if ( newPixel . element === "destroyable_pipe" || newPixel . element === "bridge_pipe" ) {
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
}
if ( pixel . con && ! newPixel . con && newPixel . stage === nextStage ) { //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 ) { //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 ;
}
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 ,
breakInto : [ "metal_scrap" , "oxidixed_copper" ] ,
} ,
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 ,
breakInto : [ "metal_scrap" , "oxidixed_copper" ] ,
} ,
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 ,
breakInto : [ "metal_scrap" , "oxidixed_copper" ] ,
} ,
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 ] ;
if ( ! isEmpty ( x , y ) ) {
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 ] ;
if ( ! isEmpty ( x , y ) ) {
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 ] ;
if ( ! isEmpty ( x , y ) ) {
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 ] ;
if ( ! isEmpty ( x , y ) ) {
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 ) ) {
createPixel ( "brick" , x , y ) ;
pixelMap [ x ] [ y ] . color = pixelColorPick ( pixel , "#808080" ) ;
}
}
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 ] ;
2023-12-03 20:55:19 -05:00
if ( newPixel . element === "e_pipe" || newPixel . element === "bridge_pipe" ) {
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
}
if ( pixel . con && ! newPixel . con && newPixel . stage === nextStage && ( pixel . charge || pixel . chargeCD ) ) { //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 && ( pixel . charge || pixel . chargeCD ) ) { //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 && ( 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 ,
} ,
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 ) ;
pixelMap [ x ] [ y ] . color = pixelColorPick ( pixel , "#808080" ) ;
}
}
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 ] ;
2023-12-03 20:55:19 -05:00
if ( newPixel . element === "destroyable_e_pipe" || newPixel . element === "bridge_pipe" ) {
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
}
if ( pixel . con && ! newPixel . con && newPixel . stage === nextStage && ( pixel . charge || pixel . chargeCD ) ) { //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 && ( pixel . charge || pixel . chargeCD ) ) { //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 && ( 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 ) ) {
createPixel ( "brick" , x , y ) ;
pixelMap [ x ] [ y ] . color = pixelColorPick ( pixel , "#808080" ) ;
}
}
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 ] ;
if ( ( newPixel . element === "channel_pipe" && pixelMap [ x ] [ y ] . channel == pixel . channel || newPixel . element === "bridge_pipe" ) ) {
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 && newPixel . stage === nextStage ) { //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 ) { //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 ) && ( ( 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 ,
} ,
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 ) ;
pixelMap [ x ] [ y ] . color = pixelColorPick ( pixel , "#808080" ) ;
}
}
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 ] ;
if ( ( newPixel . element === "destroyable_channel_pipe" && pixelMap [ x ] [ y ] . channel == pixel . channel ) || newPixel . element === "bridge_pipe" ) {
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 && newPixel . stage === nextStage ) { //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 ) { //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 ) && ( ( 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 ,
} ,
2023-12-16 13:56:31 -05:00
listPipes = [ "pipe" , "destroyable_pipe" , "destroyable_e_pipe" , "channel_pipe" , "destroyable_channel_pipe" , "bridge_pipe" , "e_pipe" ] ;
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 ) ) {
createPixel ( "brick" , x , y ) ;
pixelMap [ x ] [ y ] . color = pixelColorPick ( pixel , "#808080" ) ;
}
}
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
}
if ( pixel . con && ! newPixel . con && newPixel . stage === nextStage ) { //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 ) { //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 . 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 ,
} ,
elements . pipe . 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 ) ;
pixelMap [ x ] [ y ] . color = pixelColorPick ( pixel , "#808080" ) ;
}
}
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 ] ;
if ( newPixel . element === "pipe" || newPixel . element === "bridge_pipe" ) {
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 && newPixel . stage === nextStage ) { //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 ) { //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 ) && ( 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 ) ;
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 ;
}
}
else if ( ! pixel . con && elements [ newPixel . element ] . movable && ( newPixel . element == pixel . filterType ) ) { //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 ,
2023-12-05 17:50:14 -05:00
noMix : true ,
} ,
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
} ,
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
} ,
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 ] ;
if ( ! isEmpty ( x , y ) ) {
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 = [ ] ;
} else {
pixel . decidedcontent = pixel . bhcontents [ Math . floor ( Math . random ( ) * pixel . bhcontents . length ) ] ;
}
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 ) && ( ! pixel . charge && ! pixel . chargeCD ) ) {
var otherPixel = pixelMap [ x ] [ y ] ;
if ( elements [ otherPixel . element ] . movable == true ) {
pixel . bhcontents . push ( otherPixel ) ;
deletePixel ( otherPixel . x , otherPixel . y ) ;
}
} else if ( pixel . charge && isEmpty ( x , y ) && pixel . decidedcontent ) {
var otherPixel = pixelMap [ x ] [ y ] ;
pixel . decidedcontent . x = x ;
pixel . decidedcontent . y = y ;
delete pixel . decidedcontent . del ;
otherPixel = pixel . decidedcontent ;
currentPixels . push ( pixel . decidedcontent ) ;
pixel . bhcontents . splice ( pixel . bhcontents . indexOf ( pixel . decidedcontent ) , 1 ) ;
pixel . decidedcontent = pixel . bhcontents [ Math . floor ( Math . random ( ) * pixel . bhcontents . length ) ] ;
}
}
} ,
movable : false ,
conduct : 1 ,
2023-12-25 16:51:40 -05:00
} ,
elements . plutonium = {
color : [ "#616161" , "#4b4949" , "#353232" , "#211c1c" ] ,
behavior : behaviors . STURDYPOWDER ,
category : "powders" ,
tempHigh : 640 ,
stateHigh : "molten_plutonium" ,
state : "solid" ,
tick : function ( pixel ) {
if ( Math . random ( ) < 0.0007 ) {
changePixel ( pixel , "neutron" , false ) ;
} else if ( Math . random ( ) < 0.0007 ) {
changePixel ( pixel , "uranium" , false ) ;
}
} ,
reactions : {
"neutron" : { elem1 : "pn_explosion" , tempMin : 400 , chance : 0.1 } ,
"neutron" : { temp1 : 100 , temp2 : 100 } ,
} ,
density : 19186 ,
}
elements . molten _plutonium = {
color : [ "#6b5133" , "#743f26" , "#7c2727" ] ,
behavior : behaviors . LIQUID ,
category : "states" ,
state : "liquid" ,
tempLow : 620 ,
stateLow : "plutonium" ,
tick : function ( pixel ) {
if ( Math . random ( ) < 0.0007 ) {
changePixel ( pixel , "neutron" , false ) ;
} else if ( Math . random ( ) < 0.0007 ) {
changePixel ( pixel , "uranium" , false ) ;
}
} ,
reactions : {
"neutron" : { elem1 : "pn_explosion" , tempMin : 400 , chance : 0.1 } ,
} ,
density : 16629 ,
2023-12-26 14:45:35 -05:00
} ,
elements . neutron . reactions = {
"uranium" : { temp2 : 100 } ,
"plutonium" : { temp2 : 100 }
} ,
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-14 14:20:47 -05:00
}