PowerQuest 0.19.0
Loading...
Searching...
No Matches
IPowerQuest Interface Reference

Detailed Description

PowerQuest is the main hub for the adventure game engine (Access with E) - eg. E.Wait(2);.

Most adventure game functionality not tied to a room/character/item/etc is accessed through here. Including:

  • Pausing scripts with Wait commands
  • Displaying text boxes
  • Save/Restore games
  • Accessing Camera, Cursor, and other adventure game objects
  • Access to game settings
  • Triggering "interactions" of other objects
  • Little helper utilities
  • Eg.
    E.FadeOut(1);
    E.Wait(3);
    if ( E.FirstOccurrence("AteBadPie") )
    E.ChangeRoom(R.Vomitorium);
    E.Save(1);
    E.StartCutscene;

Properties

bool IsDebugBuild [get]
 Returns true for developer builds, or if QUESTDEBUG is defined in player settings. Alternative to Debug.isDebugBuild, so you can have debug features enabled in non-developer builds.
 
bool GameHasKeyboardFocus [get]
 Returns true if keyboard events should be processed by the game scripts. If a gui control is capturing keyboard, it returns false.
 
ICharacter Player [get, set]
 Gets or sets the current player controlled character.
 
IInventory ActiveInventory [get, set]
 Shortcut to the current player's active inventory (the one currently selected for use on things). You can use the shorter I.Active
 
int InlineDialogResult [get]
 Retrieves the option that was picked in the last call to WaitForInlineDialog()
 
float VerticalResolution [get]
 Returns the currentvertical resolution including any overrides from the current room.
 
float DefaultVerticalResolution [get]
 Returns the project's vertical resolution set in PowerQuest.
 
QuestSettings Settings [get]
 The game settings object.
 
float TransitionFadeTime [get, set]
 Length of time transition between rooms takes.
 
string DisplayBoxGui [get, set]
 The name of the gui used for "Display Text".
 
string DialogTreeGui [get, set]
 The name of the gui used for Dialog Trees.
 
string CustomSpeechGui [get, set]
 The name of the gui used for Custom Speech.
 
bool AlwaysShowDisplayText [get, set]
 Whether "Display" text is shown regardless of the DialogDisplay setting.
 
eSpeechStyle SpeechStyle [get, set]
 Controls how game speech captions are displayed.
 
bool NextOccurrence [get]
 Continues a sequence of Occurrence checks, started with FirstOccurence.
 
bool NextOption [get]
 Continues a if/else sequence starting with FirstOption.
 
Commands for empty blocking functions
YieldInstruction ConsumeEvent [get]
 This is the same as Consume in quest scripts. It stops the script from falling back to Unhandled Event functions.
 
YieldInstruction Break [get]
 This is the same as End in quest scripts. Empty functions need to return something and this stops the function consuming an update cycle like "yield break" does.
 
Access to other objects
ICamera Camera [get]
 Convenient shortcut to the game camera.
 
ICursor Cursor [get]
 Convenient shortcut to the Cursor.
 

Public Member Functions

void InterruptNextLine (float secondsBeforeEndOfLine)
 The instruction for the next line of dialog will unblock early by bySeconds seconds.
 
void SkipDialog (bool preventEarlySkip=true)
 Skips the current line of dialog,.
 
bool SkipCutscene ()
 Skips a currently active cutscene- Returns true if a cutscene was skipped.
 
bool GetBlocked ()
 Returns true if there's a blocking script currently running.
 
IGui GetFocusedGui ()
 Returns the currently focused gui.
 
bool NavigateGui (eGuiNav input=eGuiNav.Ok)
 Allows navigation of gui by keyboard/controller.
 
bool ConsumeGuiKey (eGuiNav input)
 Returns true if the specfied NavigateGui input was pressed or repeated (when held down after timer). Also 'consumes' the press event so other guis won't recieve it.
 
Coroutine Display (string dialog, int id=-1)
 Display narrator dialog.
 
Coroutine DisplayBG (string dialog, int id=-1)
 Display narrator dialog (without blocking)
 
void StartCutscene ()
 Flags the section of code as a cutscenes. If player presses esc, the game will skip forward until the next EndCutscene()
 
void EndCutscene ()
 Stops flagging a section of code as a cutscene. When plyer presses esc after a "StartCutscene", this is where they'll skip to.
 
bool GetSkippingCutscene ()
 Returns true when a cutscene (The code between StartCutscene() and EndCutscene()) is currently being skipped.
 
void ChangeRoomBG (IRoom room)
 Change the current room. Same as calling C.Player.Room = room;.
 
Coroutine ChangeRoom (IRoom room)
 Change the current room. And blocks until after OnEnterAfterFade of the new room finishes.
 
Room GetCurrentRoom ()
 The room the player's in (R.Current)
 
void DebugSetPreviousRoom (IRoom room)
 Debugging function that overrides the value of R.Previous. Useful for testing, paricularly in 'Play from` functions- (when using the [QuestPlayFromFunction] attribute)
 
Room GetRoom (string scriptName)
 Retrieve a room by it's name.
 
Character GetPlayer ()
 Get the current player controlled character.
 
void SetPlayer (ICharacter character, float cameraPanTime=0)
 Set the current player controlled character. If in another room, will trigger room transition. If in the same room, the camera will pan to the new character over 'cameraPanTime' seconds.
 
Character GetCharacter (string scriptName)
 Retrieve a character by it's name. eg E.GetCharacter("Dave"); Usually you would just use C.Dave
 
Inventory GetInventory (string scriptName)
 Retrieve an inventory item by it's name. Eg E.GetInventory("Screwdriver");, Usually you would just use I.Screwdriver
 
DialogTree GetDialogTree (string scriptName)
 Retrieve the currently active dialog. Eg. E.GetCurrentDialog().OptionOff(1);. Same as D.Current
 
Coroutine WaitForInlineDialog (params string[] options)
 
Gui GetGui (string scriptName)
 Retreive a Gui item by it's name.
 
GameObject GetSpawnablePrefab (string name)
 Find a prefab to spawn by name. Usage: E.GetSpawnablePrefab("SparkleEffect").Spawn(...);.
 
UnityEngine.Camera GetCameraGui ()
 Returns the Gui Camera.
 
Canvas GetCanvas ()
 Returns the Gui Canvas.
 
