xxxxxxxxxx
2274
// I need a toy
// make me a toy
// using all the bits you've made
// I just need something to entertain myself
// 90% OF THIS IS NOT BASED ON ACTUAL SCIENCE AND IS MAINLY DESIGNED FOR GAMEPLAY
// DO NOT TRY THIS AT HOME
// values
let col1 = [0]
col2 = [255]
col3 = [100]
col4 = [0,0,100]
let tutorialIndex = 0
tutorialSubIndex = 0
neededPart = null
let drillOre = null
nextOre = null
hopperOres = []
oresToShift = -1
let furnaceOre = null
furnaceChuteOre = null
chuteOrigin = 0
furnaceOriginalMaterials = 0
furnaceTempreature = 0
furnaceHeating = -25
furnaceMaxTemp = 1500
furnaceOverheat = false
let grabberPos = 0
prevGrabberPos = 0
grabberTarget = 0
grabberHeight = 0
grabberClosed = false
grabberOre = null
let selectedPart = null
fabricatingPart = null
processing = false
laytheOutput = null
let assemblyLine = []
alAdded = null
assemblerItems = []
assemblerInserting = false
assemblerProcessing = false
assemblingItem = null
assemblerOutput = null
let truckInventory = {}
truckOrder = {}
truckConveyorItem = null
extremelyLoudIncorrectBuzzer = false
truckDriving = false
orderGenerated = false
let money = 0
let ores = {
bauxite: {
composition: {
aluminium: 4,
iron: 2
},
color: [160,160,180],
frequency: 2
},
hematite: {
composition:{
iron: 5,
silicon: 1
},
color: [120,80,80],
frequency: 2
},
tetrahedrite:{
composition:{
copper: 4,
phosphorus: 1
},
color: [160,110,30],
frequency: 1
},
limestone:{
composition:{
calcium: 4,
silicon: 2,
carbon: 1
},
color: [120],
frequency: 3
},
coal: {
composition: {
carbon: 5,
phosphorus: 2
},
color: [60],
frequency: 2
},
rareEarth: {
composition: {
neodymium: 3,
copper: 2,
iron: 1
},
color: [100,100,130],
frequency: 1
},
rosehedrite:{
composition: {
neodymium: 4,
copper: 2,
phosphorus: 2,
silicon: 3
},
color: [180,100,120],
frequency: 1
},
greggium:{
composition: {
neodymium: 20,
copper: 20,
phosphorus: 20,
silicon: 20,
iron: 20,
aluminium: 20,
carbon: 20,
calcium: 10
},
color: [255],
frequency: 0
}
}
let metals = {
iron:{
meltingPoint: 500,
symbol: "Fe",
color: [150,130,130],
dark: false
},
aluminium:{
meltingPoint: 700,
symbol: "Al",
color: [200,200,210],
dark: false
},
copper:{
meltingPoint: 300,
symbol: "Cu",
color: [220,90,0],
dark: false
},
silicon:{
meltingPoint: 600,
symbol: "Si",
color: [100],
dark: true
},
calcium:{
meltingPoint: 1000,
symbol: "Ca",
color: [240],
dark: false
},
phosphorus:{
meltingPoint: 100,
symbol: "P",
color: [120,0,20],
dark: true
},
carbon: {
meltingPoint: 200,
symbol: "C",
color: [40],
dark: true
},
neodymium: {
meltingPoint: 1200,
symbol: "Nd",
color: [150,150,180],
dark: false
}
}
let materials = {}
for(let [Key, value] of Object.entries(metals)){
materials[Key] = 0
}
let selectedMaterials = {}
for(let [Key, value] of Object.entries(metals)){
selectedMaterials[Key] = false
}
// inventory buttons
let i = 0
for(let [Key, value] of Object.entries(metals)){
let newButton = new Button("Box", 10 + (40*i)%160, 85 + 55*Math.floor(i/4))
newButton.width = 30
newButton.height = 45
newButton.shrink = 0
newButton.Pshrink = 0
newButton.stroke = [0]
newButton.Pstroke = [0]
newButton.fill = value.color
newButton.strokeWeight = 2
newButton.text = value.symbol
newButton.textSize = 20
newButton.element = Key
newButton.render = function(){
let needed = false
if(neededPart != null){
for(let i = 0; i < parts[neededPart].materials.length; i++){
if(parts[neededPart].materials[i] == this.element) needed = true
}
}
this.stroke = selectedMaterials[Key]?[0,200,0]:((needed)?[0,50,255]:[0])
let x = this.x
let y = this.y
let w = this.width
let h = this.height
let s = this.shrink
// animations
let Ptimer = this.timeSincePressedChange
let Htimer = min(this.timeSinceHoverChange, Ptimer)
this.Pstroke = color(this.Pstroke)
if(this.hover && !this.pressed){ // when hovered over
cursor(HAND)
this.shrink = Clerp(this.Pshrink, -1, Htimer*5)
}else if(this.pressed){ // when clicked
this.shrink = Clerp(this.Pshrink, 0, Htimer*8)
}else{ // when not hovered or clicked
this.shrink = Clerp(this.Pshrink, 0, Htimer*5)
}
fill(this.fill)
stroke(this.stroke)
strokeWeight(this.strokeWeight)
rect(x + s,y + s,w - s*2,h - 15 - s*2)
fill(210)
rect(x + s,y + 30 - s,w - s*2,15 - s*2)
textSize(10)
noStroke()
fill((materials[Key]==0 && selectedMaterials[Key])?[255,0,0]:0)
textAlign(CENTER,CENTER)
text(materials[Key],x + s,y + 30 - s,w - s*2,15 - s*2)
noStroke()
fill(value.dark?[230]:[0])
textAlign(CENTER,CENTER)
textSize(this.textSize)
text(this.text, x,y,w,h-15)
}
newButton.onHoverBegin = function(){
this.Pstroke = this.stroke
this.Pshrink = this.shrink
cursor(HAND)
}
newButton.onHoverEnd = function(){
this.Pstroke = this.stroke
this.Pshrink = this.shrink
cursor()
}
newButton.onPressBegin = function(){
this.Pstroke = this.stroke
this.Pshrink = this.shrink
if(!processing){
selectedMaterials[Key] = !selectedMaterials[Key]
selectedPart = checkPart()
}
}
newButton.onPress = function(){
}
i++
}
// intermediate components
let parts = {
wire:{
materials:["copper"],
draw(x,y){
push()
translate(x-0.5,y-0.5)
stroke(220,100,0)
strokeWeight(1)
line(2, 2, 2, 19)
line(2, 19, 19, 19)
line(19, 19, 19, 2)
line(19, 2, 4, 2)
line(4, 2, 4, 17)
line(4, 17, 17, 17)
line(17, 17, 17, 4)
line(17, 4, 6, 4)
line(6, 4, 6, 15)
line(6, 15, 15, 15)
line(15, 15, 15, 6)
line(15, 6, 8, 6)
pop()
}
},
concrete:{
materials:["calcium","silicon"],
draw(x,y){
push()
translate(x,y)
noStroke()
fill(150)
rect(2,2,16,16)
stroke(120)
point(5,6)
point(13,15)
point(14,7)
point(7,14)
point(11,3)
pop()
}
},
magnet:{
materials:["iron","copper","neodymium"],
draw(x,y){
push()
translate(x,y)
noStroke()
fill(20,20,30)
rect(2,2,16,16)
fill(220)
rect(5,5,10,10)
pop()
}
},
frame:{
materials:["iron","aluminium"],
draw(x,y){
push()
translate(x,y)
noFill()
stroke(180,180,200)
strokeWeight(2)
rect(2,2,16,16)
line(2,2,18,18)
line(2,18,18,2)
stroke(120)
point(2,2)
point(2,18)
point(18,18)
point(18,2)
pop()
}
},
plastic:{
materials:["carbon","phosphorus"],
draw(x,y){
push()
translate(x,y)
stroke(180)
fill(255)
strokeWeight(2)
rect(2,2,16,16)
strokeWeight(1)
stroke(200)
line(12,4,16,8)
line(8,4,16,12)
pop()
}
},
steel:{
materials:["iron","carbon"],
draw(x,y){
push()
translate(x,y)
noStroke()
fill(100)
rect(2,2,16,4)
rect(2,8,16,4)
rect(2,14,16,4)
pop()
}
},
chip:{
materials:["phosphorus","silicon","neodymium"],
draw(x,y){
push()
translate(x,y)
stroke(160)
strokeWeight(2)
line(2,6,18,6)
line(2,10,18,10)
line(2,14,18,14)
line(6,2,6,18)
line(10,2,10,18)
line(14,2,14,18)
noStroke()
fill(40)
rect(4,4,12,12)
pop()
}
},
lubricant:{
materials:["calcium","phosphorus","carbon"],
draw(x,y){
push()
translate(x,y)
noStroke()
fill(160,60,50)
rect(5,4,10,14)
fill(170,140,50)
rect(6,8,8,4)
fill(140,120,50)
rect(6,1,8,3)
pop()
}
},
glass:{
materials:["silicon"],
draw(x,y){
push()
translate(x,y)
fill(150,160,230)
stroke(100,110,210)
strokeWeight(2)
rect(2,2,16,16)
strokeWeight(1)
stroke(180,180,220)
line(12,4,16,8)
line(8,4,16,12)
pop()
}
},
mirror: {
materials:["aluminium","copper"],
draw(x,y){
push()
translate(x,y)
fill(200)
stroke(180)
strokeWeight(2)
rect(2,2,16,16)
strokeWeight(1)
stroke(240)
line(12,4,16,8)
line(8,4,16,12)
pop()
}
}
}
function checkPart(){
let output = null
// go through parts
for(let [Key, value] of Object.entries(parts)){
let matches = true
// for each slected material
for(let [Key2, value2] of Object.entries(selectedMaterials)){
if(value2){
let matchFound = false
// for each element in part materials list
for(let i = 0; i < value.materials.length; i++){
if(value.materials[i] == Key2) matchFound = true
}
if(!matchFound) matches = false
}else{
// for each element in part materials list
for(let i = 0; i < value.materials.length; i++){
if(value.materials[i] == Key2) matches = false
}
}
}
if(matches) output = Key
}
return output
}
// final products
let products = {
circuit:{
parts:["plastic","wire","chip"],
draw(x,y){
push()
translate(x,y)
stroke(0,60,0)
strokeWeight(1)
fill(0,100,0)
rect(2,2,16,16)
strokeWeight(2)
stroke(220,100,0)
line(6,2,6,6)
line(6,6,18,6)
line(8,6,8,18)
line(13,6,13,14)
line(13,14,18,14)
noStroke()
fill(30)
rect(10,4,6,6)
pop()
}
},
motor:{
parts:["frame","wire","magnet"],
draw(x,y){
push()
translate(x,y)
noStroke()
fill(130)
rect(2,10,16,8)
fill(80)
circle(10,10,15)
fill(100)
circle(10,10,8)
fill(50)
circle(10,10,2)
pop()
}
},
engine:{
parts:["frame","steel","lubricant","steel"],
draw(x,y){
push()
translate(x,y)
noStroke()
fill(120)
rect(2,6,16,12)
fill(60)
rect(4,2,2,6)
rect(8,2,2,6)
rect(12,2,2,6)
fill(90)
rect(6,10,12,4)
pop()
}
},
foundation:{
parts:["frame","plastic","steel","concrete"],
draw(x,y){
push()
translate(x,y)
noStroke()
fill(170)
rect(2,2,16,16)
noFill()
stroke(90)
strokeWeight(2)
rect(2,2,16,16)
line(2,2,18,18)
line(2,18,18,2)
pop()
}
},
solar:{
parts:["frame","mirror","wire","glass"],
draw(x,y){
push()
translate(x,y)
noStroke()
fill(30,50,220)
rect(2,2,16,16)
noFill()
stroke(240)
strokeWeight(1)
line(2,5.5,18,5.5)
strokeWeight(2)
line(2,10,18,10)
strokeWeight(1)
line(2,14.5,18,14.5)
line(5.5,2,5.5,18)
strokeWeight(2)
line(10,2,10,18)
strokeWeight(1)
line(14.5,2,14.5,18)
stroke(150)
strokeWeight(2)
rect(2,2,16,16)
pop()
}
},
trash:{ // MUST BE LAST!!
parts:["wrongwrongwrongwrong"],
draw(x,y){
push()
translate(x,y)
noStroke()
fill(41, 23, 7)
rect(2,2,16,16)
fill(54, 34, 9)
rect(6,5,4,4)
rect(4,12,4,4)
fill(48, 25, 8)
rect(7,8,4,4)
rect(13,10,4,4)
pop()
}
}
}
function generateOrder(){
truckOrder = {}
let productList = []
let i = 0
for(let [Key, value] of Object.entries(products)){
if(Key != "trash") productList[i] = Key
i++
}
let rand1 = round(random(productList.length - 1))
let rand2 = 0
let yes = true
while(yes){
rand2 = round(random(productList.length - 1))
if(rand1 != rand2) yes = false
}
truckOrder[productList[rand1]] = round(random(1,5))
truckOrder[productList[rand2]] = round(random(1,5))
truckInventory = {}
truckInventory[productList[rand1]] = 0
truckInventory[productList[rand2]] = 0
}
// the pressy bits
let grabberLeft = new Button("box",200,200)
grabberLeft.active = true
grabberLeft.hidden = false
grabberLeft.x = 10
grabberLeft.y = 10
grabberLeft.width = 30
grabberLeft.height = 30
grabberLeft.shrink = 0
grabberLeft.Pshrink = 0
grabberLeft.stroke = [0,230,180]
grabberLeft.Pstroke = [0,230,180]
grabberLeft.strokeWeight = 2
grabberLeft.fill = [220]
grabberLeft.text = ""
grabberLeft.textSize = 15
grabberLeft.triangleSize = 10
grabberLeft.triangleRotation = Math.PI
grabberLeft.render = function(){
let x = this.x
let y = this.y
let w = this.width
let h = this.height
let s = this.shrink
// animations
let Ptimer = this.timeSincePressedChange
let Htimer = min(this.timeSinceHoverChange, Ptimer)
this.Pstroke = color(this.Pstroke)
if(this.hover && !this.pressed){ // when hovered over
cursor(HAND)
this.shrink = Clerp(this.Pshrink, 1, Htimer*5)
this.stroke = ClerpColor(this.Pstroke, col4, Htimer*5)
}else if(this.pressed){ // when clicked
this.shrink = Clerp(this.Pshrink, 2, Htimer*8)
this.stroke = ClerpColor(this.Pstroke, col4, Ptimer*5)
}else{ // when not hovered or clicked
this.shrink = Clerp(this.Pshrink, 0, Htimer*5)
this.stroke = ClerpColor(this.Pstroke, col1, Htimer*5)
}
fill(this.fill)
stroke(this.stroke)
strokeWeight(this.strokeWeight)
rect(x + s,y + s,w - s*2,h - s*2)
noStroke()
fill(this.stroke)
textAlign(CENTER,CENTER)
textSize(this.textSize)
text(this.text, x,y,w,h)
x = x + w/2 + (this.triangleSize*(0.2)-(this.shrink*0.2))
y = y + h/2
triangle(x + cos(this.triangleRotation + (PI*2/3)*0)*(this.triangleSize-this.shrink),y + sin(this.triangleRotation + (PI*2/3)*0)*(this.triangleSize-this.shrink),
x + cos(this.triangleRotation + (PI*2/3)*1)*(this.triangleSize-this.shrink), y + sin(this.triangleRotation + (PI*2/3)*1)*(this.triangleSize-this.shrink),
x + cos(this.triangleRotation + (PI*2/3)*2)*(this.triangleSize-this.shrink),y + sin(this.triangleRotation + (PI*2/3)*2)*(this.triangleSize-this.shrink))
}
grabberLeft.onHoverBegin = function(){
this.Pstroke = this.stroke
this.Pshrink = this.shrink
cursor(HAND)
}
grabberLeft.onHoverEnd = function(){
this.Pstroke = this.stroke
this.Pshrink = this.shrink
cursor()
}
grabberLeft.onPressBegin = function(){
this.Pstroke = this.stroke
this.Pshrink = this.shrink
if(grabberTarget > 0 && grabberHeight <= 0){
grabberTarget--
grabberLerpTimer.value = 0
prevGrabberPos = grabberPos
}
}
grabberLeft.onPress = function(){
}
let grabberRight = new Button("box",200,200)
grabberRight.active = true
grabberRight.hidden = false
grabberRight.x = 90
grabberRight.y = 10
grabberRight.width = 30
grabberRight.height = 30
grabberRight.shrink = 0
grabberRight.Pshrink = 0
grabberRight.stroke = [0,230,180]
grabberRight.Pstroke = [0,230,180]
grabberRight.strokeWeight = 2
grabberRight.fill = [220]
grabberRight.text = ""
grabberRight.textSize = 15
grabberRight.triangleSize = 10
grabberRight.triangleRotation = 0
grabberRight.render = function(){
let x = this.x
let y = this.y
let w = this.width
let h = this.height
let s = this.shrink
// animations
let Ptimer = this.timeSincePressedChange
let Htimer = min(this.timeSinceHoverChange, Ptimer)
this.Pstroke = color(this.Pstroke)
if(this.hover && !this.pressed){ // when hovered over
cursor(HAND)
this.shrink = Clerp(this.Pshrink, 1, Htimer*5)
this.stroke = ClerpColor(this.Pstroke, col4, Htimer*5)
}else if(this.pressed){ // when clicked
this.shrink = Clerp(this.Pshrink, 2, Htimer*8)
this.stroke = ClerpColor(this.Pstroke, col4, Ptimer*5)
}else{ // when not hovered or clicked
this.shrink = Clerp(this.Pshrink, 0, Htimer*5)
this.stroke = ClerpColor(this.Pstroke, col1, Htimer*5)
}
fill(this.fill)
stroke((tutorialIndex == 3)?[0,50,255]:this.stroke)
strokeWeight(this.strokeWeight)
rect(x + s,y + s,w - s*2,h - s*2)
noStroke()
fill((tutorialIndex == 3)?[0,50,255]:this.stroke)
textAlign(CENTER,CENTER)
textSize(this.textSize)
text(this.text, x,y,w,h)
x = x + w/2 - (this.triangleSize*(0.2)-(this.shrink*0.2))
y = y + h/2
triangle(x + cos(this.triangleRotation + (PI*2/3)*0)*(this.triangleSize-this.shrink),y + sin(this.triangleRotation + (PI*2/3)*0)*(this.triangleSize-this.shrink),
x + cos(this.triangleRotation + (PI*2/3)*1)*(this.triangleSize-this.shrink), y + sin(this.triangleRotation + (PI*2/3)*1)*(this.triangleSize-this.shrink),
x + cos(this.triangleRotation + (PI*2/3)*2)*(this.triangleSize-this.shrink),y + sin(this.triangleRotation + (PI*2/3)*2)*(this.triangleSize-this.shrink))
}
grabberRight.onHoverBegin = function(){
this.Pstroke = this.stroke
this.Pshrink = this.shrink
cursor(HAND)
}
grabberRight.onHoverEnd = function(){
this.Pstroke = this.stroke
this.Pshrink = this.shrink
cursor()
}
grabberRight.onPressBegin = function(){
this.Pstroke = this.stroke
this.Pshrink = this.shrink
if(grabberTarget < 8 && grabberHeight <= 0) {
grabberTarget++
grabberLerpTimer.value = 0
prevGrabberPos = grabberPos
if(grabberTarget == 8 && tutorialIndex == 3) tutorialIndex ++
}
}
grabberRight.onPress = function(){
}
let grabberClose = new Button("box",200,200)
grabberClose.active = true
grabberClose.hidden = false
grabberClose.x = 50
grabberClose.y = 10
grabberClose.width = 30
grabberClose.height = 30
grabberClose.shrink = 0
grabberClose.Pshrink = 0
grabberClose.stroke = [0,230,180]
grabberClose.Pstroke = [0,230,180]
grabberClose.strokeWeight = 2
grabberClose.fill = [220]
grabberClose.text = ""
grabberClose.textSize = 15
grabberClose.triangleSize = 10
grabberClose.triangleRotation = Math.PI
grabberClose.render = function(){
let x = this.x
let y = this.y
let w = this.width
let h = this.height
let s = this.shrink
// animations
let Ptimer = this.timeSincePressedChange
let Htimer = min(this.timeSinceHoverChange, Ptimer)
this.Pstroke = color(this.Pstroke)
if(this.hover && !this.pressed){ // when hovered over
cursor(HAND)
this.shrink = Clerp(this.Pshrink, 1, Htimer*5)
this.stroke = ClerpColor(this.Pstroke, col4, Htimer*5)
}else if(this.pressed){ // when clicked
this.shrink = Clerp(this.Pshrink, 2, Htimer*8)
this.stroke = ClerpColor(this.Pstroke, col4, Ptimer*5)
}else{ // when not hovered or clicked
this.shrink = Clerp(this.Pshrink, 0, Htimer*5)
this.stroke = ClerpColor(this.Pstroke, col1, Htimer*5)
}
fill(this.fill)
stroke((tutorialIndex == 1 || tutorialIndex == 4)?[0,50,255]:this.stroke)
strokeWeight(this.strokeWeight)
rect(x + s,y + s,w - s*2,h - s*2)
noStroke()
fill(this.stroke)
textAlign(CENTER,CENTER)
textSize(this.textSize)
text(this.text, x,y,w,h)
x = x + w/2
y = y + h/2
noFill()
stroke((tutorialIndex == 1 || tutorialIndex == 4)?[0,50,255]:this.stroke)
strokeWeight(this.strokeWeight + 0.5)
push()
rect(x-w/4+this.shrink,y-h/4+this.shrink,
w/2-this.shrink*2,h/2-this.shrink*2)
if(!grabberClosed){
fill(220)
stroke(220)
strokeWeight(this.strokeWeight + 1)
rect(x-w/4,y,w/2,w/4)
}
pop()
}
grabberClose.onHoverBegin = function(){
this.Pstroke = this.stroke
this.Pshrink = this.shrink
cursor(HAND)
}
grabberClose.onHoverEnd = function(){
this.Pstroke = this.stroke
this.Pshrink = this.shrink
cursor()
}
grabberClose.onPressBegin = function(){
this.Pstroke = this.stroke
this.Pshrink = this.shrink
}
grabberClose.onPressEnd = function(){
if(grabberClosed){
if(grabberPos == 8 && furnaceChuteOre == null) {
grabberClosed = false
furnaceChuteOre = grabberOre
chuteDropTimer.value = 0
chuteOrigin = 21 + grabberHeight
grabberOre = null
if(tutorialIndex == 4) tutorialIndex ++
}
}else{
if(grabberPos != 8 && grabberHeight == 20) {
if(hopperOres[grabberPos] != undefined && grabberPos > oresToShift){
grabberClosed = true
grabberOre = hopperOres[grabberPos]
hopperOres[grabberPos] = undefined
if(tutorialIndex == 1) tutorialIndex++
}
}
}
}
grabberClose.onPress = function(){
}
let assemblerButton = new Button("box",277,190)
assemblerButton.active = true
assemblerButton.hidden = false
assemblerButton.width = 25
assemblerButton.height = 25
assemblerButton.shrink = 0
assemblerButton.Pshrink = 0
assemblerButton.stroke = [0,230,180]
assemblerButton.Pstroke = [0,230,180]
assemblerButton.fill = [230,0,0]
assemblerButton.strokeWeight = 0
assemblerButton.text = ""
assemblerButton.textSize = 15
assemblerButton.triangleSize = 10
assemblerButton.triangleRotation = Math.PI
assemblerButton.render = function(){
let x = this.x
let y = this.y
let w = this.width
let h = this.height
let s = this.shrink
// animations
let Ptimer = this.timeSincePressedChange
let Htimer = min(this.timeSinceHoverChange, Ptimer)
this.Pstroke = color(this.Pstroke)
if(this.hover && !this.pressed){ // when hovered over
cursor(HAND)
this.shrink = Clerp(this.Pshrink, 0, Htimer*5)
this.stroke = ClerpColor(this.Pstroke, col4, Htimer*5)
this.fill = [180,0,0]
}else if(this.pressed){ // when clicked
this.shrink = Clerp(this.Pshrink, 0, Htimer*8)
this.stroke = ClerpColor(this.Pstroke, col4, Ptimer*5)
this.fill = [250,0,0]
}else{ // when not hovered or clicked
this.shrink = Clerp(this.Pshrink, 0, Htimer*5)
this.stroke = ClerpColor(this.Pstroke, col1, Htimer*5)
if((alAdded == null && !assemblerInserting && !assemblerProcessing && assemblerItems.length == 0 && assemblyLine.length > 0) || (assemblerItems.length > 0 && assemblerOutput == null && assemblingItem == null && !assemblerProcessing && !assemblerInserting) || (assemblerTimer.value >= 5 && assemblerItems.length > 0 && assemblerProcessing)){
this.fill = [255,0,0]
}else{
this.fill = [210,0,0]
}
}
fill(100)
stroke(0)
strokeWeight(2)
rect(x-5,y-5,w+10,h+10)
fill(this.fill)
stroke(this.stroke)
strokeWeight(this.strokeWeight)
rect(x + s,y + s,w - s*2,h - s*2)
noStroke()
fill(this.stroke)
textAlign(CENTER,CENTER)
textSize(this.textSize)
text(this.text, x,y,w,h)
}
assemblerButton.onHoverBegin = function(){
this.Pstroke = this.stroke
this.Pshrink = this.shrink
cursor(HAND)
}
assemblerButton.onHoverEnd = function(){
this.Pstroke = this.stroke
this.Pshrink = this.shrink
cursor()
}
assemblerButton.onPressBegin = function(){
this.Pstroke = this.stroke
this.Pshrink = this.shrink
}
assemblerButton.onPressEnd = function(){
if(alAdded == null && !assemblerInserting && !assemblerProcessing && assemblerItems.length == 0 && assemblyLine.length > 0){
assemblerInserting = true
assemblyInsertTimer.value = 0
assemblerItems = assemblyLine
}
if(assemblerItems.length > 0 && assemblerOutput == null && assemblingItem == null && !assemblerProcessing && !assemblerInserting){
let itemToAssemble = null
for(let [Key, value] of Object.entries(products)){
let matches = true
if(assemblerItems.length != value.parts.length) matches = false
for(let i = 0; i < assemblerItems.length; i++){
if(assemblerItems[i] != value.parts[i]) matches = false
}
if(matches) itemToAssemble = Key
}
if(itemToAssemble == null) itemToAssemble = "trash"
assemblingItem = itemToAssemble
assemblerTimer.value = 0
assemblerProcessing = true
}
if(assemblerTimer.value >= 5 && assemblerItems.length > 0 && assemblerProcessing){
assemblerProcessing = false
assemblerOutput = assemblingItem
assemblingItem = null
assemblerItems = []
truckConveyorItem = assemblerOutput
truckConveyorTimer.value = 0
// DUMP
assemblerOutput = null
}
}
assemblerButton.onPress = function(){
}
let grabberSlider = new Slider("box",false, 20, 60)
grabberSlider.Slength = 90
grabberSlider.fill = [220]
grabberSlider.stroke = [0]
grabberSlider.strokeWeight = 2
grabberSlider.render = function(){
fill(this.hover||this.pressed?this.stroke:this.fill)
stroke(((round(time)%2==0 && tutorialIndex == 0) || tutorialIndex == 2)?[0,50,255]:this.stroke)
strokeWeight(this.strokeWeight)
line(this.x,this.y,this.x + this.Slength,this.y)
if(this.smooth){
rect(this.x - this.width/2 + this.value, this.y - this.height/2, this.width, this.height)
}else{
rect(this.x - this.width/2 + (this.value * (this.Slength / this.segments)), this.y - this.height/2, this.width, this.height)
}
}
grabberSlider.onUpdate = function(){
if(tutorialIndex == 0 && this.value == this.Slength) tutorialIndex ++
if(tutorialIndex == 2 && this.value == 0) tutorialIndex ++
}
let furnaceDial = new Dial(false, 220, 100)
furnaceDial.segments = 2
furnaceDial.originOffset = 90
furnaceDial.radius = 20
furnaceDial.minAngle = 135
furnaceDial.maxAngle = 225
furnaceDial.stroke = [255]
furnaceDial.strokeWeight = 1.5
furnaceDial.fill = [0]
furnaceDial.value = 1
furnaceDial.render = function(){
angleMode(DEGREES)
fill(this.fill)
noStroke()
circle(this.x, this.y, this.radius*2)
let C = this.cos
let S = this.sin
stroke(this.stroke)
strokeWeight(this.strokeWeight)
line(this.x + C*(this.radius/2), this.y + S*(this.radius/2),
this.x + C*(this.radius), this.y + S*(this.radius))
// marker lines
stroke(0)
line(this.x + cos(-45)*(this.radius), this.y + sin(-45)*(this.radius)+1, this.x + cos(-45)*(this.radius), this.y + sin(-45)*(this.radius) - 5)
line(this.x + cos(-90)*(this.radius), this.y + sin(-90)*(this.radius)+1, this.x + cos(-90)*(this.radius), this.y + sin(-90)*(this.radius) - 5)
line(this.x + cos(-135)*(this.radius), this.y + sin(-135)*(this.radius)+1, this.x + cos(-135)*(this.radius), this.y + sin(-135)*(this.radius) - 5)
// labels
textAlign(CENTER,CENTER)
noStroke()
fill(0)
textSize(10)
text("+",this.x + cos(-45)*(this.radius), this.y + sin(-45)*(this.radius) - 10)
text("o",this.x + cos(-90)*(this.radius), this.y + sin(-90)*(this.radius) - 10)
text("-",this.x + cos(-135)*(this.radius), this.y + sin(-135)*(this.radius) - 10)
angleMode(RADIANS)
}
let laytheLever = new Slider("box",true, 25, 250)
laytheLever.Slength = 20
laytheLever.value = 5
laytheLever.smooth = false
laytheLever.segments = 5
laytheLever.height = 10
laytheLever.fill = [160]
laytheLever.stroke = [0]
laytheLever.strokeWeight = 2
laytheLever.render = function(){
fill(this.hover?this.stroke:this.fill)
stroke(this.stroke)
strokeWeight(this.strokeWeight)
if(this.vertical){
line(this.x,this.y,this.x,this.y - this.Slength)
if(this.smooth){
rect(this.x - this.width/2, this.y - this.height/2 - this.value, this.width, this.height)
}else{
rect(this.x - this.width/2, this.y - this.height/2 - (this.value * (this.Slength / this.segments)), this.width, this.height)
}
}
}
function generateOre(){
let oreList = []
for(let [Key, value] of Object.entries(ores)){
for(let i = 0; i < value.frequency; i++){
oreList.push(Key)
}
}
if(round(random(1,100)) == 50) oreList = ["greggium"]
return random(oreList)
}
function setup() {
createCanvas(400, 400);
for(let i = 0; i < 8; i++){
hopperOres[i] = generateOre()
}
generateOrder()
}
let grabberLerpTimer = new Timer()
let miningTimer = new Timer()
let furnaceChuteTimer = new Timer()
let chuteDropTimer = new Timer()
oreConveyorTimer = new Timer()
furnaceTimer = new Timer()
let laytheTimer = new Timer()
let assemblyLineTimer = new Timer()
assemblyInsertTimer = new Timer()
assemblerTimer = new Timer()
let truckConveyorTimer = new Timer()
truckTimer = new Timer()
truckWrongTimer = new Timer()
let gregTimer = new Timer()
gregX = 0
gregY = 0
gregS = 10
function gregIfDraw(x, y){
noStroke()
fill(0)
textAlign(CENTER,CENTER)
textSize(gregS)
text("Greg", x + gregX, y + gregY)
}
let time = 0
function draw() {
background(220);
let dt = round(deltaTime/1000,3)
time += dt
// mine
if(drillOre == null){
drillOre = generateOre()
}
if(nextOre == null){
nextOre = drillOre
drillOre = null
}
if(miningTimer.value >= 3){
let lastSpace = -1
for(let i = 0; i < 8; i++){
if(hopperOres[i]==undefined) lastSpace = i
}
if(lastSpace > -1){
oresToShift = lastSpace
for(let i = lastSpace; i > 0; i--){
let sav = hopperOres[i]
hopperOres[i] = hopperOres[i-1]
hopperOres[i-1] = sav
}
hopperOres[0] = nextOre
nextOre = null
}else{
oresToShift = -1
}
miningTimer.value = 0
}
// claw panel
strokeWeight(2)
stroke(20)
line(125,12,200,12)
stroke(200,0,0)
line(125,14,200,14)
stroke(0,160,0)
line(125,16,200,16)
stroke(0)
strokeWeight(2)
fill(160)
rect(5,5,120,70)
// hopper background
noStroke()
fill(200)
rect(200,10,180,50)
// claw rail
stroke(0)
strokeWeight(1)
fill(100)
rect(200,7,180,6)
stroke(70)
strokeWeight(2)
line(210,10,370,10)
// drill
stroke(0)
fill(40)
rect(140, 20, 55, 40)
rect(195, 40, 5, 20)
noStroke()
fill(100)
circle(160, 40, 25)
stroke(30)
strokeWeight(2)
for(let i = 0; i < 4; i++){
line(160 + cos((time/2)*PI + (PI/4)*i)*(25/2), 40 + sin((time/2)*PI + (PI/4)*i)*(25/2),
160 + cos((time/2)*PI + PI + (PI/4)*i)*(25/2), 40 + sin((time/2)*PI + PI + (PI/4)*i)*(25/2))
}
noStroke()
fill(80)
circle(160,40,15)
stroke(20)
strokeWeight(2)
for(let i = 0; i < 4; i++){
line(160 + cos(-(time/2)*PI + (PI/4)*i)*(25/4), 40 + sin(-(time/2)*PI + (PI/4)*i)*(25/4),
160 + cos(-(time/2)*PI + PI + (PI/4)*i)*(25/4), 40 + sin(-(time/2)*PI + PI + (PI/4)*i)*(25/4))
}
noStroke()
fill(60)
circle(160,40,5)
// furnace background
noStroke()
fill(80)
rect(360,39,20,121)
fill(70)
rect(249,130,111,30)
fill(55)
rect(333,130,15,30)
// furnace coils
let r = (furnaceTempreature/500)*255
let g = ((furnaceTempreature-500)/500)*255
let b = ((furnaceTempreature-1000)/500)*255
strokeWeight(3)
translate(0.5,0.5)
stroke(r,g,b)
strokeCap(PROJECT)
line(255,155,285,155)
line(285,155,285,150)
line(285,150,255,150)
line(255,150,255,145)
line(255,145,285,145)
line(285,145,285,140)
line(285,140,255,140)
line(255,140,255,135)
line(255,135,320,135)
line(320,135,320,140)
line(320,140,290,140)
line(290,140,290,145)
line(290,145,320,145)
line(320,145,320,150)
line(320,150,290,150)
line(290,150,290,155)
line(290,155,320,155)
translate(-0.5,-0.5)
// materials pipe
stroke(0)
strokeWeight(2)
fill(100)
rect(283,160,10,20)
rect(140,170,153,10)
noStroke()
rect(284,162,8,10)
fill(60)
stroke(0)
rect(275,160,25,5)
rect(165,165,5,20)
// draw ores
noStroke()
fill(100)
for(let i = 0; i < 8; i++){
if(hopperOres[i] != undefined){
fill(ores[hopperOres[i]].color)
if(i <= oresToShift){
push()
beginClip()
rect(200,10,200,60)
endClip()
rect(202 + Clerp(i*20 - 20, i*20, miningTimer.value/3), 42, 16, 16)
if(hopperOres[i] == "greggium") gregIfDraw(202 + Clerp(i*20 - 20, i*20, miningTimer.value/3), 42)
pop()
}else{
rect(202 + i*20, 42, 16, 16)
if(hopperOres[i] == "greggium") gregIfDraw(202 + i*20, 42)
}
}
}
// outlines
strokeWeight(2)
stroke(0)
line(200,10,200,60)
line(200,60,360,60)
line(360,130,360,40)
line(380,160,380,10)
// grabber
if(grabberPos != grabberTarget) grabberSlider.value = 0
grabberHeight = (grabberSlider.value/grabberSlider.Slength)*20
line(210+grabberPos*20,10,210+grabberPos*20,20 +
grabberHeight)
//ore in bucket
noStroke()
if(grabberOre != null){
fill(ores[grabberOre].color)
rect(201+grabberPos*20,21 + grabberHeight, 18,18)
if(grabberOre == "greggium") gregIfDraw(201+grabberPos*20,21 + grabberHeight)
}
noFill()
stroke(0)
strokeWeight(2)
push()
if(!grabberClosed){
fill(220)
stroke(220)
strokeWeight(3)
beginClip()
rect(198+grabberPos*20,18 + grabberHeight, 24,14)
endClip()
}
noFill()
stroke(0)
strokeWeight(2)
rect(201+grabberPos*20,21 + grabberHeight, 18,18)
pop()
grabberPos = Clerp(prevGrabberPos,grabberTarget,grabberLerpTimer.value*2)
// furnace
line(380, 160, 250, 160)
line(250,160,250,130)
line(250,130,360,130)
// chute ore
if(furnaceChuteOre != null){
fill(ores[furnaceChuteOre].color)
let pos = Clerp(chuteOrigin, 142, pow(chuteDropTimer.value,2))
noStroke()
rect(362, pos, 16, 16)
if(furnaceChuteOre == "greggium") gregIfDraw(362, pos)
}
if(chuteDropTimer.value > 1 && furnaceOre == null && furnaceChuteOre != null){
oreConveyorTimer.value = 0
furnaceOriginalMaterials = 0
for(let [Key, value] of Object.entries(ores[furnaceChuteOre].composition)){
furnaceOriginalMaterials += value
}
furnaceOre = structuredClone(ores[furnaceChuteOre])
furnaceChuteOre = null
}
// gauge
noFill()
stroke(0)
rect(250, 85, 100, 30)
if(furnaceOre != null){
for(let [Key, value] of Object.entries(furnaceOre.composition)){
if(value > 0){
let meltTemp = metals[Key].meltingPoint
let pos0 = 255 + round((meltTemp)/furnaceMaxTemp * 90)
let pos1 = 255 + round((meltTemp-50)/furnaceMaxTemp * 90)
let pos2 = 255 + round((meltTemp+50)/furnaceMaxTemp * 90)
textSize(10)
noStroke()
fill(0)
textAlign(CENTER, BOTTOM)
text(metals[Key].symbol, pos0, 84)
stroke(0,120,0)
strokeWeight(2)
line(pos1, 87, pos2, 87)
line(pos1, 113, pos2, 113)
}
}
}
stroke(0)
if(furnaceOverheat) furnaceDial.value = 0
if(furnaceDial.value == 0) furnaceTempreature += -50 * dt
if(furnaceDial.value == 1) furnaceTempreature += -20 * dt
if(furnaceDial.value == 2) furnaceTempreature += 50 * dt
if(furnaceTempreature > furnaceMaxTemp) furnaceOverheat = true
if(furnaceTempreature <= 0) {
furnaceOverheat = false
furnaceTempreature = 0
}
if(furnaceTempreature > 1350) stroke(255,100,0)
if(furnaceOverheat) stroke(furnaceTempreature/furnaceMaxTemp * 255 + 100, 0, 0)
line(255, 100, 345, 100)
line(255 + round(furnaceTempreature/furnaceMaxTemp * 90), 90,
255 + round(furnaceTempreature/furnaceMaxTemp * 90), 110)
textAlign(CENTER,TOP)
textSize(7)
fill(0)
stroke(0)
strokeWeight(1)
line(255,115,255,120)
noStroke()
text("20°C",255,121)
stroke(0)
strokeWeight(1)
line(285,115,285,120)
noStroke()
text("500°C",285,121)
stroke(0)
strokeWeight(1)
line(315,115,315,120)
noStroke()
text("1000°C",315,121)
stroke(0)
strokeWeight(1)
line(345,115,345,120)
noStroke()
text("1500°C",345,121)
// furnace ore
if(furnaceTimer.value >= 1){
if(furnaceOre != null){
for(let [Key, value] of Object.entries(furnaceOre.composition)){
if(value > 0 && furnaceTempreature >= metals[Key].meltingPoint - 50 && furnaceTempreature <= metals[Key].meltingPoint + 50){
furnaceOre.composition[Key] --
materials[Key] ++
}
}
}
furnaceTimer.value = 0
}
let pos = Clerp(362, 280, oreConveyorTimer.value/2)
if(furnaceOre != null){
noStroke()
fill(furnaceOre.color)
let furnaceMaterials = 0
for(let [Key, value] of Object.entries(furnaceOre.composition)){
furnaceMaterials += value
}
let Size = 16 * (furnaceMaterials/furnaceOriginalMaterials)
rect(pos, 142 + 16 - Size, 16, Size)
if(furnaceOre.color[0] == 255) gregIfDraw(pos, 142)
if(furnaceMaterials == 0) furnaceOre = null
}
// part making
fill(130)
stroke(0)
strokeWeight(2)
rect(5, 80, 160, 138)
// selected output
stroke(0)
strokeWeight(2)
fill(100)
rect(40,195, 90, 24)
textAlign(LEFT, CENTER)
noStroke()
fill(0)
textSize(18)
text("output:",45,195, 85, 25)
fill(220)
rect(105, 197, 20, 20)
if(selectedPart != null){
parts[selectedPart].draw(105,197)
}
// laythe
stroke(0)
strokeWeight(2)
fill(80)
rect(10,220, 150, 40)
noStroke()
fill(50)
rect(45,225, 100,20)
fill(120)
rect(45,230, 100,10)
let aoff = 0
if(processing){
aoff = -cos(laytheTimer.value * PI)*35 + 35
}else if(time > 8.1 && laytheTimer.value < 8){
aoff = Clerp(70,0,((laytheTimer.value-5)/3))
}
fill(150)
noStroke()
rect(55 + aoff,238, 5, 7)
rect(130 - aoff,225, 5, 7)
if(processing){
fill(255,240,0)
stroke(255,240,0)
strokeWeight(2)
point(55 + aoff + random(0,5),238)
point(130 - aoff + random(0,5),232)
}
// progress bar
stroke(0)
strokeWeight(2)
line(50,250,140,250)
if(processing){
stroke(0,200,0)
line(50,250, Clerp(50, 140, laytheTimer.value/5),250)
}else if(laytheOutput != null){
stroke(0,200,0)
line(50,250,140,250)
}
if(!processing && selectedPart != null && laytheLever.value == 0 && laytheOutput == null){
let canMake = true
for(let i = 0; i < parts[selectedPart].materials.length; i++ ){
if(materials[parts[selectedPart].materials[i]] < 1) canMake = false
}
if(canMake){
for(let i = 0; i < parts[selectedPart].materials.length; i++ ){
materials[parts[selectedPart].materials[i]] --
}
laytheLever.active = false
laytheLever.hover = false
laytheLever.pressed = false
cursor()
processing = true
laytheTimer.value = 0
fabricatingPart = selectedPart
}
}
if(processing && laytheTimer.value >= 5){
laytheLever.active = true
laytheOutput = fabricatingPart
fabricatingPart = null
processing = false
for(let [Key, value] of Object.entries(selectedMaterials)){
selectedMaterials[Key] = false
}
}
if(laytheOutput != null && laytheLever.value == 5 && assemblyLine.length < 5){
assemblyLine.push(laytheOutput)
laytheOutput = null
assemblyLineTimer.value = 0
alAdded = assemblyLine.length - 1
selectedPart = checkPart()
}
// assembly
// conveyor
strokeWeight(2)
stroke(0)
line(160, 250, 260, 250)
for(let i = 0; i < assemblyLine.length; i++){
if(i == alAdded){
push()
beginClip()
rect(161,220,98,60)
endClip()
parts[assemblyLine[i]].draw(Clerp(140, 240 - (i*20), assemblyLineTimer.value/3), 230)
pop()
}else{
if(assemblerInserting){
push()
beginClip()
rect(161,220,98,60)
endClip()
parts[assemblyLine[i]].draw(240 - (i*20) + Clerp(0,100,assemblyInsertTimer.value/3), 230)
pop()
}else{
parts[assemblyLine[i]].draw(240 - (i*20), 230)
}
}
}
if(assemblyLineTimer.value >= 3) alAdded = null
// assembler
stroke(0)
strokeWeight(2)
fill(100)
rect(260,220,60,40)
for(let i = 0; i < 5; i++){
noStroke()
if(assemblerInserting){
fill((round(time*2)%5==i)?[0,200,0]:[0])
}else{
if(assemblingItem){
fill((assemblerTimer.value>=i+1)?[0,200,0]:[0])
}else{
if(assemblyInsertTimer.value > 3 && assemblerItems.length > 0){
fill((round(time)%2==0)?[0,200,0]:[0])
}else{
fill(0)
}
}
}
rect(264 + (i*11), 245,8,10)
}
if(assemblyInsertTimer.value > 3 && assemblerInserting){
assemblyLine = []
assemblerInserting = false
}
// truck
// conveyor
stroke(0)
strokeWeight(2)
line(320,250,340,250)
// truck
push()
if(truckDriving) translate(Clerp(0,60,truckTimer.value/3) - Clerp(0,60, (truckTimer.value-5)/3) ,0)
noStroke()
fill(100)
rect(340, 210, 60, 45)
fill(60)
stroke(60)
strokeWeight(2)
circle(350, 260, 10)
circle(362, 260, 10)
circle(400, 260, 10)
let i = 0
for(let [Key, value] of Object.entries(truckOrder)){
products[Key].draw(345,212 + i*20)
noStroke()
fill(0)
textAlign(LEFT, CENTER)
textSize(12)
text(truckInventory[Key] + "/" + value, 370,214 + i*20, 30,20)
i++
}
if(truckConveyorItem != null && truckConveyorTimer.value <= 3){
push()
beginClip()
rect(321,220,19,30)
endClip()
products[truckConveyorItem].draw(300 + Clerp(0,60,truckConveyorTimer.value/3),230)
pop()
}
pop()
if(truckConveyorItem != null && truckConveyorTimer.value > 1 && !extremelyLoudIncorrectBuzzer){
let correct = false
for(let [Key, value] of Object.entries(truckOrder)){
if(truckConveyorItem == Key){
if(truckInventory[Key] < truckOrder[Key]) correct = true
}
}
if(!correct){
extremelyLoudIncorrectBuzzer = true
truckWrongTimer.value = 0
truckConveyorItem = null
}
}
if(truckConveyorItem != null && truckConveyorTimer.value > 3){
if(truckInventory[truckConveyorItem] < truckOrder[truckConveyorItem]) truckInventory[truckConveyorItem] ++
truckConveyorItem = null
}
if(extremelyLoudIncorrectBuzzer){
strokeWeight(2)
stroke(255,0,0)
line(322,232, 338,248)
line(322,248, 338,232)
if(truckWrongTimer.value > 2) extremelyLoudIncorrectBuzzer = false
}
let orderFilled = true
for(let [Key, value] of Object.entries(truckOrder)){
if(truckInventory[Key] != value) orderFilled = false
}
if(orderFilled && !truckDriving){
truckTimer.value = 0
truckDriving = true
orderGenerated = false
}
if(truckDriving && truckTimer.value > 3 && !orderGenerated){
generateOrder()
orderGenerated = true
money += 50
}
if(truckDriving && truckTimer.value > 8){
truckDriving = false
}
noStroke()
fill(0,180,0)
textSize(20)
textAlign(LEFT, CENTER)
// money counter
text("$ " + money, 340, 180, 200, 20)
// directions
stroke(0)
strokeWeight(2)
line(0,270,400,270)
line(170,270,170,400)
line(270,270,270,400)
noStroke()
fill(0)
textSize(16)
text("Parts", 10, 283)
textSize(10)
i = 0
for(let [Key,value] of Object.entries(parts)){
value.draw(10 + floor(i/5)*80, 290 + (i%5)*20)
let string = "= "
for(let m = 0; m < value.materials.length; m++){
if(m == 0){
string += metals[value.materials[m]].symbol
}else{
string += "+" + metals[value.materials[m]].symbol
}
}
text(string, 32 + floor(i/5)*80, 300 + (i%5)*20)
i++
}
textAlign(LEFT,CENTER)
textSize(16)
text("Products", 280, 283)
textAlign(RIGHT, CENTER)
textSize(14)
i = 0
for(let [Key,value] of Object.entries(products)){
if(Key != "trash"){
value.draw(375 + floor(i/5)*-80, 290 + (i%5)*20)
for(let m = 0; m < value.parts.length; m++){
parts[value.parts[m]].draw(340 - m*20 + floor(i/5)*-80, 290 + (i%5)*20)
}
text("->", 375 + floor(i/5)*-80, 300 + (i%5)*20)
}
i++
}
textSize(10)
text("... 3rd 2nd 1st", 358, 395)
// ore info
textSize(16)
noStroke()
fill(0)
textAlign(LEFT, CENTER)
text("Ore Info", 175, 283)
if(round(grabberPos) < 8 && hopperOres[round(grabberPos)] != undefined && grabberOre == null){
let ore = hopperOres[round(grabberPos)]
fill(ores[ore].color)
rect(177,300,16,16)
if(ore == "greggium") gregIfDraw(175,298)
textAlign(LEFT, CENTER)
fill(0)
textSize(10)
text(ore, 197, 308)
i = 0
for(let [Key, value] of Object.entries(ores[ore].composition)){
text(value + " " + metals[Key].symbol,175, 325 + i*10)
i++
}
}else if(grabberOre != null){
let ore = grabberOre
fill(ores[ore].color)
rect(177,300,16,16)
if(ore == "greggium") gregIfDraw(175,298)
textAlign(LEFT, CENTER)
fill(0)
textSize(10)
text(ore, 197, 308)
i = 0
for(let [Key, value] of Object.entries(ores[ore].composition)){
text(value + " " + metals[Key].symbol,175, 325 + i*10)
i++
}
}else{
textSize(12)
text("N/A",175,308)
}
furnaceDial.draw()
// tutorial guides
if(tutorialIndex == 5){
noFill()
stroke(0,50,255)
strokeWeight(2)
rect(225,80,15,40)
if(furnaceDial.value == 2) tutorialIndex ++
}
if(tutorialIndex == 6){
noFill()
stroke(0,50,255)
strokeWeight(2)
rect(345,212,55,20)
// highlight objectives
i = 0
for(let [Key, value] of Object.entries(truckOrder)){
if(i == 0){
let s = 0
for(let [Key2,value2] of Object.entries(products)){
if(Key2 != "trash" && Key2 == Key){
neededPart = value2.parts[tutorialSubIndex]
rect(340 - tutorialSubIndex*20, 290 + s*20,20,20)
}
s++
}
}
i++
}
i = 0
for(let [Key,value] of Object.entries(parts)){
if(Key == neededPart){
rect(10 + floor(i/5)*80, 290 + (i%5)*20, 80,20)
}
i++
}
let canMake = false
let correct = 0
if(selectedPart != null){
for(let i = 0; i < parts[selectedPart].materials.length; i++ ){
if(materials[parts[selectedPart].materials[i]] > 0 && selectedPart == neededPart) correct++
}
if(correct == parts[selectedPart].materials.length) canMake = true
}
if(canMake && laytheLever.value > 0 && laytheOutput == null){
rect(13,222,24,36)
fill(0,50,255)
noStroke()
textAlign(CENTER,CENTER)
textSize(10)
text("pull",25,265)
}
if(laytheOutput != null){
rect(13,222,24,36)
fill(0,50,255)
noStroke()
textAlign(CENTER,CENTER)
textSize(10)
text("pull",25,210)
}
if(assemblyLine.length > tutorialSubIndex){
tutorialSubIndex ++
}
let product
i = 0
for(let [Key, value] of Object.entries(truckOrder)){
if(i == 0){
product = Key
}
i++
}
if(tutorialSubIndex == products[product].parts.length){
tutorialIndex ++
}
assemblerButton.draw()
line(277-10,190-10,277-10,190+10)
fill(0,50,255)
noStroke()
textAlign(CENTER,CENTER)
textSize(10)
text("process ores for more materials", 290,30)
if(furnaceTempreature > 1350){
noFill()
stroke(0,50,255)
strokeWeight(2)
rect(200,80,15,40)
}
}else{
neededPart = null
}
if(tutorialIndex == 7){
assemblerButton.draw()
if((alAdded == null && !assemblerInserting && !assemblerProcessing && assemblerItems.length == 0 && assemblyLine.length > 0) || (assemblerItems.length > 0 && assemblerOutput == null && assemblingItem == null && !assemblerProcessing && !assemblerInserting) || (assemblerTimer.value >= 5 && assemblerItems.length > 0 && assemblerProcessing)){
noFill()
stroke(0,50,255)
strokeWeight(2)
rect(273,186,33,33)
}
if(truckConveyorItem != null){
tutorialIndex ++
}
}
if(gregTimer.value > 0.25){
gregTimer.value = 0
gregX = round(random(-5,25))
gregY = round(random(-5,25))
gregS = round(random(5,15))
}
updateTimers()
}