Jump to content

[MCM scripting] how to properly do versioning?


3aq

Recommended Posts

Actually, as you have both versions right now, neither one would compile in the CK. In version one it would complain that variable a_01 within the OnPageReset event and draw_a function were undefined. This because the declaration String a_01 = "whatever" resides within the OnConfigInit event. In version two it would complain because you declared the a_01 variable as a string in the empty state but are trying to declare it again within the OnConfigInit() event. And both versions would also complain that you are trying to assign the value of a_01 to Pages[0] array entry prior to a_01 getting any sort of value assigned to it.

 

Corrected variation with additional tweaks:

string a_01
 
event OnConfigInit()
  ;a_01 = "hello world" ; old version
  a_01 = "goodbye world" ; new version

  Pages = new string[2]
  Pages[0] = a_01
  Pages[1] = "Page 2"

EndEvent

event OnPageReset(string page)
  if(page == Pages[0]) ;take advantage of the array and check for it rather than specific string
    draw_a()
  elseIf(page == Pages[1])
    addHeaderOption(a_01)
  endIf
endEvent

function draw_a
  addHeaderOption(a_01)
endFunction
Link to comment
Share on other sites

thank you Ishera, and appreciate the corrections/tweaks greatly.

 

apologies, in my haste and as I don't really have a working compiler atm it seems I have mistaken declaring with assignment.. :facepalm:

note on array to check, I forgot to mention I used strings to check to demonstrate whether the MCM will properly show version 1 string or version 2 string if a_01 did or did not get assigned between the two versions.

Link to comment
Share on other sites

  • 2 weeks later...

Sadly looks like I am back.

 

I've attempted my best at implementing additional pages to MCM updating via Ishara's method unfortunately it doesn't seem to work. It doesn't work even when resetting SKI through console commands.

 

Test starts with Pages, pages, function set at new string[2]. Save. Increase to string[4], Recompile. MCM does not update index.

I seriously have no idea how to go about doing this. Help? =(

 

GetVersioning test (not) in action

source, script, esp, translation in its respective archive.

FRUITS v1 - https://ufile.io/axlui

 

Scriptname FRUITS extends SKI_ConfigBase

int function GetVersion()
    return 3
endfunction

event OnConfigInit()
    Pages = new string[2]
    Pages[0] = "$p_01"
    Pages[1] = "$p_02"
endevent

event OnPageReset(string page)
    If (page == Pages[0])
        draw_1()
    elseIf (page == Pages[1])
        draw_2()
	endIf
endEvent

event OnVersionUpdate(int a_version)
    if (a_version > 1)
        Debug.Trace(self + ": Updating script to version " + a_version)
        OnConfigInit()
    endIf
endEvent

function draw_1()
	AddHeaderOption("$p_01")
endfunction

function draw_2()
	AddHeaderOption("$p_02")
endfunction

 

 

FRUITS v2 - https://ufile.io/z0ywd

 

Scriptname FRUITS extends SKI_ConfigBase

int function GetVersion()
    return 3
endfunction

event OnConfigInit()
    Pages = new string[4]
    Pages[0] = "$p_01"
    Pages[1] = "$p_02"
    Pages[2] = "$p_03"
    Pages[3] = "$p_04"
endevent

event OnPageReset(string page)
    If (page == Pages[0])
        draw_1()
    elseIf (page == Pages[1])
        draw_2()
    elseIf (page == Pages[2])
        draw_3()
    elseIf (page == Pages[3])
        draw_4()
	endIf
endEvent

event OnVersionUpdate(int a_version)
    if (a_version > 1)
        Debug.Trace(self + ": Updating script to version " + a_version)
        OnConfigInit()
    endIf
endEvent

function draw_1()
	AddHeaderOption("$p_01")
endfunction

function draw_2()
	AddHeaderOption("$p_02")
endfunction

function draw_3()
	AddHeaderOption("$p_03")
endfunction

function draw_4()
	AddHeaderOption("$p_04")
endfunction

 

 

 

Edited by 3aq
Link to comment
Share on other sites

If you are going from your example 1 to example 2, the problem is that you have not changed the return value in the GetVersion function. If your first script says that it is version 3, there will be no need to update if you say your second script is also 3. You have to advance that number EVERY time you want the script to be considered an update. Change it to a 4 on the second script and see what happens.

Link to comment
Share on other sites

ahh, here I thought the GetVersion has to be at return 3 as it seems to be the case on all the mods I checked..

 

on that note would you need to change the number in a_version > 1 ?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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