Vector2 GetMousePosition ()
 Returns the current mouse position in world space.
 
Vector2 GetMousePositionGui ()
 Returns the current mouse position in gui space.
 
IQuestClickable GetMouseOverClickable ()
 Returns the "clickable object" that the mouse is over (could be a character, hotspot, etc). Returns null of the mouse cursor isn't over anything.
 
eQuestClickableType GetMouseOverType ()
 Returns the type of clickable that the mouse is over as an eQuestClickableType (eg, could be a character, hotspot, etc).
 
string GetMouseOverDescription ()
 Returns the display name of the object the mouse is over.
 
Vector2 GetLastLookAt ()
 Returns the "Look at" position of the last thing clicked.
 
Vector2 GetLastWalkTo ()
 Returns the "Walk To" position of the last thing clicked.
 
bool ProcessClick (eQuestVerb verb)
 Starts the specified action for the verb on whatever the mouse is over (whatever the current GetMouseOverClickable() happens to be ).
 
bool ProcessClick (eQuestVerb verb, IQuestClickable clickable, Vector2 mousePosition)
 
Coroutine HandleInteract (IHotspot target)
 Runs a "Use Hotspot" sequence.
 
Coroutine HandleLookAt (IHotspot target)
 Runs a "Look at Hotspot" sequence.
 
Coroutine HandleInventory (IHotspot target, IInventory item)
 Runs a "Use inventory on hostpot" sequence.
 
Coroutine HandleInteract (IProp target)
 Runs a "Use Prop" sequence.
 
Coroutine HandleLookAt (IProp target)
 Runs a "Look at Prop" sequence.
 
Coroutine HandleInventory (IProp target, IInventory item)
 Runs a "Use inventory on Prop" sequence.
 
Coroutine HandleInteract (ICharacter target)
 Runs a "Use Character" sequence.
 
Coroutine HandleLookAt (ICharacter target)
 Runs a "Look at Character" sequence.
 
Coroutine HandleInventory (ICharacter target, IInventory item)
 Runs a "Use inventory on Character" sequence.
 
Coroutine HandleInteract (IInventory target)
 Runs a "Use Inventory" sequence.
 
Coroutine HandleLookAt (IInventory target)
 Runs a "Look at Inventory" sequence.
 
Coroutine HandleInventory (IInventory target, IInventory item)
 Runs a "Use inventory on Inventory" sequence.
 
Coroutine HandleOption (IDialogTree dialog, string optionName)
 Runs a specific dialog option. NB: Does NOT start the dialog tree first.
 
void DisableCancel ()
 Stops sequence from being cancelled when user clicks something else while walking there. Place either at start of script to prevent first WalkTo being cancelable.
 
bool FirstOccurrence (string uniqueString)
 Registers something "occurring", and returns whether it's the first time it's occurred.
 
int Occurrence (string uniqueString)
 Registers something "occurring", and returns the number of time's it's occurred. Returns 0 the first time, then 1, etc.
 
int GetOccurrenceCount (string uniqueString)
 Checks how many times something has occurred, without incrementing the occurrence.
 
bool FirstOption (int count, string source=null)
 Start a sequence of options, passing in the total number of options in your list. Then call NextOption for the remaining options.
 
void Restart ()
 Returns a random int from 0 up to and including the "max". The id will not repeat until all ids have been used, and will not be repeated twice in a row.
 
void Restart (IRoom room, string playFromFunction=null)
 Restart the game on a specific scene, optionally with a specific 'playFromFunction'. Useful for testing.
 
void DisableAllClickablesExcept ()
 Helper function that temporarily disables all clickables, except those specified. Useful when you want to set only certain props clickable for a short time. Eg: E.DisableAllClickablesExcept("Ropes","BrokenGlass");
 
void DisableAllClickablesExcept (params string[] exceptions)
 Helper function that temporarily disables all clickables, except those specified. Useful when you want to set only certain props clickable for a short time. Eg: E.DisableAllClickablesExcept("Ropes","BrokenGlass");
 
void DisableAllClickablesExcept (params IQuestClickableInterface[] exceptions)
 Helper function that temporarily disables all clickables, except those specified. Useful when you want to set only certain props clickable for a short time. Eg: E.DisableAllClickablesExcept("Ropes","BrokenGlass");
 
void RestoreAllClickables ()
 Helper function that restores clickables disabled with the DisableAllClickablesExcept function.
 
void SetAllClickableCursors (string cursor, params string[] exceptions)
 Set all clickables to have a specific cursor temporarily, restore using RestoreAllClickableCursors(). Eg: E.SetAllClickableCursors("None", "Ropes","BrokenGlass");
 
void RestoreAllClickableCursors ()
 Resets all clickable cursors after a call to "SetAllClickableCursors".
 
List< QuestSaveSlotData > GetSaveSlotData ()
 Returns a list of all save slot data.
 
QuestSaveSlotData GetSaveSlotData (int slot)
 Returns save slot data for a particular save game. The data has info about the name, etc of the save file.
 
QuestSaveSlotData GetLastSaveSlotData ()
 Returns save slot data for the most recenly saved game. The data has info about the name, etc of the save file.
 
bool SaveSettings ()
 Saves game settings (volume, etc). This is a separate file to game saves. It's called already during game save, but can be done when options have changed too (like when leaving options menu)
 
bool Save (int slot, string description, Texture2D imageOverride=null)
 Saves the game to a particular slot with a particular description. You may also override the image or provide extra slot data if desired, this will override the "Screenshot" that would otherwise be saved.
 
bool RestoreSave (int slot)
 Restores the game from a particular slot.
 
bool RestoreLastSave ()
 Restores the last game saved.
 
bool DeleteSave (int slot)
 Deletes a save game from a particular slot.
 
bool GetRestoringGame ()
 Returns true if game is in process of being restored from a save file.
 
void AddSaveData (string name, object data, System.Action OnPostRestore=null)
 Advanced save/restore function: For saving data not in a QuestScript...
 
void RemoveSaveData (string name)
 Advanced save/restore function: For aving data not in a QuestScript. Call this when you've called AddSaveData, but no longer want to save that data.
 
GetScript< T > ()
 PowerQuest internal function: Retrieve a quest script by it's type. So you can access your functions/variables in your own scripts. Eg: E.GetScript<RoomKitchen>().m_tapsOn = true;.
 
Timing/Waiting functions

