Trying to use OBSE "call" to play sounds effects.

Post » Fri Aug 13, 2010 1:38 pm

I ran out of lines in a script so I am trying to run a sound effect script subroutine using "call" as it will be many many lines of script.

So in an object script I do this but get an error saying it expects an integer:

if aaDPSCABOWSWAYquest.RaceIndex != 999call aaDPVocalizationOfCriticalHit justafakeendif



In the "function" object script I am doing this:

ScriptName aaDPVocalizationOfCriticalHitRef PRaceshort JustAFakeBegin Function {JustAFake}if aaDPSCABOWSWAYquest.RaceIndex == 999   returnendif;-------------------if aaDPSCABOWSWAYquest.RaceIndex == 0   set PRace to Player.GetRace      if PRace == orc         set aaDPSCABOWSWAYquest.RaceIndex to 1         elseif PRace == nord         set aaDPSCABOWSWAYquest.RaceIndex to 2      endif        if player.isfemale == 1         set aaDPSCABOWSWAYquest.RaceIndex to aaDPSCABOWSWAYquest.RaceIndex * 10       endifendif;---------------if aaDPSCABOWSWAYquest.RaceIndex == 1   playsound aadpMCHImp   elseif aaDPSCABOWSWAYquest.RaceIndex == 10   playsound aadpFCHImpendifset aaDPSCABOWSWAYquest.RaceIndex to 0end

User avatar
Cathrin Hummel
 
Posts: 3399
Joined: Mon Apr 16, 2007 7:16 pm

Post » Fri Aug 13, 2010 12:14 am

Never mind I figured it out!

It now works as I wanted it to! :hubbahubba:

He he he..this OBSE "call" function thingamajig is really cool!



if aaDPSCABOWSWAYquest.RaceIndex != 999set justafake to aaDPSCABOWSWAYquest.RaceIndexcall aaDPVocalizationOfCriticalHit justafakeendif




ScriptName aaDPVocalizationOfCriticalHitRef PRaceshort JustAFakeBegin Function {JustAFake}if JustAFake == 999returnendif;-------------------if JustAFake == 0set PRace to Player.GetRaceif PRace == Bretonset JustAFake to 1elseif PRace == Imperialset JustAFake to 1elseif PRace == nordset JustAFake to 2endif if player.isfemale == 1set JustAFake to JustAFake * 10endifendif;---------------if JustAFake == 1playsound aadpMCHImpelseif JustAFake == 10playsound aadpFCHImpendifset JustAFake to 0end

User avatar
Queen
 
Posts: 3480
Joined: Fri Dec 29, 2006 1:00 pm

Post » Fri Aug 13, 2010 1:06 am

Why don't you pass the race index as a parameter to the function instead ? Nothing wrong in not doing so but that's what parameters are for after all.
User avatar
Samantha Wood
 
Posts: 3286
Joined: Sun Oct 15, 2006 5:03 am

Post » Fri Aug 13, 2010 3:14 am

huh? :blink:

yeah...that is what I did, see my previous post where said I figured it out on my own and I show my new fixed script.

or... maybe I do not understand what you mean.

if aaDPSCABOWSWAYquest.RaceIndex != 999set justafake to aaDPSCABOWSWAYquest.RaceIndexcall aaDPVocalizationOfCriticalHit justafakeendif



Why don't you pass the race index as a parameter to the function instead ? Nothing wrong in not doing so but that's what parameters are for after all.

User avatar
Lady Shocka
 
Posts: 3452
Joined: Mon Aug 21, 2006 10:59 pm

Post » Fri Aug 13, 2010 1:58 am

huh? :blink:

yeah...that is what I did, see my previous post where said I figured it out on my own and I show my new fixed script.

or... maybe I do not understand what you mean.
Ah, my apologies - I must have read the wrong post :facepalm:

