PowerQuest 0.18.9
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

YieldInstruction Break [get]
 yield return this in an empty function (so it doesn't give an error, and doesn't consume an update cycle like a doing "yield break" does) More...
 
YieldInstruction ConsumeEvent [get]
 yield return this if nothing is happening in a function, but you don't want to fall back to an Unhandled Event More...
 
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. More...
 
ICamera Camera [get]
 Convenient shortcut to the game camera. More...
 
ICursor Cursor [get]
 Convenient shortcut to the Cursor. More...
 
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. More...
 
Color FadeColor [get, set]
 Get/Set a temporary fade color. The fade color will be restored to FadeColorDefault after the next fade-in. More...
 
Color FadeColorDefault [get, set]
 Get/Set the default fade color. More...
 
bool Paused [get, set]
 Gets or sets whether the game is paused. More...
 
ICharacter Player [get, set]
 Gets or sets the current player controlled character. More...
 
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 More...
 
int InlineDialogResult [get]
 Retrieves the option that was picked in the last call to WaitForInlineDialog() More...
 
float VerticalResolution [get]
 Returns the currentvertical resolution including any overrides from the current room. More...
 
float DefaultVerticalResolution [get]
 Returns the project's vertical resolution set in PowerQuest. More...
 
QuestSettings Settings [get]
 The game settings object. More...
 
float TransitionFadeTime [get, set]
 Length of time transition between rooms takes. More...
 
string DisplayBoxGui [get, set]
 The name of the gui used for "Display Text". More...
 
string DialogTreeGui [get, set]
 The name of the gui used for Dialog Trees. More...
 
string CustomSpeechGui [get, set]
 The name of the gui used for Custom Speech. More...
 
bool AlwaysShowDisplayText [get, set]
 Whether "Display" text is shown regardless of the DialogDisplay setting. More...
 
eSpeechStyle SpeechStyle [get, set]
 Controls how game speech captions are displayed. More...
 

Public Member Functions

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. More...
 
Coroutine WaitSkip (float time=0.5f)
 Wait for time (or default 0.5 sec). Pressing button will skip the waiting. More...
 
Coroutine WaitForTimer (string timerName, bool skippable=false)
 
Coroutine WaitFor (PowerQuest.DelegateWaitForFunction functionToWaitFor, bool autoLoadQuestScript=true)
 Use this when you want to yield to another function that returns an IEnumerator Usage: yield return E.WaitFor( SimpleExampleFunction ); or yield return E.WaitFor( ()=>ExampleFunctionWithParams(C.Dave, "lol") ); More...
 
Coroutine WaitWhile (System.Func< bool > condition, bool skippable=false)
 Use this when you want to wait until a condition is net. You need the ()=> to Usage: yield return E.WaitWhile( ()=> C.Player.Walking ) More...
 
Coroutine WaitUntil (System.Func< bool > condition, bool skippable=false)
 Use this when you want to wait until a condition is net. You need the ()=> to Usage: yield return E.WaitUntil( ()=> C.Player.Position.x > 0 ) More...
 
Coroutine WaitForDialog ()
 Waits until the current dialog has finished. Useful for waiting to the end of SayBG commands. More...
 
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() More...
 
Coroutine WaitForGui (IGui gui)
 Shows gui and waits for it to disappear. Useful for prompts. More...
 
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(); } ); More...
 
void InterruptNextLine (float secondsBeforeEndOfLine)
 The instruction for the next line of dialog will unblock early by bySeconds seconds. More...
 
void SkipDialog (bool preventEarlySkip=true)
 Skips the current line of dialog,. More...
 
bool SkipCutscene ()
 Skips a currently active cutscene- Returns true if a cutscene was skipped. More...
 
bool GetBlocked ()
 Returns true if there's a blocking script currently running. More...
 
IGui GetFocusedGui ()
 Returns the currently focused gui. More...
 
bool NavigateGui (eGuiNav input=eGuiNav.Ok)
 
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. More...
 
Coroutine Display (string dialog, int id=-1)
 Display narrator dialog. More...
 
Coroutine DisplayBG (string dialog, int id=-1)
 Display narrator dialog (without blocking) More...
 
void StartCutscene ()
 Starts a cutscene. If player presses esc, the game will skip forward until the next EndCutscene() More...
 
void EndCutscene ()
 Ends a cutscene. When plyer presses esc after a "StartCutscene", this is where they'll skip to. More...
 