Some of these have nice shortcuts in the quest script editor. Eg ... or => FunctionToWaitFor

Coroutine Wait (float time=0.5f)
 Wait for time (or default 0.5 sec). In the Quest Script editor you can also just write ... with more or less dots for a shorter or longer time.
 
Coroutine WaitSkip (float time=0.5f)
 Wait for time (or default 0.5 sec). Pressing button will skip the waiting.
 
Coroutine WaitForTimer (string timerName, bool skippable=false)
 Wait for a timer to expire (use the name used with E.SetTimer()). Will remove the timer on complete, even if skipped.
 
Coroutine WaitFor (PowerQuest.DelegateWaitForFunction functionToWaitFor, bool autoLoadQuestScript=true)
 Use this when you want to yield to another function that returns an IEnumerator. Note: In the Script Editor you can just do => MyFunction()
 
Coroutine WaitWhile (System.Func< bool > condition, bool skippable=false)
 Use this when you want to wait until a condition is net. Note, you need the ()=> bit to make it work!
 
Coroutine WaitUntil (System.Func< bool > condition, bool skippable=false)
 Use this when you want to wait until a condition is net. Note, you need the ()=> bit to make it work!
 
Coroutine WaitForDialog ()
 Waits until the current dialog has finished. Useful for waiting to the end of SayBG commands.
 
Coroutine WaitForDialogSkip ()
 Waits until the current dialog has finished, allowing it to be skipped. Useful when you start a SayBG, do a bunch of other things, then want to be able to skip the rest of the SayBG()
 
Coroutine WaitForGui (IGui gui)
 Shows gui and waits for it to disappear. Useful for prompts.
 
void DelayedInvoke (float time, System.Action functionToInvoke)
 Invokes the specified function after the specified time has elapsed (non-blocking). EG: E.DelayedInvoke(1, ()=>{ C.Player.FaceLeft(); } );
 
void StartBackgroundSequence (PowerQuest.DelegateWaitForFunction function)
 Starts a sequence in the background that can be stopped again StopBackgroundSequence(). Use it for background conversations. Since they can't be skippable, use SayBG and WaitForDialog.
 
void StopBackgroundSequence (string function=null)
 Stops the background sequence with the specified name, or all background sequences if none specified.
 
Timers
void SetTimer (string name, float time)
 Starts timer with a name, counting down from time in seconds.
 
bool GetTimerExpired (string name)
 Checks whether the timer with specified name has expired. If the timeout set with SetTimer has elapsed, returns true. Otherwise, returns false.
 
float GetTimer (string name)
 Returns the time remaining on the timer with specified name.
 
Enum shortcuts
void Set< tEnum > (tEnum enumState)
 Sets an enum with the specified value. eg: E.Set(eDoor.Unlocked);.
 
bool At< tEnum > (params tEnum[] enumStates)
 Returns true if this script has an enum with the specified enum value. Usage: if ( E.At(eSection.GettingMap) ) {...}.
 
bool Is< tEnum > (params tEnum[] enumStates)
 Returns true if the enum has the specified value. Usage: if ( E.Is(eDoor.Unlocked) ) {...}.
 
bool Reached< tEnum > (tEnum enumState)
 Returns true if reached state. Eg: if ( E.Reached(eProgress.FoundTreasure) ). (Shorthand for m_state >= eState.myState )
 
bool After< tEnum > (tEnum enumState)
 Returns true if passed state. Eg: if ( E.After(eState.EscapedLava) ). (Shorthand for m_state > eState.myState )
 
bool Before< tEnum > (tEnum enumState)
 Returns true if haven't reached state. Eg: if ( E.Before(eProgress.FoundTreasure) ). (Shorthand for m_state < eState.myState )
 

Screen Fade Functions

Color FadeColor [get, set]
 Get/Set a temporary fade color. The fade color will be restored to FadeColorDefault after the next fade-in.
 
Color FadeColorDefault [get, set]
 Get/Set the default fade color.
 
Coroutine FadeIn (float time=0.2f, bool skippable=true)
 Fade the screen from the current FadeColor.
 
Coroutine FadeOut (float time=0.2f, bool skippable=true)
 Fade the screen to the current FadeColor.
 
void FadeInBG (float time=0.2f)
 Fade the screen from the current FadeColor (non-blocking)
 
void FadeOutBG (float time=0.2f)
 Fade the screen to the current FadeColor (non-blocking)
 
Coroutine FadeIn (float time, string source, bool skippable=true)
 Fade the screen from the current FadeColor, pass a string as the "source" if you want to be able to fade in/out while other fades are happening.
 
Coroutine FadeOut (float time, string source, bool skippable=true)
 Fade the screen to the current FadeColor, pass a string as the "source" if you want to be able to fade in/out while other fades are happening.
 
void FadeInBG (float time, string source)
 Fade the screen from the current FadeColor (non-blocking), pass a string as the "source" if you want to be able to fade in/out while other fades are happening.
 
void FadeOutBG (float time, string source)
 Fade the screen to the current FadeColor (non-blocking), pass a string as the "source" if you want to be able to fade in/out while other fades are happening.
 
bool GetFading ()
 Returns true if a fadeout/in is currently active.
 
void FadeColorRestore ()
 Return fade color to its default value.
 

Pause/Unpause the game

bool Paused [get, set]
 Gets or sets whether the game is paused.
 
void Pause (string source=null)
 Pauses the game. Pass a string as a source in case multiple things have paused/unpaused the game.
 
void UnPause (string source=null)
 Unpauses the game. Use the same source string you paused the game with (if any).
 

Property Documentation

◆ ConsumeEvent

YieldInstruction ConsumeEvent
get

This is the same as Consume in quest scripts. It stops the script from falling back to Unhandled Event functions.

◆ Break

YieldInstruction Break
get

This is the same as End in quest scripts. Empty functions need to return something and this stops the function consuming an update cycle like "yield break" does.

◆ IsDebugBuild

bool IsDebugBuild
get

Returns true for developer builds, or if QUESTDEBUG is defined in player settings. Alternative to Debug.isDebugBuild, so you can have debug features enabled in non-developer builds.

◆ Camera

ICamera Camera
get

Convenient shortcut to the game camera.

◆ Cursor

ICursor Cursor
get

Convenient shortcut to the Cursor.

◆ GameHasKeyboardFocus

bool GameHasKeyboardFocus
get

