MV Trouble with showing messages in a script call~

Hiiya!~
I have been working with RPG Maker MV for a few years now and I am getting more and more into the coding side of things~
Recently I have been working on some scripts for randomizing some NPCs for my game and I am running into an issue~

I have a base NPC event that calls a function from my plugin via script call that first randomizes some facets of the NPC, then creates an array with some possible dialog choices~ Once that is done it changes the NPC event's trigger to player touch and turns on some self switches so that when that same function is called it then executes none of the setup and only shows a message along with the choices populated earlier. This all works fine~

The problem is when I call another function in the same plugin from the choice call back, none of the messages or choices from this new function will show~
Please help!

Code is below:
Note: "these" accepts "this" as a parameter from the initial event script call so I have easier access to the interpreter~
I have tried calling it directly and there is no change~


Spoiler: Code
JavaScript:
//randomize NPCs
Etchy.npcRandomize = function(eventID, these)
{
  //Get base information 1ST
  //Declare variables
  var mapId = $gameMap._mapId;
  var personalityArray = [];
  var spendingArray = [];
  var quirkArray = [];
  var imageArray = [];
  var randFile = 0;
  var randImage = 0;
  //list personalities
  personalityArray[0] = "Forceful";
  personalityArray[1] = "Tsundere";
  personalityArray[2] = "Genki";
  personalityArray[3] = "Shy";
  personalityArray[4] = "Princess";
  personalityArray[5] = "Idiot";
  personalityArray[6] = "Logical";
  personalityArray[7] = "Sadistic";
  personalityArray[8] = "Depressive";
  personalityArray[9] = "Pervert";
  //list spending
  spendingArray[0] = "Generous";
  spendingArray[1] = "Miserly";
  spendingArray[2] = "Selective";
  spendingArray[3] = "Frugal";
  spendingArray[4] = "Risk Taker";
  spendingArray[5] = "Impulse Buyer";
  spendingArray[6] = "Hoarder";
  spendingArray[7] = "Moron"
  //list quirks
  quirkArray[0] = "Omorashi Kink";
  quirkArray[1] = "Hates Cats";
  //List images
  imageArray[0] = "Actor1";
  imageArray[1] = "Actor2";
  imageArray[2] = "Actor3";
 
  //image handler 2ND
  if(!$gameSelfSwitches.value([mapId, eventID, "A"]))
  {
    //randomize image selection
    randFile = Math.floor(Math.random() * imageArray.length);
    randImage = Math.floor(Math.random() * 7);

    //Change Image
    $gameMap.event(eventID).setImage(imageArray[randFile], randImage);
    $gameSelfSwitches.setValue([mapId, eventID, "A"], true);
  }

  //randomize traits code 3RD
  if(!$gameSelfSwitches.value([mapId, eventID, "B"]))
  {
 
    //randomize traits
 
    $gameMap.event(eventID).personalitySet(spendingArray[Math.floor(Math.random() * spendingArray.length)]);
 
    $gameMap.event(eventID).spendingSet(personalityArray[Math.floor(Math.random() * personalityArray.length)]);
    $gameMap.event(eventID).quirkSet(quirkArray[Math.floor(Math.random() * quirkArray.length)]);
 
    //Set C
    $gameSelfSwitches.setValue([mapId, eventID, "B"], true);
  }

  //action button code FINAL STATE
  if($gameSelfSwitches.value([mapId, eventID, "C"]))
  {
    Etchy.npcActions(mapId, eventID, these);
  }

  //populate action choices and dialog
  if(!$gameSelfSwitches.value([mapId, eventID, "C"]))
  {
    Etchy.populateActions(mapId, eventID, personalityArray, spendingArray, quirkArray)
    //Sets C
    $gameSelfSwitches.setValue([mapId, eventID, "C"], true);
  }

  //change event trigger to action 4TH
  if(!$gameSelfSwitches.value([mapId, eventID, "D"]))
  {
    //changes event trigger to action and sets D
    $gameSelfSwitches.setValue([mapId, eventID, "D"], true);
    $gameMap.event(eventID)._trigger = 0;
  }
 
}

//action button code
Etchy.npcActions = function(mapId, eventID, these)
{
    //Turn off omo system
    $gameSwitches.setValue(1,0);
 

    //Show Text
    $gameMessage.setBackground(0);
    $gameMessage.setPositionType(2);
    $gameMessage.add("THIS IS THE TEXT SHOWN");
 
    //these.setWaitMode('message');
 

    //Show Choices
    $gameMessage.setChoices($gameMap.event(eventID).actionsSetValue(),0,-1);
    $gameMessage.setChoiceBackground(0);
    $gameMessage.setChoicePositionType(0);
    $gameMessage.setChoiceCallback(choiceNum =>
      {
        //call choice handler
        Etchy.choiceHandler(choiceNum, eventID, these);
      }
    );
    // Wait for a choice to be selected
    these.setWaitMode('message');
 
 
 
}


