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

Post » Wed Nov 30, 2011 4:21 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
Max Van Morrison
 
Posts: 3503
Joined: Sat Jul 07, 2007 4:48 pm

Post » Wed Nov 30, 2011 3:32 pm

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
Darian Ennels
 
Posts: 3406
Joined: Mon Aug 20, 2007 2:00 pm

Post » Wed Nov 30, 2011 11:08 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
CHangohh BOyy
 
Posts: 3462
Joined: Mon Aug 20, 2007 12:12 pm

Post » Wed Nov 30, 2011 10:47 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
Alyna
 
Posts: 3412
Joined: Wed Aug 30, 2006 4:54 am

Post » Wed Nov 30, 2011 11:37 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
Laura Hicks
 
Posts: 3395
Joined: Wed Jun 06, 2007 9:21 am

Post » Wed Nov 30, 2011 12:21 pm

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
chirsty aggas
 
Posts: 3396
Joined: Wed Oct 04, 2006 9:23 am

Post » Wed Nov 30, 2011 1:11 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
CORY
 
Posts: 3335
Joined: Sat Oct 13, 2007 9:54 pm

Post » Wed Nov 30, 2011 7:52 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
x_JeNnY_x
 
Posts: 3493
Joined: Wed Jul 05, 2006 3:52 pm

Post » Wed Nov 30, 2011 2:57 pm

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
Adam Porter
 
Posts: 3532
Joined: Sat Jun 02, 2007 10:47 am

Post » Wed Nov 30, 2011 4:13 am

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
Nicole Coucopoulos
 
Posts: 3484
Joined: Fri Feb 23, 2007 4:09 am

Post » Wed Nov 30, 2011 2:06 pm

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
BRIANNA
 
Posts: 3438
Joined: Thu Jan 11, 2007 7:51 pm

Post » Wed Nov 30, 2011 10:54 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
Sophie Payne
 
Posts: 3377
Joined: Thu Dec 07, 2006 6:49 am


Return to IV - Oblivion