Returns true if keyboard events should be processed by the game scripts. If a gui control is capturing keyboard, it returns false.

◆ FadeColor

Color FadeColor
getset

Get/Set a temporary fade color. The fade color will be restored to FadeColorDefault after the next fade-in.

See also
FadeColorDefault
FadeColorRestore

◆ FadeColorDefault

Color FadeColorDefault
getset

Get/Set the default fade color.

See also
FadeColor
FadeColorRestore

◆ Paused

bool Paused
getset

Gets or sets whether the game is paused.

◆ Player

ICharacter Player
getset

Gets or sets the current player controlled character.

◆ ActiveInventory

IInventory ActiveInventory
getset

Shortcut to the current player's active inventory (the one currently selected for use on things). You can use the shorter I.Active

◆ InlineDialogResult

int InlineDialogResult
get

Retrieves the option that was picked in the last call to WaitForInlineDialog()

See also
WaitForInlineDialog

◆ VerticalResolution

float VerticalResolution
get

Returns the currentvertical resolution including any overrides from the current room.

◆ DefaultVerticalResolution

float DefaultVerticalResolution
get

Returns the project's vertical resolution set in PowerQuest.

◆ Settings

QuestSettings Settings
get

The game settings object.

◆ TransitionFadeTime

float TransitionFadeTime
getset

Length of time transition between rooms takes.

◆ DisplayBoxGui

string DisplayBoxGui
getset

The name of the gui used for "Display Text".

◆ DialogTreeGui

string DialogTreeGui
getset

The name of the gui used for Dialog Trees.

◆ CustomSpeechGui

string CustomSpeechGui
getset

The name of the gui used for Custom Speech.

◆ AlwaysShowDisplayText

bool AlwaysShowDisplayText
getset

Whether "Display" text is shown regardless of the DialogDisplay setting.

◆ SpeechStyle

eSpeechStyle SpeechStyle
getset

Controls how game speech captions are displayed.

◆ NextOccurrence

bool NextOccurrence
get

Continues a sequence of Occurrence checks, started with FirstOccurence.

Usage:

if ( E.FirstOccurrence("Ham") )
Display: You take a bite of ham
else if ( E.NextOccurrence )
Display: You take another bite of ham
else if ( E.NextOccurrence )
Display: You take a third bite of ham
Coroutine Display(string dialog, int id=-1)
Display narrator dialog.
See also
FirstOccurrence
FirstOption
NextOption

◆ NextOption

bool NextOption
get

Continues a if/else sequence starting with FirstOption.

See also
FirstOption

Member Function Documentation

◆ Wait()

Coroutine Wait ( float time = 0.5f)

Wait for time (or default 0.5 sec). In the Quest Script editor you can also just write ... with more or less dots for a shorter or longer time.

See also
WaitSkip

◆ WaitSkip()

Coroutine WaitSkip ( float time = 0.5f)

Wait for time (or default 0.5 sec). Pressing button will skip the waiting.

◆ WaitForTimer()

Coroutine WaitForTimer ( string timerName,
bool skippable = false )

Wait for a timer to expire (use the name used with E.SetTimer()). Will remove the timer on complete, even if skipped.

◆ WaitFor()

Coroutine WaitFor ( PowerQuest.DelegateWaitForFunction functionToWaitFor,
bool autoLoadQuestScript = true )

Use this when you want to yield to another function that returns an IEnumerator. Note: In the Script Editor you can just do => MyFunction()

Usage:

Create a new blocking function. Eg:

public IEnumerator OpenDoor()
{
P.Door.PlayAnimation("Open");
m_doorOpen = true;
Display: The door is now open
}

Then call it from any sequence. Eg:

Display: Lets enter the door!
=> OpenDoor

Or if your function is used in multiple rooms, put it in your global script, then use => Globals.OpenDoor

Notes:

  • It is best practice to always use WaitFor() instead calling other blocking functions directly (eg by yield return MyFunction() ). This is so PQ knows its happening and if you change scenes or restore a game the function can be stopped, avoiding wierd bugs.
  • If not using the Quest Script Editor, use yield return E.WaitFor( SimpleExampleFunction ); or yield return E.WaitFor( ()=>ExampleFunctionWithParams(C.Dave, "lol") );

◆ WaitWhile()

Coroutine WaitWhile ( System.Func< bool > condition,
bool skippable = false )

Use this when you want to wait until a condition is net. Note, you need the ()=> bit to make it work!

Usage: yield return E.WaitWhile( ()=> C.Player.Walking )

See also
WaitUntil

◆ WaitUntil()

Coroutine WaitUntil ( System.Func< bool > condition,
bool skippable = false )

Use this when you want to wait until a condition is net. Note, you need the ()=> bit to make it work!

Usage: yield return E.WaitUntil( ()=> C.Player.Position.x > 0 )

See also
WaitWhile

◆ WaitForDialog()

Coroutine WaitForDialog ( )

Waits until the current dialog has finished. Useful for waiting to the end of SayBG commands.

See also
SayBG
WaitForDialogSkip

◆ WaitForDialogSkip()

Coroutine WaitForDialogSkip ( )

Waits until the current dialog has finished, allowing it to be skipped. Useful when you start a SayBG, do a bunch of other things, then want to be able to skip the rest of the SayBG()

See also
SayBG
WaitForDialog

◆ WaitForGui()

Coroutine WaitForGui ( IGui gui)

Shows gui and waits for it to disappear. Useful for prompts.

◆ DelayedInvoke()

void DelayedInvoke ( float time,
System.Action functionToInvoke )

Invokes the specified function after the specified time has elapsed (non-blocking). EG: E.DelayedInvoke(1, ()=>{ C.Player.FaceLeft(); } );

◆ StartBackgroundSequence()

void StartBackgroundSequence ( PowerQuest.DelegateWaitForFunction function)

Starts a sequence in the background that can be stopped again StopBackgroundSequence(). Use it for background conversations. Since they can't be skippable, use SayBG and WaitForDialog.

Usage:

- Create a blocking function, eg: `IEnumerator BackgroundChatter()`
- Call `E.StartBackroundSequence( BackgroundChatter );`
- If you want to interrupt the sequence, call `E.StopBackgroundSequence("BackgroundChatter");`
- These don't currently work when changing rooms, call `E.StopBackgroundSequence()` to stop all of them if leaving.
- Since a regular mouse click skips dialog, and WaitSkip commands, you need to use: 
    - `E.Wait(0.5f)` instead of `...` when waiting
    - `C.SayNoSkip("blah")` or `C.SayBG("blah");` followed by `E.WaitForDialog();`

