Jump to content

How to isolate strings?


Recommended Posts

I'm sorry, this probably has a very easy answer, but the whole Sky ui github page has none, and I google around other programming sites, but I didn't find an answer, and I don't know the technical terms for my question is so here it goes in the pic. I also tried CreationKit wiki.

 

I want the "SetMenuDialogOptions" command to only show some strings, not all of them.

I tried several ways:

 

Classes={2,3}

Classes=[{2,3}]

Classes=[2,3]

Classes={[2,3]}

 

and I tried without the "="

 

 

I also tried without "classes"

{2,3} [{2,3}] [2,3] {[2,3]}

Edited by TruePooshmeu
Link to comment
Share on other sites

github link you know already: https://github.com/schlangster/skyui/wiki/MCM-API-Reference

SetMenuDialogOptions(string[] options)
Parameters:
    options - The list entries for the menu dialog.

Context:    OnOptionMenuOpen()

snippets of source scripts for SkyUI (subfolder headers)

Scriptname SKI_ConfigBase extends SKI_QuestBase

function SetMenuDialogOptions(string[] a_options)
    {Sets menu dialog parameter(s)}
    Guard()
endFunction

function Guard()
    Debug.MessageBox("SKI_ConfigBase: Don't recompile this script!")
endFunction

SKI_ConfigMenu

 

Scriptname SKI_ConfigMenu extends SKI_ConfigBase

; -- Version 2 --

; Lists
string[]    _categoryIconThemeShortNames
string[]    _categoryIconThemeLongNames                               ; ***
string[]    _categoryIconThemeValues


; -- Version 6 --

; Lists
  string[]    _favGroupNames                        ; *6*


; @implements SKI_QuestBase
event OnVersionUpdate(int a_version)

    ; Version 2
    if (a_version >= 2 && CurrentVersion < 2)
        Debug.Trace(self + ": Updating to script version 2")

        _categoryIconThemeShortNames = new string[4]
        _categoryIconThemeShortNames[0] = "SKYUI V3"
        _categoryIconThemeShortNames[1] = "CELTIC"
        _categoryIconThemeShortNames[2] = "CURVED"
        _categoryIconThemeShortNames[3] = "STRAIGHT"

        _categoryIconThemeLongNames = new string[4]                    ; ***
        _categoryIconThemeLongNames[0] = "SkyUI V3, by PsychoSteve"
        _categoryIconThemeLongNames[1] = "Celtic, by GreatClone"
        _categoryIconThemeLongNames[2] = "Curved, by T3T"
        _categoryIconThemeLongNames[3] = "Straight, by T3T"

        _categoryIconThemeValues = new string[4]
        _categoryIconThemeValues[0] = "skyui\\icons_category_psychosteve.swf"
        _categoryIconThemeValues[1] = "skyui\\icons_category_celtic.swf"
        _categoryIconThemeValues[2] = "skyui\\icons_category_curved.swf"
        _categoryIconThemeValues[3] = "skyui\\icons_category_straight.swf"
    endIf

endEvent


state FAV_GROUP_SELECT ; MENU

    event OnMenuOpenST()
        SetMenuDialogStartIndex(_favCurGroupIdx)
        SetMenuDialogDefaultIndex(0)
        SetMenuDialogOptions(_favGroupNames)        ; *6*
    endEvent

endState


state ITEMLIST_CATEGORY_ICON_THEME ; MENU

    event OnMenuOpenST()
        SetMenuDialogStartIndex(_categoryIconThemeIdx)
        SetMenuDialogDefaultIndex(0)
        SetMenuDialogOptions(_categoryIconThemeLongNames)              ; ***
    endEvent

endState

 

 

Forget classes in picture you attached, simply use array of strings

Edited by ReDragon2013
Link to comment
Share on other sites

either I'm missing something or I didn't explain my needs properly, I already have na array called "classes".

 

"classes" array have several strings already, I want the menu to show only some of those. if "classmainchoice == 2" I want it to show only the class[5] and class[6] for example, not the whole array

 

In the example above he uses two different states, one for each array shown.

Edited by TruePooshmeu
Link to comment
Share on other sites

either I'm missing something or I didn't explain my needs properly, I already have na array called "classes".

 

"classes" array have several strings already, I want the menu to show only some of those. if "classmainchoice == 2" I want it to show only the class[5] and class[6] for example, not the whole array

 

In the example above he uses two different states, one for each array shown.

 

