LUADOC - Farming Simulator 22

Script v1_7_1_0

Engine v1_7_1_0

Foundation Reference

PlaySampleMixin

Description
Play UI sound sample mixin. Add this mixin to a GuiElement to enable it to play UI sounds. Added methods: GuiElement:setPlaySampleCallback(callback): Set a callback for playing UI sound samples, signature: function(sampleName). GuiElement:playSample(index, count): Called by the decorated GuiElement to play a sound sample using a name from GuiSoundPlayer.SOUND_SAMPLES. GuiElement:disablePlaySample(): Permanently disables playing samples for special cases (i.e. separate sound logic)
Parent
GuiMixin
Functions

addTo

Description
See GuiMixin:addTo().
Definition
addTo()
Code
30function PlaySampleMixin:addTo(guiElement)
31 if PlaySampleMixin:superClass().addTo(self, guiElement) then
32 guiElement.setPlaySampleCallback = PlaySampleMixin.setPlaySampleCallback
33 guiElement.playSample = PlaySampleMixin.playSample
34 guiElement.disablePlaySample = PlaySampleMixin.disablePlaySample
35
36 -- make sure an uninitialized call doesn't blow up by assigning an empty function:
37 guiElement[PlaySampleMixin].playSampleCallback = NO_CALLBACK
38
39 return true
40 else
41 return false
42 end
43end

clone

Description
Clone this mixin's state from a source to a destination GuiElement instance.
Definition
clone()
Code
71function PlaySampleMixin:clone(srcGuiElement, dstGuiElement)
72 dstGuiElement[PlaySampleMixin].playSampleCallback = srcGuiElement[PlaySampleMixin].playSampleCallback
73end

disablePlaySample

Description
Permanently disable playing samples on the decorated GuiElement for special cases.
Definition
disablePlaySample()
Code
65function PlaySampleMixin.disablePlaySample(guiElement)
66 guiElement[PlaySampleMixin].playSampleCallback = NO_CALLBACK
67end

new

Description
Definition
new()
Code
24function PlaySampleMixin.new()
25 return GuiMixin.new(PlaySampleMixin_mt, PlaySampleMixin)
26end

playSample

Description
Request playing a UI sound sample identified by name.
Definition
playSample(table guiElement, string sampleName)
Arguments
tableguiElementGuiElement instance
stringsampleNameSample name, use one of GuiSoundPlayer.SOUND_SAMPLES.
Code
57function PlaySampleMixin.playSample(guiElement, sampleName)
58 if not guiElement.soundDisabled then
59 guiElement[PlaySampleMixin].playSampleCallback(sampleName)
60 end
61end

setPlaySampleCallback

Description
Set a callback to play a UI sound sample.
Definition
setPlaySampleCallback(table guiElement, function callback)
Arguments
tableguiElementGuiElement instance
functioncallbackPlay sample callback, signature: function(sampleName)
Code
49function PlaySampleMixin.setPlaySampleCallback(guiElement, callback)
50 guiElement[PlaySampleMixin].playSampleCallback = callback
51end