Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

[harlowe] How to set multiple condition for an item with (elseif)?

Hello, another brick wall hit with my story. This time, on a pokemon game I'm trying to get my son to forget about pokemon go.

This code always gets me a female, enven with pokes that shouldn't be female, as their wiki says. Can you spot my mistakes?

Comments

  • The (either: ) macro returns a randomly selected item from the list supplied to it, so if your $species variable equalled "Sawk" you would only have a 1 in 19 chance of it being true in your first (if:) macro.

    What you want to do is to store all the potential male species from your first (either:) macro into an array and then use the Array contains operator to check if the value in your $species variable is contained within that array. You would do the same for each of the other potential species list.

    The following code only includes examples of your "only male", "only female", and "mostly male" potential species lists but you should be able to implement the "only neither", etc... lists yourself.
    {
    (set: $onlyMaleSpecies to (array: "Nidoran♂", "Nidorino", "Nidoking", "Hitmonlee", "Hitmonchan", "Tauros", "Hitmontop", "Volbeat", "Mothim", "Gallade", "Throh", "Sawk", "Rufflet", "Braviary", "Tyrogue", "Latios", "Tornadus", "Thundurus", "Landorus"
    ))
    
    (set: $onlyFemaleSpecies to (array: "Nidoran♀", "Chansey", "Kangaskhan", "Jynx", "Miltank", "Blissey", "Illumise", "Wormadam", "Vespiquen", "Froslass", "Petilil", "Lilligant", "Vullaby", "Mandibuzz", "Flabébé", "Floette", "Florges", "Nidorina", "Nidoqueen", "Smoochum", "Latias", "Happiny", "Cresselia"))
    
    (set: $mostlyMaleSpecies to (array: "Bulbasaur", "Ivysaur", "Venusaur", "Charmander", "Charmeleon", "Charizard", "Squirtle", "Wartortle", "Blastoise", "Eevee", "Vaporeon", "Jolteon", "Flareon", "Omanyte", "Omastar", "Kabuto", "Kabutops", "Aerodactyl", "Snorlax", "Chikorita", "Bayleef", "Meganium", "Cyndaquil", "Quilava", "Typhlosion", "Totodile", "Croconaw", "Feraligatr", "Togetic", "Espeon", "Umbreon", "Treecko", "Grovyle", "Sceptile", "Torchic", "Combusken", "Blaziken", "Mudkip", "Marshtomp", "Swampert", "Lileep", "Cradily", "Anorith", "Armaldo", "Relicanth", "Turtwig", "Grotle", "Torterra", "Chimchar", "Monferno", "Infernape", "Piplup", "Prinplup", "Empoleon", "Cranidos", "Rampardos", "Shieldon", "Bastiodon", "Combee", "Lucario", "Togekiss", "Leafeon", "Glaceon", "Snivy", "Servine", "Serperior", "Tepig", "Pignite", "Emboar", "Oshawott", "Dewott", "Samurott", "Pansage", "Simisage", "Pansear", "Simisear", "Panpour", "Simipour", "Tirtouga", "Carracosta", "Archen", "Archeops", "Zorua", "Zoroark", "Chespin", "Quilladin", "Chesnaught", "Fennekin", "Braixen", "Delphox", "Froakie", "Frogadier", "Greninja", "Tyrunt", "Tyrantrum", "Amaura", "Aurorus", "Sylveon", "Togepi", "Munchlax", "Riolu"))
    
    (set: $sexvalue to (random: 0,255))
    (set: $sex to "")
    
    (set: $species to "Eevee")
    
    (if: $onlyMaleSpecies contains $species)[(set: $sex to "male")]
    (else-if: $onlyFemaleSpecies contains $species)[(set: $sex to "female")]
    (else-if: $mostlyMaleSpecies contains $species)[
    	(if: $sexvalue > 85)[(set: $sex to "male")]
    	(else:)[(set: $sex to "female")]
    ]
    }
    species: $species
    gender: $sex
    sexvalue: $sexvalue
    
    notes:
    a. I moved the checking of the $sexvalue variable to be a child of the related potential species list so that the related (else:) (or in your example the (else-if:)) will only be applied for that particular potential species list and not for all later lists.

    b. You don't have to use the variable names I used for the arrays but the variable names you do should describe the type of items the array in the variable contains.

    c. You may want to rename your $sex variable to $gender so that it better describes that the variable represents.
  • That solved it. Thanks! Anything is better than a small child asking you to wander into a dangerous neighborhood to catch a bunch of pixels.
Sign In or Register to comment.