I have an upgrade in the first layer (call it A) that unlocks an upgrade in the second layer (call it B). Unfortunately, everytime I do a 2nd-layer-reset, upgrade A get removed, and therefore B dissapears until I buy A again. How do i make it so B is permanently unlocked?
I want to see the code of the A and B, and I will try to diagnose the problem.
Upgrade A (the upgrade needed to buy upgrade B):
(contexts, j is the ID for layer 1, jj is the ID for layer 2. Jays is the prestige currency #1, Jayers is the prestige currency #2)
22: {
title: "The Weak Feed The Strong.",
description: "Jays boost Jayers slightly. Also unlocks other Jayer upgrades.",
cost: new Decimal(20),
unlocked(){return hasUpgrade("jj",12)},
effect() {
return (player.j.points.add(1)).pow(0.1)
},
effectDisplay() { return format(upgradeEffect(this.layer, this.id))+"x" },
},
Upgrade B (the upgrade unlocked upon buying upgrade A):
21: {
title: "Exponented!",
description: "Gives a tiny exponent to point gain.",
cost: new Decimal(8),
unlocked(){return hasUpgrade("j",22)}
},
Hmmm, I believe if you buy the upgrade A, it will unlock the upgrade B, and doing a layer 2 reset will remove the upgrade A bought.
You can add the onPrestige(){}
function to the 2nd layer that removes the upgrade A.
If there is any problems regarding the onPrestige(){}
function, feel free to reply!
Use the function below in the 2nd layer.
onPrestige() {
player.j.upgrades = [22];
}
I tried putting the code you gave into layer 2 (more precisely, just under “color”) and nothing seemed to change. I did my layer 2 reset after buying upgrade A, and upgrade B still dissapeared.
I have a different function that would keep, If there is still more problems, I will try to find a way to make it keep the upgrade A.
onReset() {
player.j.upgrades = ["22"];
},
Remove the onPrestige() {}
and replace with the code that I sended above.
Upon putting the code into Layer 2 (the same place i put the first line, right under “color”), it just makes me unable to buy any upgrades in layer 1, whether I have the currency for it or not.
Sorry to bother again, but I really need an answer post-haste. My time with my project is starting to get kind of thin. If it helps, I’m working on Glitch, not Github.
In its unlocked function, make it an or statement with an operand checking if the second layer node is unlocked. Then it won’t disappear when you reset.
hey hey, sorry for the late answer
i dont quite understand what you mean by “operand checking if the second layer node is unlocked”.
if we just checked for the second layer being unlocked, wouldnt that just unlock the upgrade immediatly?
also sorry for my inexpertise but i dont know what an operand is, is it the || things ive been seeing, the && ones, or something else?
ok so ive got an idea on how to do it but im now quite sure how to execute it
1: make a throwaway invisible layer which we only care the points of, on the same power as layer JJ (aka it doesnt get reset by it and layers under it)
2: when upgrade A is bought, you start producing points for said throwaway layer
3: if you have more than 0 points in throwaway layer points, upgrade B is unlocked
if i’m correct, not only would this keep upgrade B due to the throwaway layer points being on the same layer as layer JJ, it would also allow upgrade B to dissapear if we did a (hypothetical) third layer reset, i believe
only thing is i dont know how to do it
SOLVED!!!
Making the invisible throwaway layer wasnt as hard as it was. I simply made a layer, turned it’s layerShown to false and used passiveGeneration (see my ask after this one if you want answer for that) after purchasing j-22