I am making this alarm thingoid were you pick your own sound. Sound file plays in a loop but every time you open the properties window, the sound start playing in another track (so the sound file is playing twice at the same time).
require("scripts/class")
local class=CreateClass(...)
--Create the Rotation speed tab and property
function class:InitDialog(grid)
self.super:InitDialog(grid)
alarmTab = grid:AddGroup("Alarm")
alarmTab:AddProperty("alarmsound", PROPERTY_FILE,"Wav Files (*.wav):wav;Ogg Vorbis (*.ogg):ogg", "Alarm Sound")
alarmTab:Expand(1)
end
--Create the object as soon as it is dragged in to the editor
function class:CreateObject(model)
local object=self.super:CreateObject(model)
--when property values are changed in the property layout, you need to apply them with SetKey()
function object:SetKey(key,value)
--the alarmsound key gets a new value (or path) assigned.
if key=="alarmsound" then
self.alarmsound = value
end
return 1
end
--use the values from the 'keys' to do things in the scene.
function object:GetKey(key,value)
if key=="alarmsound" then
if self.alarmsound ~= nil then
soundFile = LoadSound("abstract::"..self.alarmsound)
self.model:EmitSound(soundFile,8,1,1)
end
end
return value
end
end
end