AggrorJorn Posted November 7, 2010 Share Posted November 7, 2010 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 Quote Link to comment Share on other sites More sharing options...
macklebee Posted November 7, 2010 Share Posted November 7, 2010 Look at how the original environment_sound script works. It sets the source to nil every time the keys are unlocked then creates the sound again. You would have to do the same thing as well to prevent multiples. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
AggrorJorn Posted November 8, 2010 Author Share Posted November 8, 2010 thanks for the answer Macklebee. This 'Unlocking' thing, does that occur everytime when you open the properties menu for a model? Quote Link to comment Share on other sites More sharing options...
macklebee Posted November 9, 2010 Share Posted November 9, 2010 thanks for the answer Macklebee. This 'Unlocking' thing, does that occur everytime when you open the properties menu for a model? Here are the stages of how the object scripts work with the normal class/object functions: 1) Placing the model into the scene for the first time: Creating class whatever Creates the object Gets the Keys Sets the Keys Unlocks the Keys 2) Opening the model's property dialog: Adds the properties to dialog Gets the Keys 3) Pressing the APPLY button in the property dialog: Gets the Keys Sets the Keys Unlocks the Keys 4) Deleting the model from the scene: Freeing class whatever Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.