I’m very new to coding and I need help with Logical Path.
I achieve all goals on the normal screen, but when submitting it, I always die. How do I fix my code?
# Get two secret true/false values from the wizard.
hero.moveXY(14, 24)
secretA = hero.findNearestFriend().getSecretA()
secretB = hero.findNearestFriend().getSecretB()
# If BOTH secretA and secretB are true, take the high path; otherwise, take the low path.
# Check the guide for notes on how to write logical expressions.
secretC = secretA and secretB
if secretC:
hero.moveXY(20, 33)
else:
hero.moveXY(20, 15)
hero.moveXY(26, 24)
# If EITHER secretA or secretB is true, take the high path.
if secretA != "true" or secretB != "true":
hero.moveXY(32, 33)
else:
hero.moveXY(32, 15)
hero.moveXY(38, 24)
# If secretB is NOT true, take the high path.
if secretB != "true":
hero.moveXY(44,33)
else:
hero.moveXY(44, 15)
hero.moveXY(50, 24)
In the first secretC you have the proper format and in the rest you change. Consistency is important. Stick with the way it appears in the first secretC for the subsequent 2. Define what secretC is and then the code what to do with it.
That being said, in the first secretC, you don’t provide values for secretA or secretB. Are they supposed to be true or just exist?
Hey, so my code won’t work. I’m playing as Alejandro the Duelist, and my gear is Steel helmet, chestplate, and shield, plus scaled gloves. the rest is what I should have at this point. This is my code:
// Get two secret true/false values from the wizard.
// Check the guide for notes on how to write logical expressions.
hero.moveXY(14, 24);
var secretA = hero.findNearestFriend().getSecretA();
var secretB = hero.findNearestFriend().getSecretB();
// If BOTH secretA and secretB are true, take the high path; otherwise, take the low path.
var secretC = secretA && secretB;
if (secretC)
hero.moveXY(20, 33);
else
hero.moveXY(20, 15);
hero.moveXY(26, 24);
// If EITHER secretA or secretB is true, take the high path.
var secretD = secretA || secretB;
if (secretD)
hero.moveXY(32, 33);
hero.moveXY(38, 24);
// If secretB is NOT true, take the high path.
var secretE = !secretB;
if (secretE)
hero.moveXY(44, 33);
hero.moveXY(50, 24);