This page explains how to integrate ICode and the Dialogue System. (ICode is required.)
ICode copyright © Zerano.
The support package adds Dialogue System-specific actions and conditions, as well as Lua functions and sequencer commands to control ICode variables in Lua and sequences.
To set up support, import the package Third Party Support ► ICode Support. This will unpack files into the folder Assets ► Pixel Crushers ► Dialogue System ► Third Party Support ► ICode.
The Dialogue System adds these state machine actions in the ICode support package:
Action | Description |
---|---|
Bark | Makes an NPC bark. |
Action | Description |
---|---|
StartConversation | Starts a conversation. |
StopConversation | Stops the active conversation. |
UpdateResponses | Updates the choices in the response menu. If events can occur in your game while the response menu is active, and if those events can change what choices are available in the menu, then use this action after those events occur. |
GetIsConversationActive | Checks if a conversation is active and stores the result in a bool parameter. |
Condition | Description |
---|---|
IsConversationActive | Checks if the Dialogue System is currently running a conversation. |
DoesConversationHaveValidDialogueEntries | Checks if a conversation currently has any valid starting dialogue entries. |
Action | Description |
---|---|
AddDialogueDatabase | Loads an extra database into the master dialogue database. |
PreloadMasterDatabase | Loads the master dialogue database into memory. Normally this automatically happens the first time the database is needed. If your database is very large, you can preload it at a time of your choosing to prevent a hiccup in gameplay. |
RemoveDialogueDatabase | Removes a database from the master dialogue database. |
ResetMasterDatabase | Resets the master dialogue database to its initial state. |
Action | Description |
---|---|
Lua | Runs Lua code and stores the return value. |
More info: Logic & Lua
Action | Description |
---|---|
GetBoolVariable | Gets the value of a bool variable. |
GetFloatVariable | Gets the value of a float variable. |
GetIntVariable | Gets the value of an int variable. |
GetStringVariable | Gets the value of a string variable. |
SetBoolVariable | Sets the value of a bool variable. |
SetFloatVariable | Sets the value of a float variable. |
SetIntVariable | Sets the value of an int variable. |
SetStringVariable | Sets the value of a string variable. |
Action | Description |
---|---|
GetTime | Gets the value of UnityEngine.Time.time . |
Action | Description |
---|---|
GetQuestState | Gets the state of a quest ("unassigned", "active", "success", or "failure"). |
SetQuestState | Sets the state of a quest ("unassigned", "active", "success", or "failure"). |
GetQuestEntryState | Gets the state of a quest entry ("unassigned", "active", "success", or "failure"). |
SetQuestEntryState | Sets the state of a quest entry ("unassigned", "active", "success", or "failure"). |
Action | Description |
---|---|
ApplyPersistentData | Tells all persistent data components to retrieve their state from the Lua environment. |
ApplySavegameData | Applies savegame data to the Lua environment and all persistent data components. |
BroadcastLevelWillBeUnloaded | Tells all persistent data components that the level is about to be unloaded. Some persistent data components, such as PersistentDestructible, take action when they receive OnDestroy messages during gameplay. When loading a new level, the old level is destroyed, which also sends OnDestroy to all scene objects. This action tells the persistent data components to ignore the next OnDestroy. Use this action before changing levels. |
GetSavegameData | Tells all persistent data components to store their state in the Lua environment, then gets the savegame data from the Lua environment. This data allows the Dialogue System and persistent data components to reconstruct their state when loading a game. |
RecordPersistentData | Tells all persistent data components to record their state into the Lua environment. |
ResetPersistentData | Tells all persistent data components to reset the state stored in the Lua environment. |
More info: Save System
Action | Description |
---|---|
PlaySequence | Plays a cutscene sequence. |
More info: Cutscene Sequences
Action | Description |
---|---|
GetRelationship | Gets a relationship value between two actors. |
GetStatus | Gets the status value between two assets (usually two actors). |
SetRelationship | Sets a relationship value between two actors. |
SetStatus | Sets the status value between two assets (usually two actors). |
More info: Chat Mapper Functions
You can use the following Lua functions in your dialogue entries' Conditions and Script fields to interface with ICode. To use them, add the ICodeLuaFunctions component to your Dialogue Manager GameObject.
Description: Gets the value of a state machine's bool parameter.
Parameters:
Example:: The example below gets the value of a parameter named "Randomize" on the NPC named "_Barker".
r = GetStateBool("_Barker", "Randomize")
Description: Gets the value of a state machine's float parameter.
Parameters:
Example:: The example below gets the value of a parameter named "Bark Time" on the NPC named "_Barker".
bt = GetStateFloat("_Barker", "Bark Time")
Description: Gets the value of a state machine's int parameter.
Parameters:
Example:: The example below gets the value of a parameter named "Bark Index" on the NPC named "_Barker".
bi = GetStateInt("_Barker", "Bark Index")
Description: Gets the value of a state machine's object parameter.
Parameters:
Example:: The example below gets the name of a parameter value named "Conversant" on the NPC named "_Barker".
conversantName = GetStateObject("_Barker", "Conversant")
Description: Sets the value of a state machine's bool parameter.
Parameters:
Example:: The example below sets the value of a parameter named "Randomize" on the NPC named "_Barker".
SetStateBool("_Barker", "Randomize", true)
Description: Sets the value of a state machine's float parameter.
Parameters:
Example:: The example below sets the value of a parameter named "Seconds Between Barks" on the NPC named "_Barker".
SetStateFloat("_Barker", "Seconds Between Barks", 9)
Description: Sets the value of a state machine's int parameter.
Parameters:
Example:: The example below sets the value of a parameter named "Bark Index" on the NPC named "_Barker".
SetStateInt("_Barker", "Bark Index", 3)
Description: Gets the value of a state machine's object parameter.
Parameters:
Example:: The example below sets the value of a parameter named "Conversant" on the NPC named "_Barker" to an object named "Fred".
SetStateObject("_Barker", "Conversant", "Fred")
You can use the following sequencer commands in your dialogue entries' Sequence field to interface with RPG Kit.
Syntax:
SetStateBool(
objectName, parameterName, value)
SetStateInt(
objectName, parameterName, value)
SetStateFloat(
objectName, parameterName, value)
SetStateObject(
objectName, parameterName, value)
Description: Sets a parameter on a state machine.
Parameters:
Example:
SetStateBool(_Barker, Randomize, true)
(Sets the "Randomize" parameter to true
on the NPC named "_Barker")SetStateInt(_Barker, Bark Index, 3)
(Sets the "Bark Index" parameter to 3
on the NPC named "_Barker")More info: Cutscene Sequences
You can use the ICode Variable Trigger component to set an ICode variable when a trigger event such as "OnUse" occurs.
The ICode support example scene uses this to trigger state machine transitions when the player sends an NPC an "OnUse" message using the Selector.