Saving/Restoring:

- If the game is saved & restored when the background sequence is running, it'll be restarted. 
- If you want to be able to restore midway, you need to either:
    - Save a variable to skip over the already-done part of the sequence.
    - Or, have a chain of background sequences, so as one stops, it starts the next.
See also
StopBackgroundSequence
ICharacter.SayNoSkip

◆ StopBackgroundSequence()

void StopBackgroundSequence ( string function = null)

Stops the background sequence with the specified name, or all background sequences if none specified.

Note: Only the base function will be stopped. You'll have to manually stop characters walking C.Dave.StopWalking();, and talking E.CancelSay(); if desired.

See also
StartBackgroundSequence

◆ InterruptNextLine()

void InterruptNextLine ( float secondsBeforeEndOfLine)

The instruction for the next line of dialog will unblock early by bySeconds seconds.

Parameters
secondsBeforeEndOfLineThe script line following the next Say type command will execute early by this duration

Speech text and any recorded VO will still be running in the background until completion when next instructions execute

◆ SkipDialog()

void SkipDialog ( bool preventEarlySkip = true)

Skips the current line of dialog,.

◆ SkipCutscene()

bool SkipCutscene ( )

Skips a currently active cutscene- Returns true if a cutscene was skipped.

◆ GetBlocked()

bool GetBlocked ( )

Returns true if there's a blocking script currently running.

◆ GetFocusedGui()

IGui GetFocusedGui ( )

Returns the currently focused gui.

◆ NavigateGui()

bool NavigateGui ( eGuiNav input = eGuiNav.Ok)

Allows navigation of gui by keyboard/controller.

Call from UpdateNoPause in GlobalScript when an input is held down. Eg.

if ( Input.GetKey(KeyCode.Right) || MyControllerSytem.LeftJoystick.x > 0.5f )
E.NavigateGui(eGuiNav.Right);

This calls through to the Focused Gui's Navigate function, so alternatively you could call this yourself. Eg. E.MyGui.Navigate(eGuiNav.Right)

Returns true if handled by a gui.

◆ ConsumeGuiKey()

bool ConsumeGuiKey ( eGuiNav input)

Returns true if the specfied NavigateGui input was pressed or repeated (when held down after timer). Also 'consumes' the press event so other guis won't recieve it.

See also
NavigateGui

◆ Display()

Coroutine Display ( string dialog,
int id = -1 )

Display narrator dialog.

◆ DisplayBG()

Coroutine DisplayBG ( string dialog,
int id = -1 )

Display narrator dialog (without blocking)

◆ StartCutscene()

void StartCutscene ( )

Flags the section of code as a cutscenes. If player presses esc, the game will skip forward until the next EndCutscene()

See also
StartCutscene
EndCutscene

◆ EndCutscene()

void EndCutscene ( )

Stops flagging a section of code as a cutscene. When plyer presses esc after a "StartCutscene", this is where they'll skip to.

See also
StartCutscene
EndCutscene

◆ GetSkippingCutscene()

bool GetSkippingCutscene ( )

Returns true when a cutscene (The code between StartCutscene() and EndCutscene()) is currently being skipped.

Can be used to check if your own code should be skipped, or if a sequence you're in has been skipped.

eg: while ( m_boolToWaitFor && E.GetSkippingCutscene() == false ) yield return E.Wait(0);

See also
StartCutscene
EndCutscene

◆ FadeIn() [1/2]

Coroutine FadeIn ( float time = 0.2f,
bool skippable = true )

Fade the screen from the current FadeColor.

◆ FadeOut() [1/2]

Coroutine FadeOut ( float time = 0.2f,
bool skippable = true )

Fade the screen to the current FadeColor.

◆ FadeInBG() [1/2]

void FadeInBG ( float time = 0.2f)

Fade the screen from the current FadeColor (non-blocking)

◆ FadeOutBG() [1/2]

void FadeOutBG ( float time = 0.2f)

Fade the screen to the current FadeColor (non-blocking)

◆ FadeIn() [2/2]

Coroutine FadeIn ( float time,
string source,
bool skippable = true )

Fade the screen from the current FadeColor, pass a string as the "source" if you want to be able to fade in/out while other fades are happening.

◆ FadeOut() [2/2]

Coroutine FadeOut ( float time,
string source,
bool skippable = true )

Fade the screen to the current FadeColor, pass a string as the "source" if you want to be able to fade in/out while other fades are happening.

◆ FadeInBG() [2/2]

void FadeInBG ( float time,
string source )

Fade the screen from the current FadeColor (non-blocking), pass a string as the "source" if you want to be able to fade in/out while other fades are happening.

◆ FadeOutBG() [2/2]

void FadeOutBG ( float time,
string source )

Fade the screen to the current FadeColor (non-blocking), pass a string as the "source" if you want to be able to fade in/out while other fades are happening.

◆ GetFading()

bool GetFading ( )

Returns true if a fadeout/in is currently active.

◆ FadeColorRestore()

void FadeColorRestore ( )

Return fade color to its default value.

See also
FadeColor
FadeColorDefault

◆ Pause()

void Pause ( string source = null)

Pauses the game. Pass a string as a source in case multiple things have paused/unpaused the game.

◆ UnPause()

void UnPause ( string source = null)

Unpauses the game. Use the same source string you paused the game with (if any).

◆ SetTimer()

void SetTimer ( string name,
float time )

Starts timer with a name, counting down from time in seconds.

Use the same name to check whether the timer has finished by calling the GetTimerExpired(string name) function. The name is NOT case sensitive.

You can check the current time remaining on a timer by calling the GetTimer(string name) function, using the same name used to start the timer.

Pass time as 0 to disable a currently running timer.

NOTE: the timer will not tick while the game is paused.

Example:

E.SetTimer("egg",6) );

Will set the timer "egg" to expire after 6 seconds.

Rolling your own timers:

AGS users are familiar with the SetTimer() function, which is why it is included. However, it's good to know how to make your own timers, it's a fundamental building block of game coding!

This is how most coders would implement a simple timer:

In your script body or header, add a float variable: float m_myTimer = 0;