bool GetSkippingCutscene ()
 Returns true when a cutscene 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. More...
 
Coroutine FadeIn (float time=0.2f, bool skippable=true)
 Fade the screen from the current FadeColor. More...
 
Coroutine FadeOut (float time=0.2f, bool skippable=true)
 Fade the screen to the current FadeColor. More...
 
void FadeInBG (float time=0.2f)
 Fade the screen from the current FadeColor (non-blocking) More...
 
void FadeOutBG (float time=0.2f)
 Fade the screen to the current FadeColor (non-blocking) More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
bool GetFading ()
 Returns true if a fadeout/in is currently active. More...
 
void FadeColorRestore ()
 Return fade color to its default value. More...
 
void Pause (string source=null)
 Pauses the game. Pass a string as a source in case multiple things have paused/unpaused the game. More...
 
void UnPause (string source=null)
 Unpauses the game. Use the same source string you paused the game with (if any). More...
 
void SetTimer (string name, float time)
 
bool GetTimerExpired (string name)
 
float GetTimer (string name)
 Returns the time remaining on the timer with specified name. More...
 
void ChangeRoomBG (IRoom room)
 Change the current room. Same as calling C.Player.Room = room;. More...
 
Coroutine ChangeRoom (IRoom room)
 Change the current room. And blocks until after OnEnterAfterFade of the new room finishes. More...
 
Room GetCurrentRoom ()
 The room the player's in (R.Current) More...
 
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) More...
 
Room GetRoom (string scriptName)
 Retrieve a room by it's name. More...
 
Character GetPlayer ()
 Get the current player controlled character. More...
 
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. More...
 
Character GetCharacter (string scriptName)
 Retrieve a character by it's name. eg E.GetCharacter("Dave"); Usually you would just use C.Dave More...
 
Inventory GetInventory (string scriptName)
 Retrieve an inventory item by it's name. Eg E.GetInventory("Screwdriver");, Usually you would just use I.Screwdriver More...
 
DialogTree GetDialogTree (string scriptName)
 Retrieve the currently active dialog. Eg. E.GetCurrentDialog().OptionOff(1);. Same as D.Current More...
 
Coroutine WaitForInlineDialog (params string[] options)
 
Gui GetGui (string scriptName)
 Retreive a Gui item by it's name. More...
 
GameObject GetSpawnablePrefab (string name)
 Find a prefab to spawn by name. Usage: E.GetSpawnablePrefab("SparkleEffect").Spawn(...);. More...
 
UnityEngine.Camera GetCameraGui ()
 Returns the Gui Camera. More...
 
Canvas GetCanvas ()
 Returns the Gui Canvas. More...
 
Vector2 GetMousePosition ()
 Returns the current mouse position in world space. More...
 
Vector2 GetMousePositionGui ()
 Returns the current mouse position in gui space. More...
 
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. More...
 
eQuestClickableType GetMouseOverType ()
 Returns the type of clickable that the mouse is over as an eQuestClickableType (eg, could be a character, hotspot, etc). More...
 
string GetMouseOverDescription ()
 Returns the display name of the object the mouse is over. More...
 
Vector2 GetLastLookAt ()
 Returns the "Look at" position of the last thing clicked. More...
 
Vector2 GetLastWalkTo ()
 Returns the "Walk To" position of the last thing clicked. More...
 
bool ProcessClick (eQuestVerb verb)
 Starts the specified action for the verb on whatever the mouse is over (whatever the current GetMouseOverClickable() happens to be ). More...
 
bool ProcessClick (eQuestVerb verb, IQuestClickable clickable, Vector2 mousePosition)
 
Coroutine HandleInteract (IHotspot target)
 Runs a "Use Hotspot" sequence. More...
 
Coroutine HandleLookAt (IHotspot target)
 Runs a "Look at Hotspot" sequence. More...
 
Coroutine HandleInventory (IHotspot target, IInventory item)
 Runs a "Use inventory on hostpot" sequence. More...
 
Coroutine HandleInteract (IProp target)
 Runs a "Use Prop" sequence. More...
 
Coroutine HandleLookAt (IProp target)
 Runs a "Look at Prop" sequence. More...
 
Coroutine HandleInventory (IProp target, IInventory item)
 Runs a "Use inventory on Prop" sequence. More...
 
Coroutine HandleInteract (ICharacter target)
 Runs a "Use Character" sequence. More...
 
