Weird PlaySound Error

Blitz3D Forums/Blitz3D Beginners Area/Weird PlaySound Error

_PJ_(Posted 2010) [#1]
I am getting a "Not Enough parameters" error with PlaySound()"
Previously, IDEal didn't like the syntax of PlaySound without the parenthesis, which I recall used to cause issues with non wav formts, but even with:

PlaySound(ExplodeSound)


The compiler halts at this line (colummn 2 apparently)

All that I think could be relevant is here:
Global SoundDir$=Root$+"Media\Audio\"
;...
Global ExplodeSoundFile$=SoundDir$+"Explode.ogg"
;...
Global ExplodeSound
;...
InitialiseResources
;...
Function InitialiseResources()
	PlayerBulletSound=BuildSound(PlayerBulltSoundFile$)
	InvaderBulletSound=BuildSound(InvaderBulletSoundFile$)
	ExplodeSound=BuildSound(ExplodeSoundFile$)
End Function	
;...
Function BuildSound(Filename$)
	Local Sound=LoadSound(Filename$)
	If (Not(Sound)) Then RuntimeError("Cannot Read from "+Filename$)
	Return Sound
End Function
;...
Function DestroyEntity(Entity)
	PlaySound(ExplodeSound)  ; This is the error line from the compiler.
	HideEntity
	AddExplosion(Entity)
End Function	



Floyd(Posted 2010) [#2]
When I paste this into IDEal and try to compile it says not enough parameters and points to HideEntity, line 23.

This may be the error I get most frequently, usually something like

TurnEntity 0, 5, 0

Which entity? The one I'm thinking of you stupid computer!


Kryzon(Posted 2010) [#3]
You need to specify the entity's handle.
The computer can't read your mind, so you need to tell it which entity you're thinking of:
HideEntity(EntityToBeHidden)
TurnEntity(EntityToBeTurned,P,Y,R)


How do you get a handle? it's the value that's returned when you create a primitive or load a mesh:
Entity = LoadMesh("...")
Entity = CreateCube()
etc.

Then, you use this handle like above.
HideEntity Entity  ;If there isn't anything more on the line, the parentheses are not required.



_PJ_(Posted 2010) [#4]
Doh! Yeah, Silly me for not seeing that. WEspecially as it was RIGHT UNDER the line the compiler breaks on.

Turns out, of course, that yep, that was the real issue :D

Thanks guys!


Kryzon(Posted 2010) [#5]
Don't worry, some of us have tried to code under the influence too.


_PJ_(Posted 2010) [#6]
Doesn't make me feel better.. I was stone cold sober :(

Unless caffeine and tiredness counts :D