Here I compiled a list of the functions that MWSE extends the standard Lua with. I added a link to the MWSE's documentation description of each function. The numbers in the second row indicate the number of uses in all the currently released MWSE-lua mods, which were obtained by using GitHub's search in morrowind-nexus-lua-dump repository. There can be some false positives. For example, searching "table.size" would also list a file that has the words "table" and "size" in the comments. However, the number of false positives shouldn't be that high to significantly skew the numbers (my estimation, based on a quick scroll-over of the search results). Only for the functions that have a small number of hits, I've counted the real usage myself. So, these statistics show us how useful the modders find each of the functions. Bear in mind that not all the functions listed here were added to MWSE at the same time, so there wasn't the same amount of time for modders to start using each of those.
String library
Function, Usage:
- string.startswith, 46
- string.endswith, 22
- string.multifind, 12
- string.split, 7
- string.insert, 1
- string.trim, 1
Function, Usage:
- math.remap, 59
- math.round, 52
- math.clamp, 44
- math.lerp, 6
- math.isclose, 3
Function, Usage:
- table.find, 75
- table.choice, 57
- table.size, 41
- table.removevalue, 29
- table.traverse, 23
- table.empty, 18
- table.copy, 13
- table.copymissing, 8
- table.keys, 5
- table.values, 5
- table.getset, 3
- table.invert, 3
- table.deepcopy, 3
- table.get, 1
- table.bininsert, 0
- table.binsearch, 0
- table.clear, 0
- table.new, 0
- table.wrapindex, 0
The motivation to include these:
- Most of the modders aren't software developers. Having helper functions should make it easier to script something in OpenMW.
- The ones that have used MWSE will be familiar with these.
- Which functions to include? Will we define a certain threshold and include all the functions with a number of uses higher than the threshold?
- How to name the functions? Will they be exposed in the global namespace or will be inside a package (e.g. openmw_aux.util)?