npcHelper.lua utility file - VanaDev/Vana GitHub Wiki

Table of Contents

npcHelper.lua

Category: Utility Lua-Based Scripts

npc_text_black

Type: number

Notes: Used as a previous color argument value to the text color functions.

npc_text_blue

Type: number

Notes: Used as a previous color argument value to the text color functions.

npc_text_red

Type: number

Notes: Used as a previous color argument value to the text color functions.

npc_text_green

Type: number

Notes: Used as a previous color argument value to the text color functions.

npc_text_purple

Type: number

Notes: Used as a previous color argument value to the text color functions.

npc_text_normal

Type: number

Notes: Used as a previous text decoration argument value to the text decoration functions.

npc_text_bold

Type: number

Notes: Used as a previous text decoration argument value to the text decoration functions.

black

Return(s):

  • formattedText: string
Argument(s):
  • text: string
  • Optional - previousColor: number
Notes: Colors the text appropriately. If previousColor is specified, the code will emit a transition to the specified color at the end of the formatted text.

blue

Return(s):

  • formattedText: string
Argument(s):
  • text: string
  • Optional - previousColor: number
Notes: Colors the text appropriately. If previousColor is specified, the code will emit a transition to the specified color at the end of the formatted text. If not, previousColor is assumed to be black.

red

Return(s):

  • formattedText: string
Argument(s):
  • text: string
  • Optional - previousColor: number
Notes: Colors the text appropriately. If previousColor is specified, the code will emit a transition to the specified color at the end of the formatted text. If not, previousColor is assumed to be black.

green

Return(s):

  • formattedText: string
Argument(s):
  • text: string
  • Optional - previousColor: number
Notes: Colors the text appropriately. If previousColor is specified, the code will emit a transition to the specified color at the end of the formatted text. If not, previousColor is assumed to be black.

purple

Return(s):

  • formattedText: string
Argument(s):
  • text: string
  • Optional - previousColor: number
Notes: Colors the text appropriately. If previousColor is specified, the code will emit a transition to the specified color at the end of the formatted text. If not, previousColor is assumed to be black.

normal

Return(s):

  • formattedText: string
Argument(s):
  • text: string
  • Optional - previousQuality: number
Notes: Decorates the text appropriately. If previousQuality is specified, the code will emit a transition to the specified decoration at the end of the formatted text.

bold

Return(s):

  • formattedText: string
Argument(s):
  • text: string
  • Optional - previousQuality: number
Notes: Decorates the text appropriately. If previousQuality is specified, the code will emit a transition to the specified decoration at the end of the formatted text. If not, previousQuality is assumed to be normal.

fileRef

Return(s):

  • formattedText: string
Argument(s):
  • text: string
Notes: Emits a formatted file reference. Most of the most useful ones are provided by other functions already.

itemIcon

Return(s):

  • formattedText: string
Argument(s):
  • itemId: number
Notes: Emits formatted text representing an item icon.

mobRef

Return(s):

  • formattedText: string
Argument(s):
  • mobId: number
Notes: Emits formatted text representing a mob reference. This will cause the client to display the string that it has for the specified mob and may also have some associated functionality.

mapRef

Return(s):

  • formattedText: string
Argument(s):
  • mapId: number
Notes: Emits formatted text representing a map reference. This will cause the client to display the string that it has for the specified map and may also have some associated functionality.

inventoryRef

Return(s):

  • formattedText: string
Argument(s):
  • itemId: number
Notes: Emits formatted text representing an item count reference.

skillRef

Return(s):

  • formattedText: string
Argument(s):
  • skillId: number
Notes: Emits formatted text representing a skill reference. This will cause the client to display the string that it has for the specified skill and may also have some associated functionality.

altItemRef

Return(s):

  • formattedText: string
Argument(s):
  • itemId: number
