morepurplemorebetter / MPMBs-Character-Record-Sheet

MorePurpleMoreBetter's D&D 5e Character Record Sheet
https://www.flapkan.com
GNU General Public License v3.0
372 stars 352 forks source link

AllPsionicClasses is undefined, thisWeapon is undefined, CurrentWeapons.compKnown is undefined #45

Closed Oldcustard closed 6 years ago

Oldcustard commented 6 years ago

I'm not quite sure how to replicate the issue in a fresh sheet, but I have a currently have a sheet which will not calculate any weapon attack or damage dice, resulting in the following error when I change any field:

TypeError: CurrentWeapons.known[ArrayNmbr] is undefined
5224:Document-Level:Functions2
TypeError: thisWeapon is undefined
5419:Document-Level:Functions2
TypeError: CurrentWeapons.compKnown[prefix] is undefined
5418:Document-Level:Functions2
TypeError: CurrentWeapons.compKnown[prefix] is undefined
5418:Document-Level:Functions2
TypeError: thisWeapon is undefined
5419:Document-Level:Functions2
TypeError: CurrentWeapons.compKnown[prefix] is undefined
5418:Document-Level:Functions2
TypeError: CurrentWeapons.compKnown[prefix] is undefined
5418:Document-Level:Functions2
TypeError: thisWeapon is undefined
5419:Document-Level:Functions2
TypeError: CurrentWeapons.compKnown[prefix] is undefined
5418:Document-Level:Functions2
TypeError: CurrentWeapons.compKnown[prefix] is undefined
5418:Document-Level:Functions2
TypeError: thisWeapon is undefined
5419:Document-Level:Functions2
TypeError: thisWeapon is undefined
5419:Document-Level:Functions2

Additionally, the menu does not appear when pressing the "Spell Sheet Options" button, resulting in:

TypeError: AllPsionicClasses is undefined
3634:Document-Level:FunctionsSpells

I am using a custom class and subclass script, so I'm not quite sure if it's related to that. Using version 12.999, thanks in advance.

morepurplemorebetter commented 6 years ago

This is most likely related to the custom class and subclass script you mention, as this behaviour is not something that happens with a sheet that has nothing imported. Thus, I suggest fixing the import script. I would take a look at it if you had provided it, but without it I can't help you get to the bottom of it. Is it one of the scripts in this repository? If not, I recommend contacting the creator of the script.

Oldcustard commented 6 years ago

I have written the script myself, and am unsure as to what the error might be. It's not complete yet but should be (as far as I can tell) compatible in its current form.

var iFileName = "Wayfarer.js";

