Skip to content
ryobg edited this page Feb 15, 2018 · 17 revisions
  • You can use the Sublime text editor and the SublimePapyrus package for better script experience.
  • Prefix object identifiers with j or any other keyword. This will help distinguish objects from plain numbers.
  • If possible, avoid construction of many temporary objects inside a loop, try to re-use. The example below creates 2000 of JArray instances, where each instance will exist for ten seconds:
int i = 0
while i < 2000
  int jlist = JArray.object()
  ...
endwhile

And now the example with re-use:

int jlist = JArray.object()
int i = 0
while i < 2000
  JValue.clear(jlist)
  ...
endwhile

Well, alternative way would reduce default lifetime of an object, but this may break backward compatibility. Or introduce new function capable to force JC destroy an object. Or leave everything as it is.

  • If possible, write dynamically-generated JSON files (generated by a script - backups, user's settings and etc) outside the Data folder:
JValue.writeToFile(backup, JContainers.usersDirectory() + "MyBackupFolder/backup.json")
  • Do not mix constant and user data. Why:

    • You can't force users to allow Skyrim to write into the Data directory
    • Mod Organizer users are happy as they won't have to deal with their overwrite-folder pollution
  • JArray's index access is always faster than any of J*Map's key access.