Scripts / Looping Music

Author
Message
Tarkus1971
Audio Media Maker
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: England, UK
Posted: 4th Mar 2015 10:50 Edited at: 4th Mar 2015 10:52
Hi

I can get my music to play using the music LUA, but I need different background music for each level, by triggering a SOUND ZONE but I can't seem to get it work. I am using the a modified soundinzone.lua.... what am i doing wrong Also when using the music lua in standalone the music stops and never restarts after pressing esc key to change options

Attachments

Login to view attachments
Tarkus1971
Audio Media Maker
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: England, UK
Posted: 4th Mar 2015 10:56
erm..... might it be the capital Z in the lua filename.... not on my own pc at the moment so i cant check it
Nuska
9
Years of Service
User Offline
Joined: 28th Feb 2015
Location:
Posted: 4th Mar 2015 14:06
That is the way the script is by default, Enter the trigger zone, perform the action and destroy it self. This is good for one time entry. If you want that zone to stay active, then Copy the script to a new name, remove the Destroy(e) line from the renamed script. Save that file and attach it to the trigger thru the properties panel. LMB on the objet and choose properties. you will see towards the top of that panel the spot where you can change the script being called.

-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Player Enters Sound Zone
function
soundinzone_init(e) must ( soundinzoneZ1) the name off the script
end
function
soundinzone_main(e) must ( soundinzoneZ1) the name off the script
if g_Entity[e]['plrinzone']==1
then LoopSound(e,50)
Destroy(e) must remove from the script so now play 1 x then destroyt the sound zone
ActivateIfUsed(e)
end
end
PM
Big Dog Game Studios
12
Years of Service
User Offline
Joined: 18th Jun 2012
Location: Port Angeles, WA
Posted: 6th Mar 2015 05:17 Edited at: 6th Mar 2015 22:52
Actually, you are using the wrong script. In order to get it to work correctly, place a sound zone right over the player spawn area. Edit the properties of the trigger. Set the music you want played in the sound section. Replace the script in main with musicinzone.lua which has a continuous loop and will keep looping your music. I have it for my levels and it works just fine

Login to post a reply

Server time is: 2024-12-21 14:33:43
Your offset time is: 2024-12-21 14:33:43