Notes: Emits formatted text representing an item reference. This will cause the client to display the string that it has for the specified item and may also have some associated functionality. This is an alternate version of the itemRef function and it's not clear what the difference is, if any, between the two. Some scripts use one but most use the regular variant.

itemRef

Return(s):

  • formattedText: string
Argument(s):
  • itemId: number
Notes: Emits formatted text representing an item reference. This will cause the client to display the string that it has for the specified item and may also have some associated functionality.

playerRef

Return(s):

  • formattedText: string
Argument(s):
  • N/A
Notes: Emits formatted text representing a player reference. This will cause the client to display the name associated to the player and may also have some associated functionality.

npcRef

Return(s):

  • formattedText: string
Argument(s):
  • npcId: number
Notes: Emits formatted text representing an NPC reference. This will cause the client to display the string that it has for the specified NPC and may also have some associated functionality.

questCompleteIcon

Return(s):

  • formattedText: string
Argument(s):
  • N/A
Notes: Emits formatted text representing a quest complete icon. This will cause the client to display the quest completion icon.

questExpIcon

Return(s):

  • formattedText: string
Argument(s):
  • experience: number
Notes: Emits formatted text representing a quest experience icon. This will cause the client to display the quest experience icon with the associated EXP number.

questMesosIcon

Return(s):

  • formattedText: string
Argument(s):
  • mesos: number
Notes: Emits formatted text representing a quest mesos icon. This will cause the client to display the quest mesos icon with the associated mesos count.

questItemIcon

Return(s):

  • formattedText: string
Argument(s):
  • itemId: number
  • Optional - qty: number
Notes: Emits formatted text representing a quest reward item icon. This will cause the client to display the quest item icon and optionally, quantity verbiage.

questSkillIcon

Return(s):

  • formattedText: string
Argument(s):
  • skillId
Notes: Emits formatted text representing a quest skill icon. This will cause the client to display the quest skill icon for the associated skill reward.

genderedText

Return(s):

  • formattedText: string
Argument(s):
  • femaleText: string
  • maleText: string
Notes: Emits formatted text based on the current player's gender. If there is an official escape sequence in the locale, this is preferred. Otherwise it only emits one or the other.

progressBar

Return(s):

  • formattedText: string
Argument(s):
  • completionPercentage: number
Notes: Emits formatted text representing a progress bar. This will cause the client to display an actual progress bar that's filled to the completion percentage you specify (e.g. progessBar(10) will be a progress bar with 10% filled).

choiceRef

Return(s):

  • formattedText: string
Argument(s):
  • choice: table OR string
  • Optional - choiceId: number
Notes: Converts either a table into a formatted choice list text or a single choice option into formatted text.

makeChoiceData

Return(s):

  • choiceSelection: table
Argument(s):
  • choice: string
  • data: table
Notes: Synthesizes choice data into a format understood by selectChoice.

Usage:

 makeChoiceData("Skin", getSkinStyles()),

makeChoiceHandler

Return(s):

  • choiceSelection: table
Argument(s):
  • choice: string
  • handler: function
    • Return(s): value: any
    • Argument(s): Optional - choiceId: number
Notes: Synthesizes a choice handler into a format understood by selectChoice.

Usage:

 makeChoiceHandler("No, it's okay.", function()
 	addText("I guess you already know a lot about Victoria Island. ");
 	addText("Have a good trip...");
 	sendNext();
 end),

selectChoice

Conditional Return(s):

  • If the selected choice contains a handler: The return result of the handler
  • If the selected choice contains data:
    • The item associated to the choice
    • choiceId: number
  • Any other case: The choice itself
Argument(s):
  • choices: table
  • choiceId: number
Notes: This versatile function is probably how you will do most of your selection NPC interactions. It will either transform your list of choices into data that you can then go and use based on the selection or alternatively execute the associated handler function automatically.

Usage:

 choice = askChoice();
 data = selectChoice(choices, choice);
 item, worth = data[1], data[2];
⚠️ **GitHub.com Fallback** ⚠️