Coroutine HandleLookAt (ICharacter target)
 Runs a "Look at Character" sequence. More...
 
Coroutine HandleInventory (ICharacter target, IInventory item)
 Runs a "Use inventory on Character" sequence. More...
 
Coroutine HandleInteract (IInventory target)
 Runs a "Use Inventory" sequence. More...
 
Coroutine HandleLookAt (IInventory target)
 Runs a "Look at Inventory" sequence. More...
 
Coroutine HandleInventory (IInventory target, IInventory item)
 Runs a "Use inventory on Inventory" sequence. More...
 
Coroutine HandleOption (IDialogTree dialog, string optionName)
 Runs a specific dialog option. NB: Does NOT start the dialog tree first. More...
 
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. More...
 
bool FirstOccurrence (string uniqueString)
 Registers something "occuring", and returns whether it's the first time it's occurred. More...
 
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. More...
 
int GetOccurrenceCount (string uniqueString)
 Checks how many times something has occurred, without incrementing the occurrence. More...
 
void Restart ()
 Restart the game from the first scene. More...
 
void Restart (IRoom room, string playFromFunction=null)
 Restart the game on a specific scene, optionally with a specific 'playFromFunction'. Useful for testing. More...
 
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"); More...
 
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"); More...
 
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"); More...
 
void RestoreAllClickables ()
 Helper function that restores clickables disabled with the DisableAllClickablesExcept function. More...
 
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"); More...
 
void RestoreAllClickableCursors ()
 Resets all clickable cursors after a call to "SetAllClickableCursors". More...
 
List< QuestSaveSlotData > GetSaveSlotData ()
 Returns a list of all save slot data. More...
 
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. More...
 
QuestSaveSlotData GetLastSaveSlotData ()
 Returns save slot data for the most recenly saved game. The data has info about the name, etc of the save file. More...
 
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) More...
 
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. More...
 
bool RestoreSave (int slot)
 Restores the game from a particular slot. More...
 
bool RestoreLastSave ()
 Restores the last game saved. More...
 
bool DeleteSave (int slot)
 Deletes a save game from a particular slot. More...
 
bool GetRestoringGame ()
 
void AddSaveData (string name, object data, System.Action OnPostRestore=null)
 Advanced save/restore function: For saving data not in a QuestScript... More...
 
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. More...
 
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;. More...
 

Property Documentation

◆ Break

YieldInstruction Break
get

yield return this in an empty function (so it doesn't give an error, and doesn't consume an update cycle like a doing "yield break" does)

◆ ConsumeEvent

YieldInstruction ConsumeEvent
get

yield return this if nothing is happening in a function, but you don't want to fall back to an Unhandled Event

◆ 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()

◆ 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.

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.

◆ WaitFor()

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

Use this when you want to yield to another function that returns an IEnumerator Usage: yield return E.WaitFor( SimpleExampleFunction ); or yield return E.WaitFor( ()=>ExampleFunctionWithParams(C.Dave, "lol") );

Note that it's 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.

Parameters
functionToWaitForA function that returns IEnumerator. Eg: SimpleExampleFunction or, ()=/>ExampleFunctionWithParams(C.Dave, 69) if it has params

◆ WaitWhile()

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

Use this when you want to wait until a condition is net. You need the ()=> to 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. You need the ()=> to 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(); } );

◆ 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 ( )

Starts a cutscene. If player presses esc, the game will skip forward until the next EndCutscene()

See also
StartCutscene
EndCutscene

◆ EndCutscene()

void EndCutscene ( )

Ends 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 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!

            }
        }

    \sa GetTimerExpired \sa 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)

Shows a dialog with the specified text options, and waits until something's selected before continuing. Use IPowerQuest.InlineDialogResult to check what was clicked on afterwards

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();

◆ 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 "occuring", and returns whether it's the first time it's occurred.

Usage: if ( FirstOccurrence("unlockdoor") ) C.Display("You unlock the door"); else C.Display("It's already unlocked");

See also
Occurrence
GetOccurrenceCount

◆ 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 ) C.Display("You knock on the door");

See also
FirstOccurrence
GetOccurrenceCount

◆ GetOccurrenceCount()

int GetOccurrenceCount ( string  uniqueString)

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

Usage: if ( GetOccurrenceCount("knocked on door") == 3 ) C.Doorman("Who's there?");

See also
FirstOccurrence
Occurrrence

◆ Restart() [1/2]

void Restart ( )

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".

◆ 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 ( )

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