plyGame Support

This page describes how to integrate the Dialogue System with plyGame and plyBlox. (plyGame and/or plyBlox are required.)

plyGame and plyBlox copyright © PL Young.

How to Set Up plyGame Support

To enable plyGame support in the Dialogue System, import the package Third Party Support ► plyGame Support.

Example Scene

The plyGame support package includes an example scene. You cannot import the example into an existing project as it will override all your plyData. The example must be run in a new project. The example is useful to study to understand how the Dialogue System integrates with plyGame. Then you can incorporate the same functionality into your own plyGame project.

To set up and play the example:

  1. Create a new project.
  2. Import plyGame.
  3. Import the Dialogue System for Unity.
  4. Import Third Party Support ► plyGame Support.
  5. Import Assets ► Pixel Crushers ► Dialogue System ► Third Party Support ► plyGame Support ► Example ► plyGame Example plyData. This will unpack the plyGame data, built specifically for the example, into Assets ► plyData.
  6. Add the scene Assets ► Pixel Crushers ► Dialogue System ► Third Party Support ► plyGame Support ► Example ► plyGame Example to the build settings.
  7. Open this scene.
  8. On the plyGame toolbar, click the plyGame Refresh Button (2nd button).
  9. Open the plyGame Main Editor (Tools → PL Young → Toolbar → Main Editor).
  10. On the Project tab, add the plyGame Example scene.
  11. On the Input Definitions tab, click Setup Input Manager.
  12. Click on all of the other tabs to make sure plyGame updates its settings.
  13. Make sure plyData/System/00-bootstrap is in the project's Build Settings.
  14. Press the Unity Play Button. (The sample scene should be open from a previous step.)
  15. Run up to Private Hart (NPC), press E and chat with him. Run up to Sergeant Graves (NPC) and press E to cause him to bark. You can also do the same with the Dead Guard and Terminal.
  16. The F1 key saves the game, and F2 loads a previously-saved game. This demonstrates how the Dialogue System is tied into plyGame's Load/Save System. (F3 saves to slot 2, and F3 loads from slot 2, if you want to test multiple saves.)

Save & Load Setup

The SaveGame and LoadGame buttons are in an Input Group named SaveLoad. This makes the full names of the buttons "SaveLoad/SaveGame" and "SaveLoad/LoadGame". These are used in the plyBlox on the Game Object named "Demo Menu":

When the block above receives a "SaveLoad/SaveGame" keypress, it tells plyGame to save to slot 0. The example scene has an instance of the Persist Dialogue System prefab. You can find this prefab in the Prefabs subfolder. If you're using plyGame's save/load system, add an instance of this prefab to every gameplay scene. Do not add it to the Dialogue Manager GameObject. This prefab has a Persistable Dialogue Manager script, which ties the Dialogue System into plyGame's save/load system, so when plyGame saves the game, it also pulls in the Dialogue System data. The "SaveLoad/LoadGame" keypress works similarly.

plyGame-Specific Support

plyGame Bridge

Attach the plyGame Bridge component (via Component → Pixel Crushers → Dialogue System → Third Party → plyGame → plyGame Data Bridge) to any Actors for whom you want to synchronize data between plyGame and the Dialogue System's Lua environment.

The following data are synchronized if the corresponding checkbox is ticked on the bridge component:

Attributes

Lua variable Description Example
Actor["actorName"].attribute_Value The attribute's Value (max value) Actor["Player"].Health_Value
Actor["actorName"].attribute_CurrentValue The attribute's CurrentValue/ConsumableValue (current value) Actor["Player"].Health_CurrentValue

Factions

Lua variable Description Example
Actor["actorName"].Faction_faction_variable The value of a faction variable Actor["Player"].Faction_Monsters_Reputation

Skills

Lua variable Description Example
Actor["actorName"].Skill_skill A Boolean that indicates whether the Actor has this skill Actor["Player"].Skill_Fireball

Items (If Sync Items is ticked)

Lua variable Description
Actor["actorName"].Currency The current amount of currency in the Actor's ItemBag
Actor["actorName"].CurrWeight The current weight of the Actor's ItemBag
Item["itemName"].Count The current amount owned of an item. Set to 0 to remove the item

The ident values are used in Lua.

The methods in plyGameBridge are virtual so you can create a subclass if you want to synchronize additional information.

Conversation Controller

Attach the Conversation Controller component to any Actors that will engage in conversations. This component disables camera controllers and character controllers during conversations. You can specify additional components to disable in the Also Disable During Conversations list.

If you want to force plyGame to idle the character in place instead of entirely disabling plyGame's control during conversations, change the AI Controller Mode from Disable to Stay.

Loading & Saving

Attach the Persistable Dialogue Manager component to the Dialogue Manager object to add the Dialogue System to plyGame's Loading & Saving System. You may also need to add a plyGame Persistable Object script, depending on the version of plyGame you're using.