If you had a String[], or an Array of Strings called "Classes"..

 

Classes has 6 indexes, all of which are strings obviously, you'd do:

 

String foo = Classes[5] ; This gives me the 6th string in my String array

 

String bar = Classes[6] ; This gives me an out of bounds index, error

 

String foobar = Classes[4] ; This gives me the 5th String in the array

 

 

But if you wanted to get multiple strings out of the array and store them for use as output you'd use a loop to iterate through the "Classes" array in which you will store the specific indexes you want in another String[], and then output the processed array, or even iterate through the processed array and output every index line by line. This is a very fundamental programming practice.

Edited by TheWhispers
Link to comment
Share on other sites

you mean strings array inside strings array??

 

how am I gonna do it interact with StringList = new string[2] in the mcm script?

 

I need to create a struct?

 

Or do I need to create a double array in the form String[][] = PrimaryStringList , SecondaryStringList

 

Or I declare it String[[]] = PrimaryStringList[SecondaryStringList]

 

 

String[[]] = PrimaryStringListN1[SecondaryStringListN1]

String[[]] = PrimaryStringListN1[SecondaryStringListN2]

String[[]] = PrimaryStringListN1[SecondaryStringListN3]

String[[]] = PrimaryStringListN2[SecondaryStringListN1]

String[[]] = PrimaryStringListN2[SecondaryStringListN2]......

.

.

.

.

.

 

So I can use something like this> PrimaryString[SecondaryString[Choice]]

 

How in hell will I declare a string array inside a string array and how do I make it na mcm entry list?

Edited by TruePooshmeu
Link to comment
Share on other sites

S

 

you mean strings array inside strings array??

 

how am I gonna do it interact with StringList = new string[2] in the mcm script?

 

I need to create a struct?

 

Or do I need to create a double array in the form String[][] = PrimaryStringList , SecondaryStringList

 

Or I declare it String[[]] = PrimaryStringList[SecondaryStringList]

 

 

String[[]] = PrimaryStringListN1[SecondaryStringListN1]

String[[]] = PrimaryStringListN1[SecondaryStringListN2]

String[[]] = PrimaryStringListN1[SecondaryStringListN3]

String[[]] = PrimaryStringListN2[SecondaryStringListN1]

String[[]] = PrimaryStringListN2[SecondaryStringListN2]......

.

.

.

.

.

 

So I can use something like this> PrimaryString[SecondaryString[Choice]]

 

How in hell will I declare a string array inside a string array and how do I make it na mcm entry list?

 

String[[]] isn't a valid type, probably in any language. I thought we were talking about papyrus.

I'm kind of confused on exactly what you are trying to do.

Link to comment
Share on other sites

So your problem is that in vanilla papyrus, it's not possible to take a "slice" of an array. But if you make SKSE and PapyrusUtil dependencies of your mod, you can use their functions to get what you want:

String[] Classes
int ClassesMainChoice

event OnConfigInit()
    int ClassesLength = 6
    Classes = Utility.CreateStringArray(ClassesLength); a SKSE function

    Classes[0] = "String 1"
    Classes[1] = "String 2"
    Classes[2] = "String 3"
    Classes[3] = "String 4"
    Classes[4] = "String 5"
    Classes[5] = "String 6"
    ; notice how 0 == "String 1", 2 == "String 3", and 6 == none
endEvent

; ...

event OnOptionMenuOpen()
    if ClassesMainChoice == 0
        SetMenuDialogOptions(Classes)
        ; all choices are available: "String 1" through "String 6"
    elseIf ClassesMainChoice == 1
        int FromIndex = 2
        int ToInclusiveIndex = Classes.length - 1
        String[] ChoiceClasses = PapyrusUtil.SliceStringArray(Classes, FromIndex, ToInclusiveIndex); a PapyrusUtil function
        SetMenuDialogOptions(ChoiceClasses)
        ; 4 choices are available: "String 3" through "String 6"
    elseIf ClassesMainChoice == 2
        int FromIndex = 5
        int ToInclusiveIndex = Classes.length - 1
        String[] ChoiceClasses = PapyrusUtil.SliceStringArray(Classes, FromIndex, ToInclusiveIndex); a PapyrusUtil function
        SetMenuDialogOptions(ChoiceClasses)
        ; 1 choice is available: "String 6"
    endIf
endEvent

Just remember, not only do you have to install SKSE and PapyrusUtil, but your users do too.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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