ClassList["wayfarer"] = {

    regExpSearch: /wayfarer/i,

    name: "Wayfarer",

    source: ["HB", 0],

    primaryAbility: "\n \u2022 Wayfarer: Charisma;",

    prereqs: "\n \u2022 Wayfarer: Charisma 13;",

    die: 6,

    improvements: [0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5],

    saves: ["Con", "Cha"],

    skills : ["\n\n" + toUni("Wayfarer") + ": Choose two from Animal Handling, Arcana, Athletics, History, Investigation, Persuasion, and Survival", ""],

    toolProfs: {
        primary: [["Navigator's Tools", ""]]
    },

    armor: [[false, false, false, false], [false, false, false, false]],

    weapons: [[true, false, []], [true, false, []]],

    equipment : "Wayfarer starting equipment:\n \u2022 A light crossbow and 20 bolts -or- any simple weapon;\n \u2022 A component pouch -or- an arcane focus;\n \u2022 A dungeoneer's pack -or- an explorer's pack;\n \u2022 A set of navigator's tools.\n\nAlternatively, choose 4d4 \xD7 10 gp worth of starting equipment instead of both the class' and the background's starting equipment.",

    //subclasses : ["Plane-touch", ["Abyss-touched", "Arborea-touched", "Beastlands-touched", "Elemental Chaos-touched","Elysium-touched", "Feywild-touched", "Mechanus-touched", "Shadowfell-touched"]],

    subclasses: ["Plane-touch", ["Mechanus-touched"]],

    attacks : [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],

    abilitySave: 6,

    spellcastingFactor: 1,

    spellcastingKnown: {
        cantrips : [2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
        spells: "list",
        prepared: true
    },

    spellcastingList: {
        class: "any"
    },

    features : {
        "landmark" : {
            name: "Landmark",
            source: ["HB", 0],
            minlevel: 1,
            description: "\n   " + "As an action, I can focus on a point I see, and then once set, I can use an action to learn the direction and approximate distance to my landmark, provided I am on the same plane of existence as it."
        },

        "spellcasting" : {
            name: "Spellcasting",
            source: ["HB", 0],
            minlevel: 1,
            description : "\n   " + "I can cast prepared wayfarer cantrips/spells, using Charisma as my spellcasting ability" + "\n   " + "I can use an arcane focus as a spellcasting focus" + "\n   " + "I can prepare a number of spells equal to my Charisma modifier + my wayfarer level.",
            additional : ["2 cantrips known", "2 cantrips known", "2 cantrips known", "3 cantrips known", "3 cantrips known", "3 cantrips known", "3 cantrips known", "3 cantrips known", "3 cantrips known", "4 cantrips known", "4 cantrips known", "4 cantrips known", "4 cantrips known", "4 cantrips known", "4 cantrips known", "4 cantrips known", "4 cantrips known", "4 cantrips known", "4 cantrips known", "4 cantrips known"]
        },

        "subclassfeature2": {
            name: "Plane-touched",
            source: ["HB", 0],
            minlevel: 2,
            description : "\n   " + "Choose a plane of existence that your soul is bound to" + "\n   " + "Choose either the Abyss, Arborea, the Beastlands, the Elemental Chaos, Elysium, the Feywild, Mechanus, or the Shadowfell."
        },

        "amicus": {
            name: "Amicus",
            source: ["HB", 0],
            minlevel: 2,
            additional: ["", "2 amicus points", "3 amicus points", "3 amicus points", "5 amicus points", "5 amicus points", "6 amicus points", "6 amicus points", "7 amicus points", "7 amicus points", "10 amicus points", "10 amicus points", "11 amicus points", "12 amicus points", "13 amicus points", "13 amicus points", "14 amicus points", "14 amicus points", "15 amicus points", "16 amicus points"],
            description: "\n   " + "I gain an amicus in a form of my choice. It does not need to eat or drink, however it must rest for at least 4 hours to gain the benefits of a long rest. My amicus acts on my initiative, before or after my turn. It can move as a free action by me, and can take an action to allow my amicus to take the attack, dash, disengage, dodge, or help actions, or any action granted by an amicus power, defaulting to dodge action if none specififed. I can dismiss my amicus as an action, and make it reappear within 30ft of me as an action. If I am killed or the amicus drops to 0, it disappears. A 1 hour ritual will return my amicus."
        },

        "spirit link": {
            name: "Spirit link",
            source: ["HB", 0],
            minlevel: 3,
            description: "\n   " + "Whenever my amicus would be reduced to 0 hp within 120ft of me, I can use a reaction to spend a number of hit dice up to my prof bonus. Roll these dice and add CON mod to each roll. My amicus regains hp equal to the total. Additionally, as an action I can see and hear through my amicus, blinding and deafening myself until the start of my next turn."
        }
    }
}

AddSubClass(
    "wayfarer",
    "mechanus",
    {
        regExpSearch: /mechanus/i,
        subname: "Mechanus-touched",
        source: ["HB", 0],
        features: {
            "subclassfeature2": {
                name: "Mechaniform",
                source: ["HB", 0],
                minlevel: 2,
                description : "\n   " + "I summon an amicus from Mechanus, taking the form of a construct. My amicus gains proficiency in two of the following skills:" + "\n   " + "Athletics, Intimidation, Investigation, and Perception" + "\n   " + "In addition, my Amicus and I gain advantage on Charisma ability checks to interact with constructs."
            }
        }
    }
)

I have noticed that when I load up the sheet, or try import the character in to a fresh sheet, I get the following error:

TypeError: ClassSubList[aSubClass] is undefined
4097:Document-Level:FunctionsSpells

Thanks

morepurplemorebetter commented 6 years ago

Your code looks really good, nice work!

The thing that's causing issues with the sheet is tht ytht you've included a reference to a subclass "Mechanus-touched" which is not defined in the ClassSubList. Because you are adding the subclass using the Add subclass() function, you should just leave the second entry of the subclasses attribute an empty array []. It will be filled with references to the subclass objects by the function.

Oldcustard commented 6 years ago

That seems to have fixed it! Makes sense. Thanks heaps for the help MPMB, love your sheet. Best of luck.