You can pass aaDPSCABOWSWAYquest.RaceIndex as the parameter directly too:
call aaDPVocalizationOfCriticalHit aaDPSCABOWSWAYquest.RaceIndex

User avatar
sara OMAR
 
Posts: 3451
Joined: Wed Jul 05, 2006 11:18 pm

Post » Fri Aug 13, 2010 12:55 am

oh, yes thanks that is good to know!

wow thanks very much!

I am only understanding about 60% of this Call command as the documentation is not "layman friendly".
(I am not sure how to make it calc numbers then return the data back to the calling script) but I do like it so far just for running additional lines of script in a "full" script.

Ah, my apologies - I must have read the wrong post :facepalm:

You can pass aaDPSCABOWSWAYquest.RaceIndex as the parameter directly too:
call aaDPVocalizationOfCriticalHit aaDPSCABOWSWAYquest.RaceIndex


User avatar
Bambi
 
Posts: 3380
Joined: Tue Jan 30, 2007 1:20 pm

Post » Fri Aug 13, 2010 12:05 pm

I am only understanding about 60% of this Call command as the documentation is not "layman friendly".
(I am not sure how to make it calc numbers then return the data back to the calling script) but I do like it so far just for running additional lines of script in a "full" script.

Yeah, sorry, I fail at documentation.
To return a value from a function use SetFunctionValue
scn Squarefloat argbegin Function { arg }  ; do stuff  SetFunctionValue arg*arg  ; do other stuff, if you wantend

scn someOtherScript...set someVar to call Square 5print "5 * 5 = " + $someVar

Hope this helps.
User avatar
Laura Wilson
 
Posts: 3445
Joined: Thu Oct 05, 2006 3:57 pm

Post » Fri Aug 13, 2010 5:45 am

Hello everyone,

the "call" function is a GREAT tool for scripters, thanks for that! One thing I could wish for would only be a possibility to return more than one variable from the called function.

cheers,
brucevayne
User avatar
CRuzIta LUVz grlz
 
Posts: 3388
Joined: Fri Aug 24, 2007 11:44 am

Post » Fri Aug 13, 2010 10:37 am

Hello everyone,

the "call" function is a GREAT tool for scripters, thanks for that! One thing I could wish for would only be a possibility to return more than one variable from the called function.

cheers,
brucevayne
Just use an array for that, with each index containing one of the values returned.
User avatar
electro_fantics
 
Posts: 3448
Joined: Fri Mar 30, 2007 11:50 pm

Post » Fri Aug 13, 2010 1:37 pm

I haven't thought about that, thanks kyoma. Arrays are still an 'unexplored' area I planed to venture in one day. It seems that day has finally came.

Btw, I've just discovered your MiniMap mod. Nice!

cheers,
brucevayne
User avatar
Prue
 
Posts: 3425
Joined: Sun Feb 11, 2007 4:27 am

Post » Fri Aug 13, 2010 10:04 am

Arrays are still an 'unexplored' area I planed to venture in one day. It seems that day has finally came.
Expect to rewrite Fearsome Magicka when you're done ;)
User avatar
Dan Endacott
 
Posts: 3419
Joined: Fri Jul 06, 2007 9:12 am

Post » Fri Aug 13, 2010 3:37 am

It does help and thank you.

Please do not take my comment about the documentation as critization of your skills to write.
Did you intend the documentation to be able to explain the new OBSE power commands to a programing "lay person" like me?

I think my confusion is more a critization of my skills not yours.


critization (Sp?) is that a real word?


Yeah, sorry, I fail at documentation.
To return a value from a function use SetFunctionValue
scn Squarefloat argbegin Function { arg }  ; do stuff  SetFunctionValue arg*arg  ; do other stuff, if you wantend

scn someOtherScript...set someVar to call Square 5print "5 * 5 = " + $someVar

Hope this helps.

User avatar
James Rhead
 
Posts: 3474
Joined: Sat Jul 14, 2007 7:32 am


Return to IV - Oblivion