iamzip Posted October 22, 2020 Posted October 22, 2020 What I'm looking for is information on what's the speed difference between a script accessing outside data from another script as a property vs. accessing the same data from an external file, like a json config file. Which is faster? If I'm planning on having most of my data routed to a json file should I pass everything to internal arrays and variables before working on them or would going back and forth with the external file be almost as fast? Thanks for any insight.
Andy14 Posted October 24, 2020 Posted October 24, 2020 The difference is that script-properties, global variables etc. are already loaded with the game. It is instantly available in the game. External outsourcing of this data usually means additional external access to the hard disk (reloading). It's usually slower. This is why external JSON is usually only used to save / load configurations, which does not happen very often and is usually part of a setup.
iamzip Posted October 24, 2020 Author Posted October 24, 2020 Cool, thanks for the explanation, guess I'll need to pass any data I want to manipulate to variables up front then, rather than having function calls continuously pulling from json. I appreciate the help.
iamzip Posted October 24, 2020 Author Posted October 24, 2020 Couple of follow up questions, as I'm pretty ignorant about how some stuff works behind the scenes. If I'm using a function that expects an array, since generally they'll take any size array, can I pass one by using json.IntListToArray or similar? Spoiler Function thing(int[] a) Then call: Thing(json.IntListToArray("file", "list")) Second, if I wanted to take the time could I make a function that sizes arrays? Spoiler Int[] function(int size) If(size == 1) Return new int[1] Elseif(size == 10) Return new int[10] Endif Endfunction Or... Int[] function(int size) If(size == 1) Return array[1] Elseif(size == 10) Return array[10] Endif Endfunction And if that even worked, would every array I used it on be tied together as if I'd passed arrays directly? Ultimately what I want to do is not have to constantly pass big arrays filled with -1s and only a couple actual indices I'm interested in.
Fotogen Posted October 24, 2020 Posted October 24, 2020 SKSE Utility.psc has: float[] Function CreateFloatArray(int size, float fill = 0.0) global native int[] Function CreateIntArray(int size, int fill = 0) global native bool[] Function CreateBoolArray(int size, bool fill = false) global native string[] Function CreateStringArray(int size, string fill = "") global native Form[] Function CreateFormArray(int size, Form fill = None) global native Alias[] Function CreateAliasArray(int size, Alias fill = None) global native float[] Function ResizeFloatArray(float[] source, int size, float fill = 0.0) global native int[] Function ResizeIntArray(int[] source, int size, int fill = 0) global native bool[] Function ResizeBoolArray(bool[] source, int size, bool fill = false) global native string[] Function ResizeStringArray(string[] source, int size, string fill = "") global native Form[] Function ResizeFormArray(Form[] source, int size, Form fill = None) global native Alias[] Function ResizeAliasArray(Alias[] source, int size, Alias fill = None) global native Also look at PapyrusUtil JsonUtil.psc.
iamzip Posted October 24, 2020 Author Posted October 24, 2020 Awesome, thank you, I'd never seen the skse functions despite looking through the ck array page. I'm assuming then that the json and storageutil create arrays in the same way. That makes things so much easier. Thanks again.
Andy14 Posted October 25, 2020 Posted October 25, 2020 On 10/24/2020 at 4:37 PM, iamzip said: since generally they'll take any size array Papyrus is very limited when it comes to arrays. No associative arrays, no multi-dimensional arrays and max index is 127 (starting at 0). Here is an overview of arrays in papyrus
Recommended Posts
Archived
This topic is now archived and is closed to further replies.