Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- Objects
- Placeables
- Player
- Shop
- Sounds
- Specializations
- Triggers
- Utils
- Vehicles
- Weather
Engine v1.7.1.0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- Overlays
- Particle System
- Physics
- JointConstructor:setActors
- JointConstructor:setJointTransforms
- addDifferential
- addForce
- addImpulse
- addTorque
- addTorqueImpulse
- addVehicleLink
- computeWheelShapeTireForces
- createCCT
- createWheelShape
- getAngularDamping
- getAngularVelocity
- getCCTCollisionFlags
- getCenterOfMass
- getCollisionMask
- getDensity
- getLinearDamping
- getLinearVelocity
- getMass
- getMotorRotationSpeed
- getRigidBodyType
- getVelocityAtLocalPos
- getVelocityAtWorldPos
- getVolume
- getWheelShapeAxleSpeed
- getWheelShapeContactForce
- getWheelShapeContactNormal
- getWheelShapeContactObject
- getWheelShapeContactPoint
- getWheelShapePosition
- getWheelShapeSlip
- moveCCT
- overlapBox
- overlapSphere
- raycastAll
- raycastClosest
- removeCCT
- setAngularDamping
- setAngularVelocity
- setCenterOfMass
- setCollisionMask
- setFrictionVelocity
- setJointDrive
- setLinearDamping
- setLinearVelocity
- setMass
- setRigidBodyType
- setSolverIterationCount
- setWheelShapeForcePoint
- setWheelShapeProps
- setWheelShapeTireFriction
- simulatePhysics
- simulatePhysicsTimeScale
- updateDifferential
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- XML
- general
Foundation Reference
GuiSoundPlayer
DescriptionThis class loads known GUI sound samples as non-spatial samples to be played in the GUI (menu and HUD).Functions
loadSounds
DescriptionLoad GUI sound samples from definitions.Definition
loadSounds()Code
55 | function GuiSoundPlayer:loadSounds(sampleDefinitionXmlPath) |
56 | local samples = {} |
57 | |
58 | local xmlFile = loadXMLFile("GuiSampleDefinitions", sampleDefinitionXmlPath) |
59 | if xmlFile ~= nil and xmlFile ~= 0 then |
60 | for _, key in pairs(GuiSoundPlayer.SOUND_SAMPLES) do |
61 | if key ~= GuiSoundPlayer.SOUND_SAMPLES.NONE then |
62 | local sample = self.soundManager:loadSample2DFromXML(xmlFile, GuiSoundPlayer.SOUND_SAMPLE_DEFINITIONS_XML_ROOT, key, "", 1, AudioGroup.GUI) |
63 | if sample ~= nil then |
64 | samples[key] = sample |
65 | else |
66 | print("Warning: Could not load GUI sound sample [" .. tostring(key) .. "]") |
67 | end |
68 | end |
69 | end |
70 | |
71 | delete(xmlFile) |
72 | end |
73 | |
74 | return samples |
75 | end |
new
DescriptionCreate a new GuiSoundPlayer instance.Definition
new(table soundManager)Arguments
table | soundManager | SoundManager reference |
44 | function GuiSoundPlayer:new(soundManager) |
45 | local self = setmetatable({}, GuiSoundPlayer_mt) |
46 | |
47 | self.soundManager = soundManager |
48 | self.soundSamples = self:loadSounds(GuiSoundPlayer.SOUND_SAMPLE_DEFINITIONS_PATH) -- name -> sample |
49 | |
50 | return self |
51 | end |
playSample
DescriptionPlay a GUI sound sample identified by name. The sample must have been loaded when the GUI was created.Definition
playSample(string sampleName)Arguments
string | sampleName | Name of the sample to play, use one of the identifiers in GuiSoundPlayer.SOUND_SAMPLES. |
81 | function GuiSoundPlayer:playSample(sampleName) |
82 | if sampleName ~= GuiSoundPlayer.SOUND_SAMPLES.NONE then |
83 | local sample = self.soundSamples[sampleName] |
84 | if sample ~= nil then |
85 | local canPlay = not self.soundManager:getIsSamplePlaying(sample) |
86 | if canPlay then |
87 | self.soundManager:playSample(sample) |
88 | end |
89 | else |
90 | print("Warning: Tried playing GUI sample [" .. tostring(sampleName) .. "] which has not been loaded.") |
91 | end |
92 | end |
93 | end |