When you want to start a timer, in an interaction script for example: m_myTimer = 4; // Set to 4 seconds

And in your Update function:

if ( m_myTimer > 0) // If the timer is started
{
m_myTimer -= Time.deltaTime; // Subtract the time since last update
if ( m_myTimer <= 0 ) // Check if the timer's elapsed
{
... // The timer has elapsed! Do something!
}
}
See also
GetTimerExpired
GetTimer

◆ GetTimerExpired()

bool GetTimerExpired ( string name)

Checks whether the timer with specified name has expired. If the timeout set with SetTimer has elapsed, returns true. Otherwise, returns false.

Note that this function will only return true once - after that, the timer will always return false until restarted

Example: (in UpdateBlocking)

if ( E.GetTimerExpired("egg") )
Display: Egg timer expired

will display a message when timer "egg" expires.

See also
SetTimer
GetTimer

◆ GetTimer()

float GetTimer ( string name)

Returns the time remaining on the timer with specified name.

See also
SetTimer
GetTimerExpired

◆ ChangeRoomBG()

void ChangeRoomBG ( IRoom room)

Change the current room. Same as calling C.Player.Room = room;.

◆ ChangeRoom()

Coroutine ChangeRoom ( IRoom room)

Change the current room. And blocks until after OnEnterAfterFade of the new room finishes.

Example: Have a player look through a window, show the other room, then change back, in a single script:

Display: You peer into the window
E.ChangeRoom(R.InsideHouse);
Dave: Sure looks interesting in there!
E.ChangeRoom(R.OutsideHouse);
Dave: But I'll stay out here for now
See also
ChangeRoomBG

◆ GetCurrentRoom()

Room GetCurrentRoom ( )

The room the player's in (R.Current)

◆ DebugSetPreviousRoom()

void DebugSetPreviousRoom ( IRoom room)

Debugging function that overrides the value of R.Previous. Useful for testing, paricularly in 'Play from` functions- (when using the [QuestPlayFromFunction] attribute)

◆ GetRoom()

Room GetRoom ( string scriptName)

Retrieve a room by it's name.

◆ GetPlayer()

Character GetPlayer ( )

Get the current player controlled character.

◆ SetPlayer()

void SetPlayer ( ICharacter character,
float cameraPanTime = 0 )

Set the current player controlled character. If in another room, will trigger room transition. If in the same room, the camera will pan to the new character over 'cameraPanTime' seconds.

◆ GetCharacter()

Character GetCharacter ( string scriptName)

Retrieve a character by it's name. eg E.GetCharacter("Dave"); Usually you would just use C.Dave

◆ GetInventory()

Inventory GetInventory ( string scriptName)

Retrieve an inventory item by it's name. Eg E.GetInventory("Screwdriver");, Usually you would just use I.Screwdriver

◆ GetDialogTree()

DialogTree GetDialogTree ( string scriptName)

Retrieve the currently active dialog. Eg. E.GetCurrentDialog().OptionOff(1);. Same as D.Current

Retrieve an dialog tree by it's name. Eg: E.GetDialogTree("ChatWithBarney"). Usually you would just use D.ChatWithBarney

◆ WaitForInlineDialog()

Coroutine WaitForInlineDialog ( params string[] options)

Example:

Barney: You fight like a dairy farmer!
E.WaitForInlineDialog("How appropriate, you fight like a cow", "I am rubber, you are glue", "I'm shakin' I'm shakin'");
if ( E.InlineDialogResult == 2 )
WinSwordFight();
See also
InlineDialogResult

◆ GetGui()

Gui GetGui ( string scriptName)

Retreive a Gui item by it's name.

◆ GetSpawnablePrefab()

GameObject GetSpawnablePrefab ( string name)

Find a prefab to spawn by name. Usage: E.GetSpawnablePrefab("SparkleEffect").Spawn(...);.

◆ GetCameraGui()

UnityEngine.Camera GetCameraGui ( )

Returns the Gui Camera.

◆ GetCanvas()

Canvas GetCanvas ( )

Returns the Gui Canvas.

◆ GetMousePosition()

Vector2 GetMousePosition ( )

Returns the current mouse position in world space.

◆ GetMousePositionGui()

Vector2 GetMousePositionGui ( )

Returns the current mouse position in gui space.

◆ GetMouseOverClickable()

IQuestClickable GetMouseOverClickable ( )

Returns the "clickable object" that the mouse is over (could be a character, hotspot, etc). Returns null of the mouse cursor isn't over anything.

◆ GetMouseOverType()

eQuestClickableType GetMouseOverType ( )

Returns the type of clickable that the mouse is over as an eQuestClickableType (eg, could be a character, hotspot, etc).

◆ GetMouseOverDescription()

string GetMouseOverDescription ( )

Returns the display name of the object the mouse is over.

◆ GetLastLookAt()

Vector2 GetLastLookAt ( )

Returns the "Look at" position of the last thing clicked.

◆ GetLastWalkTo()

Vector2 GetLastWalkTo ( )

Returns the "Walk To" position of the last thing clicked.

◆ ProcessClick()

bool ProcessClick ( eQuestVerb verb)

Starts the specified action for the verb on whatever the mouse is over (whatever the current GetMouseOverClickable() happens to be ).

This would usually be called from the OnMouseClick function in your global script Returns true if the click resulted in a blocking function

◆ HandleInteract() [1/4]

Coroutine HandleInteract ( IHotspot target)

Runs a "Use Hotspot" sequence.

◆ HandleLookAt() [1/4]

Coroutine HandleLookAt ( IHotspot target)

Runs a "Look at Hotspot" sequence.

◆ HandleInventory() [1/4]

Coroutine HandleInventory ( IHotspot target,
IInventory item )

Runs a "Use inventory on hostpot" sequence.

◆ HandleInteract() [2/4]

Coroutine HandleInteract ( IProp target)

Runs a "Use Prop" sequence.

◆ HandleLookAt() [2/4]

Coroutine HandleLookAt ( IProp target)

Runs a "Look at Prop" sequence.

◆ HandleInventory() [2/4]

Coroutine HandleInventory ( IProp target,
IInventory item )

Runs a "Use inventory on Prop" sequence.

◆ HandleInteract() [3/4]

Coroutine HandleInteract ( ICharacter target)

Runs a "Use Character" sequence.

