Jump to content

compile a script for me


Recommended Posts

Posted
7 minutes ago, Pamatronic said:

Here you go

Thank You Pama

 

it's this it might be wrong in there

 

Original

 

; Get a Papyrus string array from a JArray
string[] function GetStringArrayFromJArray(int array) global
    int size = JArray.Count(array)
    string[] strings = Utility.CreateStringArray(size)
    int i
    while i < size
        strings = JArray.GetStr(array, i)
        i += 1
    endWhile
    return strings
endFunction

 

Changed

 

; Get a Papyrus string array from a JArray
string[] function GetStringArrayFromJArray(int array) global
    int size = JArray.Count(array)
    string[] strings = Utility.CreateStringArray(size)
    int i
    while i <= size
        strings = JArray.GetStr(array, i)
        i += 1
    endWhile
    return strings
endFunction

 

For me it looks, the last string is never loaded, or I am wrong here ?

Posted

If you refer to the original, Im amazed it compiles at all, considering how j is never initialized :/ (exept of course thats a typo on your end)

 

Did you test wheter the changed version works properly?

 

One thing that jumps at me is this: "while i <= size"

Wouldnt this have to be something like this "while i < size" , to avoid an Index out of Bounds error?

 

 

Posted
2 minutes ago, Pamatronic said:

ld not be caught here?

because the loop stops before the last string. i < 

like 100 entries, loop runs to 99 but will no more run the "load string 100"

This might be the reason for the always missing schlong on creatures after a while playing.

Posted
2 minutes ago, Tlam99 said:

because the loop stops before the last string. i < 

like 100 entries, loop runs to 99 but will no more run the "load string 100"

This might be the reason for the always missing schlong on creatures after a while playing.

Keep in mind that an Arrays index starts at 0.

so if you go from String[0] to String[99], you do have 100 entries.

Posted
14 minutes ago, Pamatronic said:

Keep in mind that an Arrays index starts at 0.

got it

i is initialized 0, first entry list 0.

OK, learned at least something ?

 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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