Check slected mission status in inspector

Hi,
I’m working in an adventure game where multiple missions can be done and some NPC will react to you different if you complete a concret one. So I need my NPC to check if the player has this mission as acomplished or not but there will be 100+ of tasks to do so I would need to expose the mission to check in the inspector (var missionToCheck = 1; or something)and type directly the one to check in every NPC. Missions are stored in MissionStatus.js as booleans (var mission1 = false, var mission2 = false, etc) and when one is complete it turns true in this script. How to tell my NPC wich boolean to check? If I use a String in the inspector and type mission1 for instance it doesn’t work (or I made a mistake) cause it send a String to check and I need to check the boolean. When the script checks if the String is true or false allways returns true cause it has a String, it doesn’t check if the String says mission1 or mission22 and then check for the boolean, and that’s what I need.

Sorry if it’s too long and for my english.
Thanks in advance

It looks like you are looking for a Hashtable. A hashtable stores a variable number of key and value pairs.

A key is an object that is used like an address, usually a string like a user name: “guest1”, “Leroy Jenkins”, etc.

A value is what you are trying to store, this can be anything. An example is a password: “letmein”, “p4ssw0rd”, etc.

In the username/password example, whenever I input the username to the Hashtable, it will spit out the associated password. I can then check that against what the user said is their password and accept or deny a login request.

Hashtables are very processor efficient usually finding your stored value in a short, constant amount of time no matter how many objects are stored, but can become major memory hogs if there is too much information stored in them.

Here is an example of how to use a Hashtable (in C#, not javascript):


using UnityEngine;
using System.Collections;
using System.Collections.Hashtable;
Class Example : MonoBehaviour
{
    int SIZE = 32;
    void Start()
    {
        //creates an empty Hashtable that can store SIZE key/value pairs
        Hashtable quests = new Hashtable(SIZE);
        //will automatically resize if more than SIZE keys are added.

        //you might need to use this if it says it can't find the namespace
            //System.Collections.Hashtable ... = new System.Collections.Hashtable();

        //creates a new key "MainQuest" and assigns the value -1 to it.
        quests.Add("MainQuest", -1);
        Debug.Log(quests["MainQuest"]);//outputs -1

        //thorws an exception if a key already exists
        try
        {   quests.Add("MainQuest", 0);//throws an exception    }
        catch
        {   Debug.Log("The value \"MainQuest\" already exists!");    }
        Debug.Log(quests["MainQuest"]); //outputs -1

        //can return and change values in this manner
        quests["MainQuest"] = 1;
        Debug.Log(quests["MainQuest"]);//outputs 1

        //can create new key/value pairs in this manner
        quests["SideQuest"] = 2;
        Debug.Log(quests["SideQuest"]);//outputs 2
    }
}

There is a lot more to Hastables than I have written here, but these are the basics to using them.