play a sound clip on game start from map resources

play a sound clip on game start from map resources

Discuss maps & map creation - from concept to execution to the ever elusive release.

Moderator: Moderators

Post Reply
User avatar
KaiserJ
Community Representative
Posts: 3113
Joined: 08 Sep 2008, 22:59

play a sound clip on game start from map resources

Post by KaiserJ »

i would imagine it's LUA.

i dont even know what that stands for.

Lemur Undercarriage Access
Lesbian Underage Anal
Lithuanian Ukranian Alliance
Leopard Underpants Acquistions.
Lets Undermine America!

if somebody has sort of an idea of how it might be done, post plox! i need you to help me make my christmas present to spring.

santa com is coming to town
User avatar
Pressure Line
Posts: 2283
Joined: 21 May 2007, 02:09

Re: play a sound clip on game start from map resources

Post by Pressure Line »

its 'Lua' not 'LUA', and it doesnt 'stand' for anything (because its not an acronym) it means 'moon' (or 'Moon' if you want to be really pedantic) in Portugese.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: play a sound clip on game start from map resources

Post by lurker »

More or less, you need this:

LuaGaia/main.lua

Code: Select all

VFS.Include("LuaGadgets/gadgets.lua",nil, VFS.BASE)
LuaGaia/Gadgets/play_a_sound.lua

Code: Select all

function gadget:GetInfo()
	return {
		name = "play_a_sound",
		desc = "Plays a sound at game start",
		author = "author",
		date = "2009-11-28",
		license = "Public domain",
		layer = 10,
		enabled = true
	}
end

if not (gadgetHandler:IsSyncedCode()) then

gadget:GameStart()
	Spring.PlaySoundFile("sounds/gamestart.wav")
end

end
User avatar
KaiserJ
Community Representative
Posts: 3113
Joined: 08 Sep 2008, 22:59

Re: play a sound clip on game start from map resources

Post by KaiserJ »

<3 :mrgreen:
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: play a sound clip on game start from map resources

Post by Beherith »

Lol kaiser, just check out my asteroid maps, they all have a music track playing at game start.

If you want to start track when game clock starts, then use the if spring.getgameseconds()>0 expression
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: play a sound clip on game start from map resources

Post by lurker »

Note that I'm not sure if gamestart is called in unsynced, I kind of flipped a coin about putting that 'not' in, remove it if so.
User avatar
Wombat
Posts: 3379
Joined: 15 Dec 2008, 15:53

Re: play a sound clip on game start from map resources

Post by Wombat »

Pressure Line wrote:its 'Lua' not 'LUA'
LUOL
Achilla
Posts: 79
Joined: 24 Aug 2009, 15:17

Re: play a sound clip on game start from map resources

Post by Achilla »

Beherith wrote:Lol kaiser, just check out my asteroid maps, they all have a music track playing at game start.

If you want to start track when game clock starts, then use the if spring.getgameseconds()>0 expression
Just wondering, is it possible in the current Spring build for the sound to play in loop (repeat itself) and not just end after end of the track?
Auswaschbar
Spring Developer
Posts: 1254
Joined: 24 Jun 2007, 08:34

Re: play a sound clip on game start from map resources

Post by Auswaschbar »

Achilla wrote:
Beherith wrote:Lol kaiser, just check out my asteroid maps, they all have a music track playing at game start.

If you want to start track when game clock starts, then use the if spring.getgameseconds()>0 expression
Just wondering, is it possible in the current Spring build for the sound to play in loop (repeat itself) and not just end after end of the track?
Yes. Search the sound forum.
Post Reply

Return to “Map Creation”