The Basics
If you don't have doReset() in your layer then add it.doReset(layer){
// put code here
},
Generally you don’t want a layer to reset another layer on the same row. You definitely don’t want your layer to be reset every tick by a side layer.
You should also make it possible to reset the layer.
doReset(layer){
if(layers[layer].row <= layers[this.layer].row || layers[layer].row == "side")return;
layerDataReset(this.layer)
/*
that giant if does 2 things
first it gets the resetting layer's row and makes sure
it's higher than the current layer's row
second it gets the resetting layer's row again
and checks if it's a side layer
if either of those are true then it returns
nothing which ends the function
the other line resets the layer
*/
},
Keeping Stuff on Reset
If you want to keep anything on reset you need to change layerDataReset().doReset(){
...
layerDataReset(this.layer, ["upgrades"])
/*
this would let you keep upgrades on reset
*/
},
Of course, you wouldn’t normally want to always keep upgrades on reset. If you want to lock keeping upgrades behind a milestone you do this:
doReset(){
...
let keep = []
// declare keep
if(hasMilestone(<layer>,<id>))keep.push("upgrades")
// check for the milestone and push "upgrades"
// keep is now ["upgrades"] if you got the milestone
layerDataReset(this.layer, keep)
// reset with keep
},
You can also do it with “milestones”, “points”, “buyables”, “challenges”, and any other variable in the player.<layer> object.
The previous code keeps all upgrades on reset. If you don’t want that, you can do this:
doReset(){
...
let keep = []
// declare keep
if(hasMilestone(<layer>, <id>))keep.push(11, 12, 13)
// push the upgrades we want to keep
// keep is now [11,12,13] if you have the milestone
layerDataReset(this.layer)
// reset
player[this.layer].upgrades = keep
// upgrades = keep
},
You can also combine these!
doReset(){
...
let keep = []
let keepupgs = []
// declare keep and keepupgs
if(hasMilestone(<layer>,<id>))keep.push("milestones")
// check for the milestone and push "milestones"
// keep is now ["milestones"] if you got the milestone
if(hasMilestone(<layer>, <id>))keepupgs.push(11, 12, 13)
// push the upgrades we want to keep
// keepupgs is now [11,12,13] if you have the milestone
layerDataReset(this.layer, keep)
// reset with keep
player[this.layer].upgrades = keepupgs
// upgrades = keepupgs
},
Of course there’s more you can do but you should only need this most of the time.