◆ HandleLookAt() [3/4]

Coroutine HandleLookAt ( ICharacter target)

Runs a "Look at Character" sequence.

◆ HandleInventory() [3/4]

Coroutine HandleInventory ( ICharacter target,
IInventory item )

Runs a "Use inventory on Character" sequence.

◆ HandleInteract() [4/4]

Coroutine HandleInteract ( IInventory target)

Runs a "Use Inventory" sequence.

◆ HandleLookAt() [4/4]

Coroutine HandleLookAt ( IInventory target)

Runs a "Look at Inventory" sequence.

◆ HandleInventory() [4/4]

Coroutine HandleInventory ( IInventory target,
IInventory item )

Runs a "Use inventory on Inventory" sequence.

◆ HandleOption()

Coroutine HandleOption ( IDialogTree dialog,
string optionName )

Runs a specific dialog option. NB: Does NOT start the dialog tree first.

◆ DisableCancel()

void DisableCancel ( )

Stops sequence from being cancelled when user clicks something else while walking there. Place either at start of script to prevent first WalkTo being cancelable.

◆ FirstOccurrence()

bool FirstOccurrence ( string uniqueString)

Registers something "occurring", and returns whether it's the first time it's occurred.

Usage:

if ( FirstOccurrence("unlockdoor") )
Display: You unlock the door
else
Display: It's already unlocked
bool FirstOccurrence(string uniqueString)
Registers something "occurring", and returns whether it's the first time it's occurred.
See also
Occurrence
GetOccurrenceCount
NextOccurrence

◆ Occurrence()

int Occurrence ( string uniqueString)

Registers something "occurring", and returns the number of time's it's occurred. Returns 0 the first time, then 1, etc.

Usage:

if ( Occurrence("knocked on door") < 3 )
Display: You knock on the door
int Occurrence(string uniqueString)
Registers something "occurring", and returns the number of time's it's occurred. Returns 0 the first ...
See also
FirstOccurrence
GetOccurrenceCount
NextOccurrence

◆ GetOccurrenceCount()

int GetOccurrenceCount ( string uniqueString)

Checks how many times something has occurred, without incrementing the occurrence.

Usage:

if ( GetOccurrenceCount("knocked on door") == 3 )
Doorman: Who's there?
int GetOccurrenceCount(string uniqueString)
Checks how many times something has occurred, without incrementing the occurrence.
See also
FirstOccurrence
Occurrrence

◆ FirstOption()

bool FirstOption ( int count,
string source = null )

Start a sequence of options, passing in the total number of options in your list. Then call NextOption for the remaining options.

Usage:

if ( E.FirstOption(4) )
Display: I can't do that
else if ( E.NextOption )
Display: Won't work
else if ( E.NextOption )
Display: Not gonna happen
else if ( E.NextOption )
Display: Nope

You can also pass a string "source", if you want it to remember which ones have been used before to avoid repeats until whole list is used.

See also
NextOption

◆ Restart() [1/2]

void Restart ( )

Returns a random int from 0 up to and including the "max". The id will not repeat until all ids have been used, and will not be repeated twice in a row.

Restart the game from the first scene

◆ Restart() [2/2]

void Restart ( IRoom room,
string playFromFunction = null )

Restart the game on a specific scene, optionally with a specific 'playFromFunction'. Useful for testing.

◆ DisableAllClickablesExcept() [1/3]

void DisableAllClickablesExcept ( )

Helper function that temporarily disables all clickables, except those specified. Useful when you want to set only certain props clickable for a short time. Eg: E.DisableAllClickablesExcept("Ropes","BrokenGlass");

◆ DisableAllClickablesExcept() [2/3]

void DisableAllClickablesExcept ( params string[] exceptions)

Helper function that temporarily disables all clickables, except those specified. Useful when you want to set only certain props clickable for a short time. Eg: E.DisableAllClickablesExcept("Ropes","BrokenGlass");

◆ DisableAllClickablesExcept() [3/3]

void DisableAllClickablesExcept ( params IQuestClickableInterface[] exceptions)

Helper function that temporarily disables all clickables, except those specified. Useful when you want to set only certain props clickable for a short time. Eg: E.DisableAllClickablesExcept("Ropes","BrokenGlass");

◆ RestoreAllClickables()

void RestoreAllClickables ( )

Helper function that restores clickables disabled with the DisableAllClickablesExcept function.

◆ SetAllClickableCursors()

void SetAllClickableCursors ( string cursor,
params string[] exceptions )

Set all clickables to have a specific cursor temporarily, restore using RestoreAllClickableCursors(). Eg: E.SetAllClickableCursors("None", "Ropes","BrokenGlass");

◆ RestoreAllClickableCursors()

void RestoreAllClickableCursors ( )

Resets all clickable cursors after a call to "SetAllClickableCursors".

◆ Set< tEnum >()

void Set< tEnum > ( tEnum enumState)

Sets an enum with the specified value. eg: E.Set(eDoor.Unlocked);.

This is a shortcut that makes c# enums much easier to use for tracking your puzzle stuff.

Usage:

Add your enums to your GlobalScript and/or Room script file headers. Eg:

public enum eDog { Sleeping, Awake, Angry, Fed }
public eDog m_dogState = eDog.Sleeping;

Then use enum functions like this in any PowerQuest script:

Display: You pat the dog.
if ( E.Is(eDog.Fed) )
Display: It licks your hand.
if ( E.After(eDog.Sleeping) && E.Before(eDog.Fed) )
{
Display: It didnt like that!
E.Set(eDog.Angry);
}
See also
Set<tEnum>()
At<tEnum>()
Is<tEnum>()
Before<tEnum>()
Reached<tEnum>()
After<tEnum>()
Type Constraints
tEnum :struct 
tEnum :System.IConvertible 

◆ At< tEnum >()

bool At< tEnum > ( params tEnum[] enumStates)

Returns true if this script has an enum with the specified enum value. Usage: if ( E.At(eSection.GettingMap) ) {...}.

You can check multiple at the same time too. Eg: if ( E.At(eSection.GettingMap, eSection.FindingShovel) )

This is the same as the Is() function and is shorthand for: if ( m_door == eSection.GettingMap ) {...}

See also
Set<tEnum>()
At<tEnum>()
Is<tEnum>()
Before<tEnum>()
Reached<tEnum>()
After<tEnum>()
Type Constraints
tEnum :struct 
tEnum :System.IConvertible 
tEnum :System.IComparable 

