Jump to content

Splitting a function into two scripts


Recommended Posts

I've been trying to edit a script in the Lovers with PK.esp, and I get the "max script size reached" warning that prevents me from extending the script (context). I see that there is no OBSE setting or command that lets me extend the script size limit further. I've searched a bit and it seems people handle this issue by splitting their script into two or more scripts. How does one go about doing this? It sounds doable when the two scripts have independent variables and functions, but what I have to do is split a function into multiple scripts.


This is what the code of the script looks like (I removed some illegible comments to make it clearer):

scn xLoversCmnPlayVoice

ref me
short step
short step
short rapev

int ticket

array_var ar

Begin Function { me step rapev }
    let ar := ar_Construct Array
    let ar[0] := step
    let ar[1] := rapev
    set ticket to me.GetItemCount xLoversPkrVoice

    if ticket == 0
        if me.GetIsSex Male
            if xLoversPkrQuest.NS0mEnabled 
                let ar[2] := xLoversPkrQuest.NS0mSeparated
                let ar[3] := xLoversPkrQuest.NS0mREnabled
                let ar[4] := xLoversPkrQuest.NS0mSeparatedR
                let ar[5] := xLoversPkrNs0mN1
                let ar[6] := xLoversPkrNs0mN2
                let ar[7] := xLoversPkrNs0mN3
                let ar[8] := xLoversPkrNs0mN4
                let ar[9] := xLoversPkrNs0mN5
                let ar[10] := xLoversPkrNs0mR1
                let ar[11] := xLoversPkrNs0mR2
                let ar[12] := xLoversPkrNs0mR3
                let ar[13] := xLoversPkrNs0mR4
                let ar[14] := xLoversPkrNs0mR5
                Call xLoversPkrPlayVoiceSub me ar
                if xLoversPkrQuest.MaleSilent == 0
                    me.PlaySound3D NPCHumanGaspMaleStrong
            let ar := ar_Null 
        elseif me.GetIsCreature
            let ar := ar_Null

    if ticket == 0    ;Female
        let ar[2] := xLoversPkrQuest.NS0Separated
        let ar[3] := xLoversPkrQuest.NS0REnabled
        let ar[4] := xLoversPkrQuest.NS0SeparatedR
        let ar[5] := xLoversPkrNs0fN1
        let ar[6] := xLoversPkrNs0fN2
        let ar[7] := xLoversPkrNs0fN3
        let ar[8] := xLoversPkrNs0fN4
        let ar[9] := xLoversPkrNs0fN5
        let ar[10] := xLoversPkrNs0fR1
        let ar[11] := xLoversPkrNs0fR2
        let ar[12] := xLoversPkrNs0fR3
        let ar[13] := xLoversPkrNs0fR4
        let ar[14] := xLoversPkrNs0fR5
        Call xLoversPkrPlayVoiceSub me ar
        let ar := ar_Null    ;Rev92

    if ticket == 1
        let ar[2] := xLoversPkrQuest.NS1Separated
        let ar[3] := xLoversPkrQuest.NS1REnabled
        let ar[4] := xLoversPkrQuest.NS1SeparatedR
        let ar[5] := xLoversPkrNs1N1
        let ar[6] := xLoversPkrNs1N2
        let ar[7] := xLoversPkrNs1N3
        let ar[8] := xLoversPkrNs1N4
        let ar[9] := xLoversPkrNs1N5
        let ar[10] := xLoversPkrNs1R1
        let ar[11] := xLoversPkrNs1R2
        let ar[12] := xLoversPkrNs1R3
        let ar[13] := xLoversPkrNs1R4
        let ar[14] := xLoversPkrNs1R5
        Call xLoversPkrPlayVoiceSub me ar
        let ar := ar_Null    ;Rev92
        return    ;�ˆ—�‚µ‚½‚Ì‚Å‹A‚è‚Ü‚·

;other voicepack blocks that I've omitted for the sake of brevity

    if ticket == 44
        let ar[2] := xLoversPkrQuest.NS44Separated
        let ar[3] := xLoversPkrQuest.NS44REnabled
        let ar[4] := xLoversPkrQuest.NS44SeparatedR
        let ar[5] := xLoversPkrNs44N1
        let ar[6] := xLoversPkrNs44N2
        let ar[7] := xLoversPkrNs44N3
        let ar[8] := xLoversPkrNs44N4
        let ar[9] := xLoversPkrNs44N5
        let ar[10] := xLoversPkrNs44R1
        let ar[11] := xLoversPkrNs44R2
        let ar[12] := xLoversPkrNs44R3
        let ar[13] := xLoversPkrNs44R4
        let ar[14] := xLoversPkrNs44R5
        Call xLoversPkrPlayVoiceSub me ar
        let ar := ar_Null    ;Rev92

    let ar := ar_Null    ;Rev92


What I want to do is get to the block that starts with "ticket == 100" or so. Since I can't extend this script due to size limits, I have to get there in another script. But I'm not sure how to start those new scripts. i.e. what function to call in order to make the game continue the function that begins in the code above. Is there a common way to split such a function into two scripts?


Link to comment




Scn xLoversCmnPlayVoiceSet01


array_var tempArray


Begin Function { tempArray }


    let tempArray [2] := xLoversPkrQuest.NS0mSeparated
let tempArray [3] := xLoversPkrQuest.NS0mREnabled
let tempArray [4] := xLoversPkrQuest.NS0mSeparatedR
let tempArray [5] := xLoversPkrNs0mN1
let tempArray [6] := xLoversPkrNs0mN2
let tempArray [7] := xLoversPkrNs0mN3
let tempArray [8] := xLoversPkrNs0mN4
let tempArray [9] := xLoversPkrNs0mN5
let tempArray [10] := xLoversPkrNs0mR1
let tempArray [11] := xLoversPkrNs0mR2
let tempArray [12] := xLoversPkrNs0mR3
let tempArray [13] := xLoversPkrNs0mR4
let tempArray [14] := xLoversPkrNs0mR5


    SetFunctionValue tempArray


    let tempArray := ar_Null







Thus make one for each (YIKES).... and each with calls like:

let Ar := Call xLoversCmnPlayVoiceSet01 Ar


OR perhaps this...




Scn xLoversCmnPlayVoiceSet


array_var tempArray


Begin Function { tempArray NSSep NSEnable NESepR NS01 NS02 NS03 NS04 NS05 NSR01 NSR02 NSR03 NSR04 NSR05 }


    let tempArray [2] := NSSep
    let tempArray [3] := NSEnable
    let tempArray [4] := NESepR
    let tempArray [5] := NS01
    let tempArray [6] := NS02
    let tempArray [7] := NS03
    let tempArray [8] := NS04
    let tempArray [9] := NS05
    let tempArray [10] := NSR01
    let tempArray [11] := NSR02
    let tempArray [12] := NSR03
    let tempArray [13] := NSR04
    let tempArray [14] := NSR05


    SetFunctionValue tempArray


    let tempArray := ar_Null






Where you only needed one script, but would have a massive call thus:


let Ar := Call xLoversCmnPlayVoiceSet Ar xLoversPkrQuest.NS0mSeparated xLoversPkrQuest.NS0mREnabled xLoversPkrQuest.NS0mSeparatedR xLoversPkrNs0mN1 xLoversPkrNs0mN2 xLoversPkrNs0mN3 xLoversPkrNs0mN4 xLoversPkrNs0mN5 xLoversPkrNs0mR1 xLoversPkrNs0mR2 xLoversPkrNs0mR3 xLoversPkrNs0mR4 xLoversPkrNs0mR5


... that's a long CALL.  But I've seen calls with 20 arguments.



Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...