Game object

The Game object allows you to access the properties of your game, and the engine itself. There is always one and only Game object available and it's stored in a predefined variable Game.


Methods

Diagnostic functions
LOG Writes a text string to the system log file.
Msg Writes a quick diagnostic message to the screen.
DumpTextureStats Writes texture usage data to a text file in CSV format.
EnableScriptProfiling Starts gathering statistic information on script execution times.
DisableScriptProfiling Stops gathering statistic information on script execution times and writes the results to wme.log and to the debugging console.
Object manipulation
ValidObject Queries whether a given object reference is valid.
UnloadObject Removes an object from memory.
LoadActor Loads a new actor from a file.
LoadActor3D Loads a new 3D actor from a file.
LoadEntity Loads a new entity from a file.
LoadWindow Loads a new window from a file.
ExpandString Expands a given string using the string table.
Music functions
MusicCrossfade Crossfades two music channels
PlayMusic Plays a music.
StopMusic Stops a music playback.
PauseMusic Pauses a music playback.
ResumeMusic Resumes a paused music playback.
SetMusicPosition Sets the music's current playing position.
GetMusicPosition Queries the music's current playing position
IsMusicPlaying Queries whether the music is currently playing
GetMusic Queries the filename of the current music
SetMusicVolume Sets the volume of currently playing music.
GetMusicVolume Queries the music's current volume.
PlayMusicChannel Plays a music in a specified channel.
StopMusicChannel Stops a music playback in a specified channel.
PauseMusicChannel Pauses a music playback in a specified channel.
ResumeMusicChannel Resumes a paused music playback in a specified channel.
SetMusicChannelPosition Sets the music's current playing position in a specified channel.
GetMusicChannelPosition Queries the music's current playing position in a specified channel.
IsMusicChannelPlaying Queries whether the music is currently playing in a specified channel
GetMusicChannel Queries the filename of the current music in a specified channel
SetMusicChannelVolume Sets the volume of currently playing music in a specified channel.
GetMusicChannelVolume Queries the music's current volume in a specified channel.
Script functions
AttachScript Executes a script file and attaches it to the object.
DetachScript Terminates a specified script file and detaches it from an object.
IsScriptRunning Queries whether a specified script file is running and attached to an object.
CanHandleMethod Queries whether the object supports a method of a specified name.
Sound functions
GetSoundLength Queries length of a given sound file
PlaySound Plays a sound. If the filename is omitted, the currently assigned sound is played (if any).
PlaySoundEvent Plays a sound and triggers an event when the sound is over. If the filename is omitted, the currently assigned sound is played (if any).
StopSound Stops the currently playing sound (if any).
PauseSound Pauses the currently playing sound.
ResumeSound Resumes a paused sound playback.
IsSoundPlaying Queries whether a sound playback is in progress.
SetSoundPosition Sets the sound's current playing position.
GetSoundPosition Queries the sound's current playing position
SetSoundVolume Sets a volume of the currently playing sound.
GetSoundVolume Gets a volume of the currently playing sound.
LoadSound Initializes a sound from file and makes it ready to be played.
Sound effects functions
SoundFXNone Removes any sound effect currently assigned to this object.
SoundFXEcho Assigns an echo effect to the sounds played by this object.
SoundFXReverb Assigns a reverb effect to the sounds played by this object.
Event functions
ApplyEvent Applies a named event to the object.
CanHandleEvent Queries whether the object has an event handler for a specified event.
Miscelaneous functions
SkipTo Moves an object to a specified location.
SetMousePos Sets the mouse cursor position.
LockMouseRect Limits the mouse pointer movement to the specified rectangle
QuitGame Quits the current game session.
FileExists Queries whether a given file exists.
GetFileChecksum Computes a CRC32 value of a given file
Screenshot Takes a screenshot of the current game and saves it into a BMP file.
ScreenshotEx Takes an (optionally resized) screenshot of the current game and saves it into a BMP file.
LoadStringTable Loads the string table from a file.
AddSpeechDir Adds a directory to be used when WME automatically looks for speech files.
RemoveSpeechDir Removes a directory from the list of dirs to look for speech files automatically.
Reset Resets the game's persistent data.
OpenDocument Opens a specified document file or internet URL in an associated program.
SetLoadingScreen Sets an image to be displayed while loading a saved game.
SetSavingScreen Sets an image to be displayed while saving the game.
ClearScriptCache Clears the content of the engine script cache.
DisplayLoadingIcon Briefly displays a "loading" icon.
HideLoadingIcon Hides a "loading" icon displayed by DisplayLoadingIcon()
StoreSaveThumbnail Stores the current screen content to be used as a saved game thumbnail.
DeleteSaveThumbnail Releases a stored saved game thumbnail.
Video functions
PlayVideo Plays a given AVI video file
PlayTheora Plays a given Theora video file
Registry functions
RegWriteNumber Writes a given number to the Windows Registry.
RegWriteString Writes a given string to the Windows Registry.
RegReadNumber Reads a numeric value from the Windows Registry.
RegReadString Reads a string value from the Windows Registry.
Save/load functions
SaveGame Saves a game to the given save slot.
LoadGame Loads a game from the given save slot.
IsSaveSlotUsed Queries whether a given save slot is in use.
GetSaveSlotDescription Queries a description of a given save slot.
EmptySaveSlot Empties a given save slot.
Volume functions
SetGlobalSFXVolume Sets the volume of sound effects.
SetGlobalSpeechVolume Sets the volume of speech.
SetGlobalMusicVolume Sets the volume of music.
SetGlobalMasterVolume Sets the master volume.
GetGlobalSFXVolume Gets the current sound effects volume.
GetGlobalSpeechVolume Gets the current speech volume.
GetGlobalMusicVolume Gets the current music volume.
GetGlobalMasterVolume Gets the current master volume.
Cursor functions
SetCursor Sets the standard cursor.
GetCursor Returns the filename of the cursor sprite (or null if no cursor is set)
GetCursorObject Returns a reference to the cursor sprite (or null if no cursor is set)
RemoveCursor Removes the standard cursor.
HasCursor Queries whether the standard cursor is set.
SetActiveCursor Sets the active cursor.
GetActiveCursor Returns the filename of the active cursor sprite (or null if no cursor is set)
GetActiveCursorObject Returns a reference to the active cursor sprite (or null if no cursor is set)
RemoveActiveCursor Removes the active cursor.
HasActiveCursor Queries whether the active cursor is set.
SetWaitCursor Sets the non-interactive cursor.
GetWaitCursor Returns the filename of the non-interactive cursor sprite (or null if no cursor is set)
GetWaitCursorObject Returns a reference to the non-interactive cursor sprite (or null if no cursor is set)
RemoveWaitCursor Removes the non-interactive cursor.
Fading functions
FadeOut Fades the screen out to a specified color.
FadeIn Fades the screen in from a specified color.
GetFadeColor Gets the current fading color.
Scene functions
ChangeScene Loads a specified scene file.
SetSceneViewport Sets scene viewport to specified values.
Responses/inventory
AddResponse Adds a single response sentence to the response box.
AddResponseOnce Adds a single response sentence to the response box. The response is only added once per a dialogue branch.
AddResponseOnceGame Adds a single response sentence to the response box. The response is only added once per a game session.
ResetResponse Revives a previously disabled response.
GetResponse Displays a response box and waits for the player's choice.
GetNumResponses Queries the number of remaining responses in the response box.
ClearResponses Removes any responses previously added to the response box.
GetInventoryWindow Returns a reference to the window object used by the inventory box.
GetResponsesWindow Returns a reference to the window object used by the responses box.
StartDlgBranch Denotes a start of a dialogue branch.
EndDlgBranch Denotes an end of a dialogue branch.
GetCurrentDlgBranch Queries a current dialogue branch name.
LoadResponseBox Reloads a response box from file.
LoadInventoryBox Reloads an inventory box from file.
LoadItems Loads inventory items from a definition file.
Item functions
TakeItem Adds an item into the inventory.
DropItem Removes an item from the inventory.
GetItem Queries an inventory item.
HasItem Queries whether a given item is in inventory of any of this object.
IsItemTaken Queries whether a given item is in inventory of any of the game objects.
QueryItem Queries a specified inventory item of all inventory items currently defined in game
Dynamic object creation
CreateEntity Creates a new entity object.
DeleteEntity Destroys a entity object.
CreateWindow Creates a new window object.
DeleteWindow Destroys a window object.
CreateItem Creates a new inventory item object.
DeleteItem Destroys an item object.
3D characters related
SetShadowImage Sets and image to be used as a simple shadow for 3D characters
GetShadowImage Gets the currently assigned image to be used as a simple shadow for 3D characters
IsShadowTypeSupported Checks the availability of specified shadow type on current computer configuration.
Accessibility
AccOutputText Sends the text to text-to-speech synthesizer