If you use Persistent Destructible or Increment On Destroy components, make sure to call the Level Will Be Unloaded block before loading a new level. This tells the components to ignore their destruction due to the level change.

plyBlox Support

The Dialogue System introduces the following plyBlocks:

Conversations

  • Start Conversation: Starts a conversation.
  • Stop Conversation: Stops the active conversation.
  • Is Conversation Active?: Checks whether a conversation is currently active.
  • Does Conversation Have Valid Entries?: Checks whether a conversation has any entries linked from the START entry whose conditions are true.
  • Update Responses: Updates the responses for the current state of the active conversation. If the response menu entries' conditions have changed while the response menu is being shown, use this to update the response menu.

Barks

  • Bark: Plays a one-liner bark.

Cutscene Sequences

  • Start Sequence: Starts a sequence.
  • Is Sequence Playing?: Checks whether a sequence is playing or finished.
  • Stop Sequence: Stops a sequence.
  • Send Message to Sequencer: Sends a message to the sequencer. (Used with WaitForMessage() as described in Cutscene Sequences.)

Quests

  • Add Quest: Adds a quest to the active game.
  • Delete Quest: Deletes a quest from the active game.
  • Get QuestState: Gets the current state of a quest.
  • Set QuestState: Sets the current state of a quest.
  • Get Quest Description: Gets the description of a quest.
  • Set Quest Description: Sets the description of a quest.
  • Get Quest Entry Count: Gets the number of entries (sub-tasks) in a quest. (optional)
  • Add Quest Entry: Adds a quest entry.
  • Get Quest Entry State: Sets the state of a quest entry.
  • Set Quest Entry State: Gets the state of a quest entry.
  • Is Quest Abandonable?: Checks whether a quest is configured as abandonable.
  • Is Quest Tracking Enabled?: Checks whether a quest is configured as trackable.
  • Set Quest Tracking: Enables or disables quest tracking.
  • Get Quest Abandon Sequence: Gets the quest's Abandon Sequence (if defined).

Relationships & Status

  • Get Status: Gets the status value that has been assigned between two actors.
  • Set Status: Sets the status value between two actors.
  • Get Relationship: Gets the relationship value that has been assigned between two actors.
  • Set Relationship: Sets the relationship value between two actors.
  • Decrement Relationship: Reduces the relationship value between two actors.
  • Increment Relationship: Increases the relationship value between two actors.

Dialogue Database Management

  • Add Dialogue Database: Adds a dialogue database to the master database in memory.
  • Preload Master Database: Preloads the master database. Use to control when loading occurs, to better time any pause when loading large databases.
  • Remove Dialogue Database: Removes a dialogue database from the master database.
  • Reset Dialogue Database: Resets the master database.
  • Set Default Dialogue Database: Sets the default database that the master database starts with when it's reset.
  • Set Portrait: Similar to the SetPortrait() sequencer command, this block overrides an actor's portrait image.
  • Set Language: Sets the current language to use for localization.
  • Get Localized Text: Gets the value of a localized text table field.

User Interface

  • Show Alert Message: Shows a message using the alert UI.
  • Preload Dialogue UI: Preloads the dialogue UI. Use to control when loading occurs, to better time any pause when loading large UIs.

Lua & Data Access

  • Run Lua Code: Runs arbitrary Lua code in the Dialogue System's Lua environment.
  • Get Variable: Gets the value of an element in the Variable[] table.
  • Set Variable: Sets the value of an element in the Variable[] table.
  • Get Lua Field: Gets the value of an field in the Actor[], Item[], or Location[] table.
  • Set Lua Field: Gets the value of an field in the Actor[], Item[], or Location[] table.
  • Level Will Be Unloaded: Tells persistent data components that listen for OnDestroy() to ignore it due to level change.

Events

The Dialogue System introduces the following plyEvents:

  • On Bark Start: Occurs when a bark starts. Sent to the barker and target.
  • On Bark End: Occurs when a bark ends. Sent to the barker and target.
  • On Conversation Start: Occurs when a conversation starts. Sent to the participants and Dialogue Manager.
  • On Conversation End: Occurs when a conversation ends. Sent to the participants and Dialogue Manager.
  • On Conversation Cancelled: Occurs when the player cancels the active conversation. Sent to the Dialogue Manager.
  • On Conversation Line: Occurs when a line in a conversation is displayed. Sent to the participants and Dialogue Manager.
  • On Conversation Line Cancelled: Occurs when the player cancelled/skipped the display of a line in a conversation. Sent to the Dialogue Manager.
  • On Conversation Timeout: Occurs when the timer on the active conversation's response menu has timed out. Sent to the Dialogue Manager.
  • On Sequence Start: Occurs when a sequence has started. Sent to the participants.
  • On Sequence End: Occurs when a sequence has ended. Sent to the participants.

For events that have an actor (the start and end of barks, conversations, and sequences), the actor's GameObject is recorded in the temporary variable actor.gameObject.


<< Third Party Integration