Jump to content

Conditional Arrays? Workarounds?


FrankFamily

Recommended Posts

I have a Bool array and i wanted to use it's values as conditions for a message through the use of GetVMQuestVariable, the quest has the conditional keyword and the arrays too but they don't appear on the list when i choose GetVMQuestVariable. I have tested with a non-array on the same quest and it works so i guess arrays cannot be used for that... Quite dissapointing, thought arrays would work just like any other property.

 

Is there any workaround for that? I have to work with arrays, that can't change, but maybe once the array is setup i could set a bunch of variables to each value of the array and use those for the conditionals, sort of "translating" the array. The length of the arrays won't change so i can have a fixed number of variables (2 arrays of 9 elements, so 18 more properties). It would be something like this:

Bool Property Element0 Auto Conditional
Bool Property Element1 Auto Conditional
...
Bool Property Elementn Auto Conditional

Bool[] Property MyArray Auto Conditional

Function TranslateArray(Bool[] Array) ; haven't used arrays for parameters of functions yet, is that right?
 Element0 = Array[0]
 Element1 = Array[1]
...
 Elementn = Array[n]
EndFunction

Any better ideas?

 

Wondering why does it let me compile it if it doesn't work...

 

Thanks in advance.

Edited by FrankFamily
Link to comment
Share on other sites

You've pretty well nailed the way to do it.

GetVMQuestVariable doesn't work with arrays which is painful.

 

Myself I create a function in the same script as the Conditionals to set their value.

I don't bother making the conditional variables a property.

CK wiki says conditionals need to be a property, but that isn't the case at all.

If the conditionals need to be updated from another script i just call the function in the conditional script.

I also keep an array or an array of delimited strings of values in the conditional script.

This way I can let my other scripts set the values in the array or a delimited string, then i call the update conditional function which uses the array or delimited string.

 

Examples of how I handled it can be seen in my Be Trainer Vendor (aka BTV) mod.

So I could let the user assign what dialogue the npc will offer.

 

You could take a look at it yourself if you like, the source is in the bsa.

In BTV I used a delimited string in an array.

 

So for example I have 18 Trainer dialogue options.

In my famework i could have any amount of NPCS and each NPC can be set to offer different dialogue options.

So each element of the the array represents a NPC and has a delimited string that when split makes an array with 18 values.

So the user set each NPC to offer different dialogue options to each other.

 

Basically my conditional function sets the the conditional values as needed depending on who you initiate the dialogue with.

 

This for example would be just a one way to do it.

From your other script you set the TCA array values in your conditional script.

Then update the conditional values as needed by calling the function.

So for example on your dialogue root you have the UpdateConditional() function called and any dialogue info pages on the root have the GetVMQuestVariable variable on each.

 

Scriptname AAAmyTest_QuestScript Extends Quest Conditional

Int[] Property TCA Auto Hidden

Int T00 Conditional
Int T01 Conditional
Int T02 Conditional
Int T03 Conditional
Int T04 Conditional
Int T05 Conditional
Int T06 Conditional
Int T07 Conditional
Int T08 Conditional
Int T09 Conditional
Int T10 Conditional
Int T11 Conditional
Int T12 Conditional
Int T13 Conditional
Int T14 Conditional
Int T15 Conditional
Int T16 Conditional
Int T17 Conditional

Event OnInit()
    ;initialize the array if it isn't already
    If TCA.Length < 18
        TCA = New Int[18]
    EndIf
EndEvent

Function UpdateConditional()
    ; This just in case for some reason the array hasn't been initialized
    If TCA.Length < 18
        TCA = New Int[18]
    EndIf
    T00 = TCA[0]
    T01 = TCA[1]
    T02 = TCA[2]
    T03 = TCA[3]
    T04 = TCA[4]
    T05 = TCA[5]
    T06 = TCA[6]
    T07 = TCA[7]
    T08 = TCA[8]
    T09 = TCA[9]
    T10 = TCA[10]
    T11 = TCA[11]
    T12 = TCA[12]
    T13 = TCA[13]
    T14 = TCA[14]
    T15 = TCA[15]
    T16 = TCA[16]
    T17 = TCA[17]
EndFunction
Edited by sLoPpYdOtBiGhOlE
Link to comment
Share on other sites

Yep Conditional script variables that aren't properties can still be accessed (read only) from Condition functions.
Obviously nothing else from outside the script can read/access those conditionals if they aren't properties.

I actually discovered it while reading the vanilla bard song quest script and saw the a bard song Scene was accessing the non property conditionals .
Saw beth was doing it for the loop song settings :smile:

Edited by sLoPpYdOtBiGhOlE
Link to comment
Share on other sites

  • Recently Browsing   0 members

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