Lua:Class:xmplayer

From Cheat Engine
Revision as of 00:39, 27 June 2026 by Leunsel (talk | contribs) (Major overhaul of the post.)
Jump to navigation Jump to search

{} Class

class xmplayer

The xmplayer class represents Cheat Engine's built-in XM module player.

The xmplayer object is already defined globally as xmplayer. It does not need to be created manually.

Global Object

<> Lua API Reference

variable xmplayer : xmplayer

The global xmplayer object can be used directly to play, pause, resume, and stop XM files.

Properties

Property Type Description
IsPlaying Boolean Indicates whether xmplayer is currently playing an XM file.
Initialized Boolean Indicates whether xmplayer is actively loaded in memory.

Methods

Method Return Type Description
setVolume(volume) void Sets the XM playback volume.
playXM(filename, noloop OPTIONAL) void Plays an XM file from a filename.
playXM(tablefile, noloop OPTIONAL) void Plays an XM file from a table file.
playXM(stream, noloop OPTIONAL) void Plays an XM file from a stream.
pause() void Pauses XM playback.
resume() void Resumes paused XM playback.
stop() void Stops XM playback.

Method Parameters

setVolume

Parameter Type Description
volume Integer The playback volume to set.

playXM

Parameter Type Description
filename String The path to an XM file.
tablefile TableFile A table file containing XM data.
stream Stream A stream containing XM data.
noloop Boolean OPTIONAL If true, disables looping.

Examples

Check whether xmplayer is initialized

1 print("Initialized: " .. tostring(xmplayer.Initialized))

Play an XM file from disk

1 xmplayer.playXM([[C:\\Music\\module.xm]])

Play an XM file without looping

1 xmplayer.playXM([[C:\\Music\\module.xm]], true)

Set the volume

1 xmplayer.setVolume(50)

Pause and resume playback

1 xmplayer.pause()
2 
3 xmplayer.resume()

Stop playback

1 xmplayer.stop()

Check whether an XM file is playing

1 if xmplayer.IsPlaying then
2   print("XM playback is active")
3 else
4   print("No XM file is currently playing")
5 end

Play an XM file from a table file

1 local tableFile = findTableFile("music.xm")
2 
3 if tableFile ~= nil then
4   xmplayer.playXM(tableFile)
5 end

Play an XM file from a stream

1 local stream = createMemoryStream()
2 stream.loadFromFile([[C:\\Music\\module.xm]])
3 
4 xmplayer.playXM(stream, true)
5 
6 stream.destroy()

Stop current playback before playing another XM file

1 if xmplayer.IsPlaying then
2   xmplayer.stop()
3 end
4 
5 xmplayer.playXM([[C:\\Music\\next_module.xm]])

Main Pages

Core Lua documentation entry points

Lua
Script Engine