Attributes

Type (read only) Returns always "game"
Accelerated (read only) Returns true if the game currently uses 3D acceleration to display graphics.
CurrentTime (read only) Returns the time elapsed since the game has started.
WindowsTime (read only) Returns the time elapsed since Windows has started.
TextEncoding Specifies text encoding used for in-game texts, 0..ANSI, 1..UTF8
TextRTL Specifies if the game uses right-to-left reading order (for Hebrew and Arabic). Only affects TrueType fonts!
MouseX The current X position of the mouse cursor
MouseY The current Y position of the mouse cursor
MainObject The object which is used for the scene's auto scrolling, can be (set to) null
ActiveObject (read only) Returns the object which is currently under the mouse cursor (or null if there's none)
InventoryObject The object whose inventory is currently displayed.
ScreenWidth (read only) Returns the screen's width in pixels.
ScreenHeight (read only) Returns the screen's height in pixels.
DebugMode (read only) Returns whether the game runs in the debugging mode.
SoundAvailable (read only) Returns whether the sound is available and enabled.
Keyboard (read only) Returns a reference to the Keyboard State object.
Subtitles Specifes whether the speech subtitles are enabled.
VideoSubtitles Specifes whether the AVI/Theora video subtitles are enabled.
SubtitlesSpeed Specifies the speech subtitles speed (in milliseconds per one character)
Scene (read only) Returns a reference to the currently loaded scene object.
SelectedItem Currently selected inventory item (or null for no item).
NumItems (read only) Returns the number of items in the player's inventory.
TotalNumItems (read only) Returns the number of all inventory items currently defined in the game.
SmartItemCursor Specifies whether the mouse cursor with selected item only highlights if the object under mouse can handle the selected item.
TalkSkipButton Specifies which mouse button is used to skip talk lines (0-left button, 1-right button, 2-both buttons, 3-skipping is disabled)
InventoryVisible Specifies whether the inventory box is currently visible.
InventoryScrollOffset Specifies the current scrolling offset of inventory items in the inventory box.
ResponsesVisible (read only) Returns whether a response box is visible (i.e. the game awaits player's choice).
WindowedMode (read only) Returns true if the game runs in windowed mode.
Hwnd (read only) Returns the window handle (HWND) of the game window (only useful for plugin development).
StartupScene The filename of the scene to be loaded when the game starts.
PrevScene (read only) Returns the name of the previous scene.
PrevSceneFilename (read only) Returns the filename of the previous scene.
LastResponse (read only) Returns the text of the most recently selected response.
LastResponseOrig (read only) Returns the text of the most recently selected response in its orignal (non-localized) form.
FPS (read only) Returns the current framerate (in frames per second)
MaxShadowType Specifies the maximum shadow detail to be used throughout the game (0..none, 1..simple, 2..flat, 3..stencil shadows)
Shadows Specifies if shadows are enabled for 3D characters (obsolete, use MaxShadowType)
SimpleShadows Specifies if simple shadows are to be used for 3D characters. This attribute has no effect if real-time shadows are unsupported (obsolete, use MaxShadowType)
SupportsRealTimeShadows (read only) Returns true if the videocard supports real-time shadows (obsolete, use IsShadowTypeSupported())
MaxActiveLights (read only) Returns the maximum number of active lights supported by video card.
HardwareTL (read only) Returns true if the game is taking advantage of hardware transform and lighting.
Direct3DDevice (read only) Returns the pointer to the underlying IDirect3DDevice8/IDirect3DDevice9 object (plugins only)
DirectDrawInterface (read only) Returns the pointer to the underlying IDirectDraw7 object (plugins only)
SaveDirectory (read only) Returns the path where saved games are stored
Frozen (read only) Returns true if the game is currently in frozen state
SoundBufferSize Specifies size of a sound buffer for streaming sounds (such as music), in seconds
SuspendedRendering Specifies whether the game updates screen. Use with caution.
Name The internal name of the object.
Caption The caption of the object.
AccCaption A special caption of the object used for accessibility purposes.
X The X position of the object.
Y The Y position of the object.
Height (read only) Returns the current height of the object. In case of actors and entities the scaling is taken into account.
Filename (read only) Returns the filename.
Ready (read only) Returns whether the object isn't currently performing any action.
Interactive Specifies whether the object recieves user input.
SoundPanning Specifies whether the sounds played by this object are automatically panned depending on object's position on screen.
NonIntMouseEvents Specifies if the object can receive the MouseEntry and MouseLeave events even if the game is in non-interactive mode.
AccTTSEnabled (read only) Accessibility: text-to-speech output is enabled
AccTTSCaptions (read only) Accessibility: text-to-speech output of item captions is enabled
AccTTSTalk (read only) Accessibility: text-to-speech output of spoken lines is enabled
AccTTSKeypress (read only) Accessibility: text-to-speech output of typed keys is enabled
AccKeyboardEnabled (read only) Accessibility: manual highlighting of active items is enabled
AccKeyboardCursorSkip (read only) Accessibility: manual highlighting of active items moves the mouse pointer to the active item
AccKeyboardPause (read only) Accessibility: pausing game using Ctrl+Space is enabled
SuppressScriptErrors Specifies whether WME should display a warning on screen when encountering script runtime error
ChangingScene (read only) Specifies whether scene change is currently in progress
AutorunDisabled Specifies whether the engine blocks Windows AutoRun feature

Low level events

LeftClick The left mouse button has been pressed.
RightClick The right mouse button has been pressed.
MiddleClick The middle mouse button has been pressed.
LeftDoubleClick The left mouse button has been double-clicked.
RightDoubleClick The right mouse button has been double-clicked.
LeftRelease The left mouse button has been released.
RightRelease The right mouse button has been released.
MiddleRelease The middle mouse button has been released.
MouseWheelUp The mouse wheel has been rolled up.
MouseWheelDown The mouse wheel has been rolled down.
Keypress Some key has been pressed. Use the Keyboard variable to find out the details.
BeforeSave The game is about to save its state.
AfterLoad The game just loaded its state.

LOG(Text)

Writes a text string to the system log file.

Parameters

Text
The text string to be written to the system log file.

Remarks

When the game runs in debug mode, it generates a "wme.log" file in the same directory where the project file resides. Using this method you can add your own diagnostic messages to the log file.


Msg(Text)

Writes a quick diagnostic message to the screen.

Parameters

Text
The text string to de displayed on screen.

Remarks

The quick message disappears after a few seconds.


DumpTextureStats(Filename)

Writes texture usage data to a text file in CSV format.

Parameters

Filename
The name of the export file.

Remarks

This method is only available if the game runs in accelerated mode.


EnableScriptProfiling()

Starts gathering statistic information on script execution times.


DisableScriptProfiling()

Stops gathering statistic information on script execution times and writes the results to wme.log and to the debugging console.


ValidObject(Object)

Queries whether a given object reference is valid.

Parameters

Object
An object reference to be tested for validity.

Return value

If the object reference is valid, the return value is true.

Remarks

If you store an object reference in a variable, you can ensure this object is still valid using the ValidObject method. Objects become invalid after they are unloaded from memory (ether explicitly or for example by changing to a different scene).


UnloadObject(Object)

Removes an object from memory.

Parameters

Object
The object to be removed from memory.

Remarks

If you load an object using the Game.LoadActor, Game.LoadEntity and similar methods, you should unload those when you no longer need them to free memory. Otherwise those objects will be released when the game quits.


LoadActor(Filename)

Loads a new actor from a file.

Parameters

Filename
The filename of the actor file to be loaded.

Return value

A reference to the new Actor object. If the method fails, the return value is null.


LoadActor3D(Filename)

Loads a new 3D actor from a file.

Parameters

Filename
The filename of the 3D actor file to be loaded.

Return value

A reference to the new 3D actor object. If the method fails, the return value is null.


LoadEntity(Filename)

Loads a new entity from a file.

Parameters

Filename
The filename of the entity file to be loaded.

Return value

A reference to the new Entity object. If the method fails, the return value is null.


LoadWindow(Filename)

Loads a new window from a file.

Parameters

Filename
Filename of the window definition file to be loaded.

Return value

Returns a reference to a newly created window object or null if the loading fails.


ExpandString(String)

Expands a given string using the string table.

Parameters

String
The text string to be expanded.

Return value

Returns the expanded string.

Remarks

Note that methods such as Actor.Talk() do expand strings automatically, you don't need to expand them yourself.


MusicCrossfade(Channel1, Channel2, Time, SwapChannels)

Crossfades two music channels

Parameters

Channel1
The channel which should fade out
Channel2
The channel which should fade int
Time
A time period in which the channels should be crossfading
SwapChannels
Specifies whether the two channels will be swapped after the crossfading finishes (optional, default=true)

Remarks

There can be always only two channels crossfading at one moment.


PlayMusic(Filename, Looping, LoopStart)

Plays a music.

Parameters

Filename
The filename of the sound file to be played.
Looping
Whether the music should be looped (optional, default = true).
LoopStart
The position where to restart the music when looping, in milliseconds (optional, default = 0).

Return value

If the method succeeds, the return value is true.


StopMusic()

Stops a music playback.

Return value

If the method succeeds, the return value is true.


PauseMusic()

Pauses a music playback.

Return value

If the method succeeds, the return value is true.


ResumeMusic()

Resumes a paused music playback.

Return value

If the method succeeds, the return value is true.


SetMusicPosition(Time)

Sets the music's current playing position.

Parameters

Time
A new playing position (in milliseconds)

Return value

If the method succeeds, the return value is true.


GetMusicPosition()

Queries the music's current playing position

Return value

Returns the current playing position (in milliseconds).


IsMusicPlaying()

Queries whether the music is currently playing

Return value

Returns true if music is playing.


GetMusic()

Queries the filename of the current music

Return value

Returns the current music filename or null if music isn't playing.


SetMusicVolume(Volume)

Sets the volume of currently playing music.

Parameters

Volume
Music volume in percent.

GetMusicVolume()

Queries the music's current volume.

Return value

The volume in percent.


PlayMusicChannel(Channel, Filename, Looping, LoopStart)

Plays a music in a specified channel.

Parameters

Channel
Which music channel to use
Filename
The filename of the sound file to be played.
Looping
Whether the music should be looped (optional, default = true).
LoopStart
The position where to restart the music when looping, in milliseconds (optional, default = 0).

Return value

If the method succeeds, the return value is true.


StopMusicChannel(Channel)

Stops a music playback in a specified channel.

Parameters

Channel
Which music channel to use

Return value

If the method succeeds, the return value is true.


PauseMusicChannel(Channel)

Pauses a music playback in a specified channel.

Parameters

Channel
Which music channel to use

Return value

If the method succeeds, the return value is true.


ResumeMusicChannel(Channel)

Resumes a paused music playback in a specified channel.

Parameters

Channel
Which music channel to use

Return value

If the method succeeds, the return value is true.


SetMusicChannelPosition(Channel, Time)

Sets the music's current playing position in a specified channel.

Parameters

Channel
Which music channel to use
Time
A new playing position (in milliseconds)

Return value

If the method succeeds, the return value is true.


GetMusicChannelPosition(Channel)

Queries the music's current playing position in a specified channel.

Parameters

Channel
Which music channel to use

Return value

Returns the current playing position (in milliseconds).


IsMusicChannelPlaying(Channel)

Queries whether the music is currently playing in a specified channel

Parameters

Channel
Which music channel to use

Return value

Returns true if music is playing.


GetMusicChannel(Channel)

Queries the filename of the current music in a specified channel

Parameters

Channel
Which music channel to use

Return value

Returns the current music filename or null if music isn't playing.


SetMusicChannelVolume(Channel, Volume)

Sets the volume of currently playing music in a specified channel.

Parameters

Channel
Which music channel to use
Volume
Music volume in percent

GetMusicChannelVolume(Channel)

Queries the music's current volume in a specified channel.

Parameters

Channel
Which music channel to use

Return value

The volume in percent.


AttachScript(Filename)

Executes a script file and attaches it to the object.

Parameters

Filename
The filename of the script file to be executed.

Return value

Returns true if the script has been executed succesfuly.

Remarks

Each WME object can have multiple scripts attached.


DetachScript(Filename, KillThreads)

Terminates a specified script file and detaches it from an object.

Parameters

Filename
The filename of the (running) script to be terminated and detached.
KillThreads
Specifies whether to terminate all running threads of this script (optional, default=false)

Return value

Returns true if the script has been detached succesfully.

Remarks

Script threads are currently executed event handlers and methods.


IsScriptRunning(Filename)

Queries whether a specified script file is running and attached to an object.

Parameters

Filename
The filename of the script to be queried.

Return value

Returns true if a specified script file is attached to an object.


CanHandleMethod(MethodName)

Queries whether the object supports a method of a specified name.

Parameters

MethodName
The name of the method to be checked.

Return value

Returns true if the object is able to handle the specified method.


GetSoundLength(SoundFilename)

Queries length of a given sound file

Parameters

SoundFilename
Name of the sound file to be queried

Return value

Returns length of the sound file (in milliseconds).


PlaySound(Filename, Looping, LoopStart)
PlaySound(Looping, LoopStart)

Plays a sound. If the filename is omitted, the currently assigned sound is played (if any).

Parameters

Filename
The filename of the sound file to be played
Looping
Whether the sound should be looped (optional, default = false).
LoopStart
The point from which the sound restarts when looping, in milliseconds (optional, default=0).

Return value

If the method succeeds, the return value is true.


PlaySoundEvent(Filename, EventName)
PlaySoundEvent(EventName)

Plays a sound and triggers an event when the sound is over. If the filename is omitted, the currently assigned sound is played (if any).

Parameters

Filename
The filename of the sound file to be played
EventName
The name of the event to be triggered after the sound finishes.

Return value

If the method succeeds, the return value is true.


StopSound()

Stops the currently playing sound (if any).

Return value

If the method succeeds, the return value is true.


PauseSound()

Pauses the currently playing sound.

Return value

If the method succeeds, the return value is true.


ResumeSound()

Resumes a paused sound playback.

Return value

If the method succeeds, the return value is true.


IsSoundPlaying()

Queries whether a sound playback is in progress.

Return value

If the sound is playing, the return value is true.


SetSoundPosition(Time)

Sets the sound's current playing position.

Parameters

Time
A new playing position (in milliseconds)

Return value

If the method succeeds, the return value is true.


GetSoundPosition()

Queries the sound's current playing position

Return value

Returns the current playing position (in milliseconds).


SetSoundVolume(Volume)

Sets a volume of the currently playing sound.

Parameters

Volume
A new sound volume (in percent).

Return value

If the method succeeds, the return value is true.


GetSoundVolume()

Gets a volume of the currently playing sound.

Return value

Returns the volume of the currently playing sound (in percent).


LoadSound(Filename)

Initializes a sound from file and makes it ready to be played.

Parameters

Filename
The sound file to be loaded

Return value

If the method succeeds, the return value is true.

Remarks

Use this method to pre-cache a sound file. Initializing the sound takes some time and sometimes it's desirable to move all sound initialization to e.g. scene start so that the subsequent PlaySound calls don't slow the game down. That's what LoadSound is for. To play the pre-cached sound simply call PlaySound without specifying a filename, for example SomeObject.PlaySound(false);


SoundFXNone()

Removes any sound effect currently assigned to this object.


SoundFXEcho(WetDryMix, Feedback, LeftDelay, RightDelay)

Assigns an echo effect to the sounds played by this object.

Parameters

WetDryMix
Wet/Dry Mix, in percent (0 to 100)
Feedback
Feedback, in percent (0 to 100)
LeftDelay
Left delay, in milliseconds (1 to 2000)
RightDelay
Right delay, in milliseconds (1 to 2000)

Remarks

Example: actor.SoundFXEcho(50, 50);


SoundFXReverb(InGain, ReverbMix, ReverbTime, HighFreqRTRatio)

Assigns a reverb effect to the sounds played by this object.

Parameters

InGain
In gain, in dB (-96 to 0)
ReverbMix
Reverb mix, in dB (-96 to 0)
ReverbTime
Reverb time, in milliseconds (0.001 to 3000)
HighFreqRTRatio
HighFreq RT Ratio (0.001 to 0.999)

Remarks

Example: actor.SoundFXReverb(0, 0, 2000);


ApplyEvent(EventName)

Applies a named event to the object.

Parameters

EventName
A name of the event to be applied to the object.

Return value

Returns true it the event has been applied succesfuly.


CanHandleEvent(EventName)

Queries whether the object has an event handler for a specified event.

Parameters

EventName
The name of the event to be checked.

Return value

Returns true if the object is able to handle the specified event.


SkipTo(X, Y)

Moves an object to a specified location.

Parameters

X
Destination X coordinate.
Y
Destination Y coordinate.

SetMousePos(X, Y)

Sets the mouse cursor position.

Parameters

X
New X position of the mouse cursor.
Y
New Y position of the mouse cursor.

LockMouseRect(Left, Top, Right, Bottom)

Limits the mouse pointer movement to the specified rectangle

Parameters

Left
Left edge of the mouse-lock rectangle.
Top
Top edge of the mouse-lock rectangle.
Right
Right edge of the mouse-lock rectangle.
Bottom
Bottom edge of the mouse-lock rectangle.

Remarks

Call this method with no parameters (or with four zeros) to unlock the mouse pointer.


QuitGame()

Quits the current game session.


FileExists(Filename)

Queries whether a given file exists.

Parameters

Filename
Filename to be tested.

Return value

If the specified file exists, the return value is true.


GetFileChecksum(Filename, AsHexString)

Computes a CRC32 value of a given file

Parameters

Filename
The file for which the CRC is computed
AsHexString
Specifies whether the checksum value should be returned as a string representing a hexadecimal number (optional, default=false)

Return value

Returns the CRC32 value of a file either as a number or a string with hexadecimal representation of the value. Returns null if the file doesn't exist.


Screenshot(Name)

Takes a screenshot of the current game and saves it into a BMP file.

Parameters

Name
Base name to be used for the generated BMP file (optional, defaults to Game.Name)

Return value

If the method succeeds, the return value is true.


ScreenshotEx(Filename, Width, Height)

Takes an (optionally resized) screenshot of the current game and saves it into a BMP file.

Parameters

Filename
Filename of the BMP file to be created
Width
The resuting width of the screenshot
Height
The resuting height of the screenshot

Return value

If the method succeeds, the return value is true.


LoadStringTable(Filename, ClearOld)

Loads the string table from a file.

Parameters

Filename
Name of the string table to be loaded
ClearOld
Remove the old string from the string table (optional, default=true)

Remarks

The string table is NOT part of the saved game. You need either to ask user for language selection each time the game is started or store the setting in the registry.


AddSpeechDir(Directory)

Adds a directory to be used when WME automatically looks for speech files.

Parameters

Directory
The directory name to look in

Remarks

By default WME looks for speech files in a "speech" directory only.


RemoveSpeechDir(Directory)

Removes a directory from the list of dirs to look for speech files automatically.

Parameters

Directory
The directory to be removed

Reset()

Resets the game's persistent data.

Remarks

This method deletes all scene states, selected responses, sets timer to zero and also clears all global variables, except those holding game objects (such as windows or entities). Use this method if you want to start a new game.


OpenDocument(Filename)

Opens a specified document file or internet URL in an associated program.

Parameters

Filename
The filename of the document file to be opened

Remarks

This method uses the Windows extension associations to run the right program. Note that the document file MUST NOT be stored inside the game packages. It must be a regular file and you must reference it either by full filename or a filename relative to the game directory.


SetLoadingScreen(ImageFilename, PosX, PosY)

Sets an image to be displayed while loading a saved game.

Parameters

ImageFilename
The filename of the image to be used or null
PosX
The X position of the image
PosY
The Y position of the image

SetSavingScreen(ImageFilename, PosX, PosY)

Sets an image to be displayed while saving the game.

Parameters

ImageFilename
The filename of the image to be used or null
PosX
The X position of the image
PosY
The Y position of the image

ClearScriptCache()

Clears the content of the engine script cache.

Remarks

Normally the engine caches compiled scripts so that they don't need to be compiled multiple times. This method allows you to flush the script cache, for example if you generate scripts dynamically and need them to be always re-compiled.


DisplayLoadingIcon(Sprite, X, Y, Persistent)

Briefly displays a "loading" icon.

Parameters

Sprite
The filename of a sprite to be displayed as a loading icon.
X
The X position of the loading icon.
Y
The Y position of the loading icon.
Persistent
Specifies if the icon should stay on screen until HideLoadingIcon() is called (optional, default=false)

Remarks

You can use this function to briefly display a "work-in-progress" symbol; for example call this method before calling a command which takes a long time (loading a window, long animation etc.). The icon is displayed until the script returns control back to the engine, unless the Persistent parameter is set to true. In that case you have to manually hide the icon by calling the Game.HideLoadingIcon() method.


HideLoadingIcon()

Hides a "loading" icon displayed by DisplayLoadingIcon()


StoreSaveThumbnail()

Stores the current screen content to be used as a saved game thumbnail.

Return value

Returns true if the method succeeded.

Remarks

Normally, the game takes a screenshot immediately before saving the game. Sometimes this might be undesirable. Using this method you can control the exact moment when the saved game thumbnail should be generated. It is then used in the nearest subsequent Game.SaveGame() call.


DeleteSaveThumbnail()

Releases a stored saved game thumbnail.

Return value

Returns true if the method succeeded.

Remarks

This method releases any stored saved game thumbnail previously generated using the Game.StoreSaveThumbnail() method.


PlayVideo(Filename, Type, X, Y, FreezeMusic, SubtitleFile)

Plays a given AVI video file

Parameters

Filename
The filename of the AVI file to be played.
Type
Type of display, 0=at a given position, 1=stretched, 2=centered (optional, default=1)
X
X position on screen. Only used when Type is 0 (optional, default=0)
Y
Y position on screen. Only used when Type is 0 (optional, default=0)
FreezeMusic
Specifies whether the background music should be suspended while video is playing (optional, default=true)
SubtitleFile
The .SUB file with subtitles (optional, defaults to [video name].sub)

Return value

If the method succeeds, the return value is true.

Remarks

This method is now deprecated. Use PlayTheora() instead whenever possible.


PlayTheora(Filename, Type, X, Y, FreezeMusic, DropFrames, SubtitleFile)

Plays a given Theora video file

Parameters

Filename
The filename of the Ogg Theora file to be played.
Type
Type of display, 0=at a given position, 1=stretched, 2=centered (optional, default=1)
X
X position on screen. Only used when Type is 0 (optional, default=0)
Y
Y position on screen. Only used when Type is 0 (optional, default=0)
FreezeMusic
Specifies whether the background music should be suspended while video is playing (optional, default=true)
DropFrames
Specifies whether the video playback should drop frames if the playback is too slow (optional, default=true)
SubtitleFile
The .SUB file with subtitles (optional, defaults to [video name].sub)

Return value

If the method succeeds, the return value is true.


RegWriteNumber(Key, Value)

Writes a given number to the Windows Registry.

Parameters

Key
Name of the key to be written
Value
The number to be written

RegWriteString(Key, Value)

Writes a given string to the Windows Registry.

Parameters

Key
Name of the key to be written
Value
The string to be written

RegReadNumber(Key, InitValue)

Reads a numeric value from the Windows Registry.

Parameters

Key
Name of the key to be read from
InitValue
Initial value to be returned if the key doesn't exist (optional, default=null)

Return value

Returns the number read from the Windows Registry.


RegReadString(Key, InitValue)

Reads a string value from the Windows Registry.

Parameters

Key
Name of the key to be read from
InitValue
Initial value to be returned if the key doesn't exist (optional, default=null)

Return value

Returns the string read from the Windows Registry.


SaveGame(Slot, Description)

Saves a game to the given save slot.

Parameters

Slot
Number of the save slot to be used
Description
Description of the saved game

Return value

If the method succeeds, the return value is true.


LoadGame(Slot)

Loads a game from the given save slot.

Parameters

Slot
Number of the save slot to be used

Return value

If the method fails, the return value is false.


IsSaveSlotUsed(Slot)

Queries whether a given save slot is in use.

Parameters

Slot
Number of the save slot to be tested.

Return value

If the save slot is already in use, the return value is true.


GetSaveSlotDescription(Slot)

Queries a description of a given save slot.

Parameters

Slot
Number of the save slot to be queried

Return value

The description of a given save slot.


EmptySaveSlot(Slot)

Empties a given save slot.

Parameters

Slot
Number of the save slot to be emptied.

SetGlobalSFXVolume(Percent)

Sets the volume of sound effects.

Parameters

Percent
A new sound volume (in percent)

Return value

If the method succeeds, the return value is true.


SetGlobalSpeechVolume(Percent)

Sets the volume of speech.

Parameters

Percent
A new speech volume (in percent)

Return value

If the method succeeds, the return value is true.


SetGlobalMusicVolume(Percent)

Sets the volume of music.

Parameters

Percent
A new music volume (in percent)

Return value

If the method succeeds, the return value is true.


SetGlobalMasterVolume(Percent)

Sets the master volume.

Parameters

Percent
A new sound volume (in percent)

Return value

If the method succeeds, the return value is true.


GetGlobalSFXVolume()

Gets the current sound effects volume.

Return value

Returns the sound volume (in percent).


GetGlobalSpeechVolume()

Gets the current speech volume.

Return value

Returns the speech volume (in percent).


GetGlobalMusicVolume()

Gets the current music volume.

Return value

Returns the music volume (in percent).


GetGlobalMasterVolume()

Gets the current master volume.

Return value

Returns the master volume (in percent).


SetCursor(Filename)

Sets the standard cursor.

Parameters

Filename
Filename of a sprite file to be used as a cursor pointer.

Return value

Returns true if the cursor has been set succesfuly.


GetCursor()

Returns the filename of the cursor sprite (or null if no cursor is set)


GetCursorObject()

Returns a reference to the cursor sprite (or null if no cursor is set)


RemoveCursor()

Removes the standard cursor.


HasCursor()

Queries whether the standard cursor is set.

Return value

Returns true if the object has a custom mouse pointer assigned.


SetActiveCursor(Filename)

Sets the active cursor.

Parameters

Filename
Filename of a sprite file to be used as a cursor pointer.

Return value

Returns true if the cursor has been set succesfuly.

Remarks

The "active" cursor is used when the mouse pointer is over an interactive object.


GetActiveCursor()

Returns the filename of the active cursor sprite (or null if no cursor is set)


GetActiveCursorObject()

Returns a reference to the active cursor sprite (or null if no cursor is set)


RemoveActiveCursor()

Removes the active cursor.


HasActiveCursor()

Queries whether the active cursor is set.

Return value

Returns true it the object has a custom mouse pointer assigned.


SetWaitCursor(Filename)

Sets the non-interactive cursor.

Parameters

Filename
Filename of a sprite file to be used as a cursor pointer.

Return value

Returns true if the cursor has been set succesfuly.


GetWaitCursor()

Returns the filename of the non-interactive cursor sprite (or null if no cursor is set)


GetWaitCursorObject()

Returns a reference to the non-interactive cursor sprite (or null if no cursor is set)


RemoveWaitCursor()

Removes the non-interactive cursor.


FadeOut(Duration, TargetRed, TargetGreen, TargetBlue, TargetAlpha)
FadeOutAsync(Duration, TargetRed, TargetGreen, TargetBlue, TargetAlpha)
SystemFadeOut(Duration, TargetRed, TargetGreen, TargetBlue, TargetAlpha)
SystemFadeOutAsync(Duration, TargetRed, TargetGreen, TargetBlue, TargetAlpha)

Fades the screen out to a specified color.

Parameters

Duration
Specifies how long it will take to fade out, in milliseconds (optional, default=500)
TargetRed
The Red component of a target fade color (optional, default=0)
TargetGreen
The Green component of a target fade color (optional, default=0)
TargetBlue
The Blue component of a target fade color (optional, default=0)
TargetAlpha
The Alpha component (opacity) of a target fade color (optional, default=255)

Remarks

The FadeOut method blocks the script execution until the fading is over, while the FadeOutAsync method returns immediately. The SystemFadeOut and SystemFadeOutAsync methods continue fading even after the game enters the system exclusive mode.


FadeIn(Duration, SourceRed, SourceGreen, SourceBlue, SourceAlpha)
FadeInAsync(Duration, SourceRed, SourceGreen, SourceBlue, SourceAlpha)
SystemFadeIn(Duration, SourceRed, SourceGreen, SourceBlue, SourceAlpha)
SystemFadeInAsync(Duration, SourceRed, SourceGreen, SourceBlue, SourceAlpha)

Fades the screen in from a specified color.

Parameters

Duration
Specifies how long it will take to fade in, in milliseconds (optional, default=500)
SourceRed
The Red component of the initial fade color (optional, default=0)
SourceGreen
The Green component of the initial fade color (optional, default=0)
SourceBlue
The Blue component of the initial fade color (optional, default=0)
SourceAlpha
The Alpha component (opacity) of the initial fade color (optional, default=255)

Remarks

The FadeIn method blocks the script execution until the fading is over, while the FadeInAsync method returns immediately. The SystemFadeIn and SystemFadeInAsync methods continue fading even after the game enters the system exclusive mode.


GetFadeColor()

Gets the current fading color.

Return value

Returns the current fading color in the encoded color format.

Remarks

You can use the GetRValue(), GetGValue(), GetBValue() and GetAValue() functions to extract individual color components.


ChangeScene(Filename, FadeOut, FadeIn)

Loads a specified scene file.

Parameters

Filename
Filename of the scene file to be loaded.
FadeOut
Whether the old scene should fade out before the scene change (optional, default = true)
FadeIn
Whether the new scene should fade in after the scene change (optional, default = true)

SetSceneViewport(X, Y, Width, Height)

Sets scene viewport to specified values.

Parameters

X
Viewport X position on screen
Y
Viewport Y position on screen
Width
Viewport width
Height
Viewport width

Remarks

This method affects all scenes (unlike Scene.SetViewport). Call this method without any parameters to set viewport to full screen.


AddResponse(ID, Response, IconFilename, HoverIconFilename, PressedIconFilename, FontFilename)

Adds a single response sentence to the response box.

Parameters

ID
An ID number of this response.
Response
A text of this reponse.
IconFilename
A filename of a sprite for this response (optional).
HoverIconFilename
A filename of a hover sprite for this response (optional).
PressedIconFilename
A filename of a pressed sprite for this response (optional).
FontFilename
Filename of font to be used for this response (optional).

AddResponseOnce(ID, Response, IconFilename, HoverIconFilename, PressedIconFilename, FontFilename)

Adds a single response sentence to the response box. The response is only added once per a dialogue branch.

Parameters

ID
An ID number of this response.
Response
A text of this reponse.
IconFilename
A filename of a sprite for this response (optional).
HoverIconFilename
A filename of a hover sprite for this response (optional).
PressedIconFilename
A filename of a pressed sprite for this response (optional).
FontFilename
Filename of font to be used for this response (optional).

Remarks

The engine will only add the response to the response box if it wasn't selected before by the player in the current dialogue branch. You must denote the dialogue branch using the Game.StartDlgBranch() and Game.EntDlgBranch() to make this method work.


AddResponseOnceGame(ID, Response, IconFilename, HoverIconFilename, PressedIconFilename, FontFilename)

Adds a single response sentence to the response box. The response is only added once per a game session.

Parameters

ID
An ID number of this response.
Response
A text of this reponse.
IconFilename
A filename of a sprite for this response (optional).
HoverIconFilename
A filename of a hover sprite for this response (optional).
PressedIconFilename
A filename of a pressed sprite for this response (optional).
FontFilename
Filename of font to be used for this response (optional).

Remarks

The engine will only add the response to the response box if it wasn't selected before by the player before. You must denote a dialogue branch using the Game.StartDlgBranch() and Game.EntDlgBranch() to make this method work.


ResetResponse(ID)

Revives a previously disabled response.

Parameters

ID
An ID number of response to be revived.

Remarks

If you add a response using the Game.AddResponseOnce() or Game.AddResponseOnceGame() methods, it gets disabled once the player selects it. Use the ResetResponse method to make such response reappear.


GetResponse(AutoSelectLastResp)

Displays a response box and waits for the player's choice.

Parameters

AutoSelectLastResp
Specifies whether the last remaining response should be automatically selected (optional, defaul=false)

Return value

An ID number of the selected response.


GetNumResponses()

Queries the number of remaining responses in the response box.

Return value

Returns the number of responses remaining in the response box.

Remarks

Some of the responses added by the AddResponseOnce or AddResponseOnceGame methods may have not been actually added to the response box. Use this method to find out how many responses currently really are prepared in the response box.


ClearResponses()

Removes any responses previously added to the response box.


GetInventoryWindow()

Returns a reference to the window object used by the inventory box.

Return value

A reference to the inventory window object.


GetResponsesWindow()

Returns a reference to the window object used by the responses box.

Return value

A reference to the responses window object.


StartDlgBranch(DialogueName)

Denotes a start of a dialogue branch.

Parameters

DialogueName
A name of the dialogue branch. Dialogue names should be unique within one script file. The parameter is optional but it's recommended to specify a name.

Remarks

Dialogue branches only need to be explicitly denoted if you want to use the Game.AddResponseOnce() or Game.AddResponseOnceGame() methods.


EndDlgBranch(DialogueName)

Denotes an end of a dialogue branch.

Parameters

DialogueName
A name of the dialogue branch. Dialogue names should be unique within one script file. The parameter is optional; if you don't specify a name, the inner-most dialogue branch is ended.

Remarks

Dialogue branches only need to be explicitly denoted if you want to use the Game.AddResponseOnce() or Game.AddResponseOnceGame() methods.


GetCurrentDlgBranch()

Queries a current dialogue branch name.

Return value

Returns the name of the current dialogue branch (started by the Game.StartDlgBranch method) or returns null if no dialgue branch has been started.


LoadResponseBox(Filename)

Reloads a response box from file.

Parameters

Filename
The response-box definition file to be loaded.

Return value

Returns true if the method succeeded.


LoadInventoryBox(Filename)

Reloads an inventory box from file.

Parameters

Filename
The inventory-box definition file to be loaded.

Return value

Returns true if the method succeeded.


LoadItems(Filename, Merge)

Loads inventory items from a definition file.

Parameters

Filename
The items definition file to be loaded
Merge
The new items will be merged with existing ones (optional, default=false)

Return value

Returns true if the items were successfuly loaded.


TakeItem(ItemName, InsertAfter)

Adds an item into the inventory.

Parameters

ItemName
A name of the item to be added to object's inventory.
InsertAfter
A name of the item which the new item should be inserted after (optional).

DropItem(ItemName)

Removes an item from the inventory.

Parameters

ItemName
A name of the item to be removed from object's inventory.

GetItem(ItemIndex)
GetItem(ItemName)

Queries an inventory item.

Parameters

ItemIndex
An index of a taken item to be queried.
ItemName
A name of an inventory item to be queried.

Return value

A reference to the item object of a given name or at a given index in the inventory.


HasItem(ItemName)
HasItem(ItemObject)

Queries whether a given item is in inventory of any of this object.

Parameters

ItemName
A name of the item to be queried.
ItemObject
Reference to the item object to be queried.

Return value

If the specified item is in the inventory of this object, the return value is true.

Remarks

Note that this method only searches the current object, use the Game.IsItemTaken() method if you want to search all game objects.


IsItemTaken(ItemName)
IsItemTaken(ItemObject)

Queries whether a given item is in inventory of any of the game objects.

Parameters

ItemName
A name of the item to be queried.
ItemObject
Reference to the item object to be queried.

Return value

If the specified item is in the inventory, the return value is true.


QueryItem(ItemName)
QueryItem(ItemIndex)

Queries a specified inventory item of all inventory items currently defined in game

Parameters

ItemName
The name of the item to be queried
ItemIndex
The index of the item to be queried

Return value

Returns a reference to the specified item or null if the item name/index is invalid.

Remarks

To query all available inventory items, create a loop from 0 to Game.TotalNumItems - 1.


CreateEntity(Name)

Creates a new entity object.

Parameters

Name
The name of the entity object (optional)

Return value

Returns a reference to the newly created entity.


DeleteEntity(Entity)

Destroys a entity object.

Parameters

Entity
The entity object to be destroyed

CreateWindow(Name)

Creates a new window object.

Parameters

Name
The name of the window object (optional)

Return value

Returns a reference to the newly created window.


DeleteWindow(Window)

Destroys a window object.

Parameters

Window
The window object to be destroyed

CreateItem(Name)

Creates a new inventory item object.

Parameters

Name
The name of the item object (optional)

Return value

Returns a reference to the newly created item.


DeleteItem(Item)

Destroys an item object.

Parameters

Item
The item object to be destroyed

Remarks

This method permanently destroys the inventory item. You can no longer reference it in methods like TakeItem etc.


SetShadowImage(Filename)

Sets and image to be used as a simple shadow for 3D characters

Parameters

Filename
The filename of an image to be used

Return value

Returns true if the image has been successfuly set.


GetShadowImage()

Gets the currently assigned image to be used as a simple shadow for 3D characters

Return value

Returns the filename of currently assigned shadow image or null if no image is set.


IsShadowTypeSupported(ShadowType)

Checks the availability of specified shadow type on current computer configuration.

Parameters

ShadowType
The shadow type to be queried (0..none, 1..simple, 2..flat, 3..stencil shadows)

Return value

Returns true if the specified shadow type is supported by player's video card.

Remarks

None and simple shadows are always available.


AccOutputText(Text, Type)

Sends the text to text-to-speech synthesizer

Parameters

Text
The text to be converted to speech
Type
Text type (0..caption, 1..speech, 2..keypress)

Remarks

For this method to work, text-to-speech output must be enabled in the accessibility tab of the WME startup settings window.