error in the Wiki concerning PLAY sound?

Post » Tue Jun 19, 2012 6:14 am

So I typed this EXACTLY as it is shown in the example in the Wiki:

int instanceID = mySFX.play(self) ; play mySFX sound from my self
Sound.SetInstanceVolume(instanceID, 0.5) ; play at half volume

see here: http://www.creationkit.com/Play_-_Sound

(I typed it into a working script and got the following error messages when I tried to compile it.)


c:\games\steamapps\common\skyrim\Data\Scripts\Source\temp\aadpMainCombatQuest.psc(70,23): play is not a function or does not exist
c:\games\steamapps\common\skyrim\Data\Scripts\Source\temp\aadpMainCombatQuest.psc(70,4): type mismatch while assigning to a int (cast missing or types unrelated)


Huh? play is not a function ?
Is this an error on the wiki page?
User avatar
Chad Holloway
 
Posts: 3388
Joined: Wed Nov 21, 2007 5:21 am

Post » Tue Jun 19, 2012 8:08 am

Just checking - mySFX is definitely of type "Sound"? What does the rest of the script look like?

Cipscis
User avatar
Joanne
 
Posts: 3357
Joined: Fri Oct 27, 2006 1:25 pm

Post » Tue Jun 19, 2012 5:00 am

oh, sorry I already deleted it because I really perceived the error was in the Wiki.

But it was about like this:

Scriptname aadpMainCombatQuest extends QuestObjectReference mySFXEVENT onInit()				 registerForUpdate(0.2)			if (Game.GetPlayer().Hasspell(aadpSwingStaminaCostAbility) == 0)	  Game.GetPlayer().Addspell(aadpSwingStaminaCostAbility)endifendEVENTEVENT onUpdate()								  if Game.GetPlayer().GetAVpercentage("stamina") <= 0aadpLowStamina.ApplyCrossFade()Game.GetPlayer().Say(OutOfBreath);Game.GetPlayer().Say(OutOfBreath, akActorToSpeakAs = None, abSpeakInPlayersHead = true)int instanceID = mySFX.play(self)		  ; play mySFX sound from my selfSound.SetInstanceVolume(instanceID, 0.5)		 ; play at half volumeendifendEVENT




So it should be

Sound mySFX

not

ObjectReference mySFX

I wish they would say that on the wiki page. I am guessing at the types.


Just checking - mySFX is definitely of type "Sound"? What does the rest of the script look like?

Cipscis
User avatar
Talitha Kukk
 
Posts: 3477
Joined: Sun Oct 08, 2006 1:14 am

Post » Tue Jun 19, 2012 1:52 am

There's your problem - the http://www.creationkit.com/Play_-_Sound function does not exist for the http://www.creationkit.com/ObjectReference_Script type. In your example, you've tried to call Play on a variable (that's not set anywhere that I can see, so it would be set to None) of type ObjectReference, but that function isn't defined in the ObjectReference script or any script that it extends, so the compiler can't find it.

What you'd want to do is use a property of type http://www.creationkit.com/Sound_Script that has its value set to your Sound form in the Creation Kit.

Cipscis
User avatar
Danielle Brown
 
Posts: 3380
Joined: Wed Sep 27, 2006 6:03 am

Post » Tue Jun 19, 2012 6:29 am

nope I tired

SOUND mySFX

and still got this:


c:\games\steamapps\common\skyrim\Data\Scripts\Source\temp\aadpMainCombatQuest.psc(67,24): type mismatch on parameter 1 (did you forget a cast?)
c:\games\steamapps\common\skyrim\Data\Scripts\Source\temp\aadpMainCombatQuest.psc(67,5): type mismatch while assigning to a int (cast missing or types unrelated)
No output generated for aadpMainCombatQuest, compilation failed.
User avatar
Georgia Fullalove
 
Posts: 3390
Joined: Mon Nov 06, 2006 11:48 pm

Post » Tue Jun 19, 2012 6:04 am

Also, once a script gets very big how do you know WHERE the bug is in the script?

In Oblivion you had error that gave you a LINE number as to where the bug was, but not in Skyrim, that is going to get nuts with bigger scripts. :ermm:
User avatar
gemma king
 
Posts: 3523
Joined: Fri Feb 09, 2007 12:11 pm

Post » Tue Jun 19, 2012 9:26 am

See those two numbers in brackets after the path of your script? Those two numbers are the line number and the character number.

In this case, the error is that your script extends the type http://www.creationkit.com/Quest_Script, so it can't be cast to the type http://www.creationkit.com/ObjectReference_Script, which is the type required as the parameter of http://www.creationkit.com/Play_-_Sound. Instead, you need an actual ObjectReference to pass as the parameter of that function, for a location from which the sound should play. If you don't need it to play from a specific location, I expect you could just use the player.

Cipscis
User avatar
Paula Ramos
 
Posts: 3384
Joined: Sun Jul 16, 2006 5:43 am

Post » Tue Jun 19, 2012 4:01 am

OH, I forgot the REF...

:facepalm:


See those two numbers in brackets after the path of your script? Those two numbers are the line number and the character number.

In this case, the error is that your script extends the type http://www.creationkit.com/Quest_Script, so it can't be cast to the type http://www.creationkit.com/ObjectReference_Script, which is the type required as the parameter of http://www.creationkit.com/Play_-_Sound. Instead, you need an actual ObjectReference to pass as the parameter of that function, for a location from which the sound should play. If you don't need it to play from a specific location, I expect you could just use the player.

Cipscis
User avatar
Rachell Katherine
 
Posts: 3380
Joined: Wed Oct 11, 2006 5:21 pm


Return to V - Skyrim