//populate action set randomly
Etchy.populateActions = function(mapId, eventID, personalityArray, spendingArray, quirkArray)
{
  //declare arrays
  potentialActionArray = [];
  purchasableGoodsArray = [
    "Adventuring Equipment",
    "Alchemical Goods",
    "Enchanted Goods",
    "Spice and Food",
    "Luxury Goods",
    "Books",
    "Tools"
  ];
  purchasableGoodsPrices = [
    $gameVariables.value(21),
    $gameVariables.value(22),
    $gameVariables.value(23),
    $gameVariables.value(24),
    $gameVariables.value(25),
    $gameVariables.value(26),
    $gameVariables.value(27)
  ];
  sellableGoodsPrices = [
    Math.floor($gameVariables.value(21)*.75),
    Math.floor($gameVariables.value(22)*.75),
    Math.floor($gameVariables.value(23)*.75),
    Math.floor($gameVariables.value(24)*.75),
    Math.floor($gameVariables.value(25)*.75),
    Math.floor($gameVariables.value(26)*.75),
    Math.floor($gameVariables.value(27)*.75)
  ];
  actionsReady = [];


  //populate potential actions with buy
  for(i = 0; i < purchasableGoodsArray.length; i++)
  {
    potentialActionArray.push("Buy " + purchasableGoodsArray + ": " + purchasableGoodsPrices);
  }
  //populate potential actions with sell
  for(i = 0; i < purchasableGoodsArray.length; i++)
  {
    potentialActionArray.push("Sell " + purchasableGoodsArray + ": " + sellableGoodsPrices);
  }
  //choose 3 to add to action set for this NPC
  for(i = 0; i < 3; i++)
  {
    action = Math.floor(Math.random() * potentialActionArray.length);
    actionsReady.push(potentialActionArray[action]);
    potentialActionArray.splice(action,1);
  }
  //add basic options
  actionsReady.push("Negotiate");
  actionsReady.push("Cancel");
  //Push action set to NPC
  $gameMap.event(eventID).actionsSetSet(actionsReady);


}


//handle choices
Etchy.choiceHandler = function(choiceNum, eventID, these)
{
  //translate to action name
  actions = $gameMap.event(eventID).actionsSetValue();
  chosenAction = actions[choiceNum];

  //split action
  splitAction = chosenAction.split(":");
  baseAction = chosenAction.split(" ");
  if(baseAction[0] == "Buy") //Buy
  {
 
    //Show Text
   
    $gameMessage.setBackground(0);
    $gameMessage.setPositionType(2);
    $gameMessage.add(chosenAction);
    $gameMessage.add("Are you sure?");
   
    these.setWaitMode('message');
   
    //Show Choices
    $gameMessage.setChoices(["Yes", "No"],1,-1);
    $gameMessage.setChoiceBackground(0);
    $gameMessage.setChoicePositionType(0);
    $gameMessage.setChoiceCallback(choiceNum =>
      {
       
        //if yes
        if(choiceNum == 0)
        {
          cost = splitAction[1];
          //check if enough gold
          if($gameParty.gold() >= cost)
          {
            $gameParty.loseGold(cost);
            if(baseAction[1] == "Adventuring")
            {
              $gameParty.gainItem($dataItems[20], 1);
            }
            else if(baseAction[1] == "Alchemical")
            {
              $gameParty.gainItem($dataItems[21], 1);
            }
            else if(baseAction[1] == "Enchanted")
            {
              $gameParty.gainItem($dataItems[22], 1);
            }
            else if(baseAction[1] == "Spice")
            {
              $gameParty.gainItem($dataItems[23], 1);
            }
            else if(baseAction[1] == "Luxury")
            {
              $gameParty.gainItem($dataItems[24], 1);
            }
            else if(baseAction[1] == "Books")
            {
              $gameParty.gainItem($dataItems[25], 1);
            }
            else if(baseAction[1] == "Tools")
            {
              $gameParty.gainItem($dataItems[26], 1);
            }
          }
          else
          {
            //display error
            $gameMessage.setBackground(0);
            $gameMessage.setPositionType(2);
            $gameMessage.add("You don't have enough gold!");
            these.setWaitMode('message');
          }
        }
      }
    );
    these.setWaitMode('message');
  }
  else if(baseAction[0] == "Sell") //Sell
  {
   
  }
  else if(baseAction[0] == "Negotiate") //Negotiate
  {
   
  }
  else //Cancel
  {
   
  }
 
  //turn on omo system
  $gameSwitches.setValue(1,1);
}
Moved to: Learning Javascript

Because you didn't put your code into code tags, certain characters have been interpreted as forum commands, which has messed up the code. It's also difficult to read as there is no indentation.

Could you please remove the script as it is, then add both spoiler tags (so it doesn't take up so much space) and code tags (so it keeps the formatting and doesn't replace anything) then add your script again inside those? Or add it as an attachment.
Just did!~
Thank you for your patience~ First time poster <.<

Original thread: https://forums.rpgmakerweb.com/threads/trouble-with-showing-messages-in-a-script-call.142244/