◆ Is< tEnum >()

bool Is< tEnum > ( params tEnum[] enumStates)

Returns true if the enum has the specified value. Usage: if ( E.Is(eDoor.Unlocked) ) {...}.

You can check multiple at the same time too. Eg: if ( E.At(eDoor.Unlocked,eDoor.Open) )

This is the same as the At() function and is shorthand for: if ( m_door == eSection.Unlocked ) {...}

See also
Set<tEnum>()
At<tEnum>()
Is<tEnum>()
Before<tEnum>()
Reached<tEnum>()
After<tEnum>()
Type Constraints
tEnum :struct 
tEnum :System.IConvertible 
tEnum :System.IComparable 

◆ Reached< tEnum >()

bool Reached< tEnum > ( tEnum enumState)

Returns true if reached state. Eg: if ( E.Reached(eProgress.FoundTreasure) ). (Shorthand for m_state >= eState.myState )

See also
Set<tEnum>()
At<tEnum>()
Is<tEnum>()
Before<tEnum>()
Reached<tEnum>()
After<tEnum>()
Type Constraints
tEnum :struct 
tEnum :System.IConvertible 
tEnum :System.IComparable 

◆ After< tEnum >()

bool After< tEnum > ( tEnum enumState)

Returns true if passed state. Eg: if ( E.After(eState.EscapedLava) ). (Shorthand for m_state > eState.myState )

See also
Set<tEnum>()
At<tEnum>()
Is<tEnum>()
Before<tEnum>()
Reached<tEnum>()
After<tEnum>()
Type Constraints
tEnum :struct 
tEnum :System.IConvertible 
tEnum :System.IComparable 

◆ Before< tEnum >()

bool Before< tEnum > ( tEnum enumState)

Returns true if haven't reached state. Eg: if ( E.Before(eProgress.FoundTreasure) ). (Shorthand for m_state < eState.myState )

See also
Set<tEnum>()
At<tEnum>()
Is<tEnum>()
Before<tEnum>()
Reached<tEnum>()
After<tEnum>()
Type Constraints
tEnum :struct 
tEnum :System.IConvertible 
tEnum :System.IComparable 

◆ GetSaveSlotData() [1/2]

List< QuestSaveSlotData > GetSaveSlotData ( )

Returns a list of all save slot data.

◆ GetSaveSlotData() [2/2]

QuestSaveSlotData GetSaveSlotData ( int slot)

Returns save slot data for a particular save game. The data has info about the name, etc of the save file.

◆ GetLastSaveSlotData()

QuestSaveSlotData GetLastSaveSlotData ( )

Returns save slot data for the most recenly saved game. The data has info about the name, etc of the save file.

◆ SaveSettings()

bool SaveSettings ( )

Saves game settings (volume, etc). This is a separate file to game saves. It's called already during game save, but can be done when options have changed too (like when leaving options menu)

◆ Save()

bool Save ( int slot,
string description,
Texture2D imageOverride = null )

Saves the game to a particular slot with a particular description. You may also override the image or provide extra slot data if desired, this will override the "Screenshot" that would otherwise be saved.

◆ RestoreSave()

bool RestoreSave ( int slot)

Restores the game from a particular slot.

◆ RestoreLastSave()

bool RestoreLastSave ( )

Restores the last game saved.

◆ DeleteSave()

bool DeleteSave ( int slot)

Deletes a save game from a particular slot.

◆ GetRestoringGame()

bool GetRestoringGame ( )

Returns true if game is in process of being restored from a save file.

Useful in OnEnterAfterFade if you're saving games in OnEnter. eg.

if ( E.GetRestoringGame() == false )
    Save(1,"AutoSave");

Or maybe you need to set something up in OnEnterAfterFade when you restore there. eg.

if ( E.GetRestoringGame() )
    E.FadeOutBG(0);
Display: My eyes adjust to the darkness
E.FadeIn(10);

◆ AddSaveData()

void AddSaveData ( string name,
object data,
System.Action OnPostRestore = null )

Advanced save/restore function: For saving data not in a QuestScript...

To use, call AddSaveData in Start, passing in a name for what you want to save, and the object containing the data you want to save.

If you want to do things when the game is restored, pass the function you want ot be called as OnPostRestore

Notes:

  • The object to be saved must be a class containing the data to be saved (can't just pass in a value type like an int, float or Vector2).
  • By default all data in a class is saved, except for:
    • GameObjects, and MonoBehaviours
    • Variables with the [QuestDontSave] attribute (NOTE: THIS IS NOT YET IMPLEMENTED, BUG DAVE IF NEEDED!)
    • If you store references to other things that shouldnt be saved in your scripts, that may cause problems. Best thing is to dave know, he can add a feature tohelp with that
  • you can add the [QuestSave] attribute to the class
    • When you do that, ONLY the variables that also have the [QuestSave] attribute are saved.
    • You can put this tag on a Monobehaviour class, when you just want to save a few of its variables without having to put them in their own seperate class

Examples saving a simple data class:

class MyComponent : Monobehaviour
{
// Class to store the save data in
class SaveData
{
public int myInt;
public float myFloat;
[QuestDontSave] public bool myNotSavedBool;
}
SaveData m_saveData;
void Start()
{
PowerQuest.Get.AddSaveData( "myData", m_saveData );
}
void OnDestroy()
{
Powerquest.Get.RemoveSaveData("myData");
}
}

Example using the [QuestSave] attribute:

[QuestSave]
class MyComponent : Monobehaviour
{
[QuestSave] int myInt;
[QuestSave] float myFloat;
bool myNotSavedBool;
SaveData m_saveData;
void Start()
{
PowerQuest.Get.AddSaveData( "myData", this );
}
void OnDestroy()
{
Powerquest.Get.RemoveSaveData("myData");
}
}

◆ RemoveSaveData()

void RemoveSaveData ( string name)

Advanced save/restore function: For aving data not in a QuestScript. Call this when you've called AddSaveData, but no longer want to save that data.

◆ GetScript< T >()

T GetScript< T > ( )

PowerQuest internal function: Retrieve a quest script by it's type. So you can access your functions/variables in your own scripts. Eg: E.GetScript<RoomKitchen>().m_tapsOn = true;.

Type Constraints
T :QuestScript