Skip to content
alexdunn edited this page Sep 10, 2014 · 14 revisions

JContainers Set-up

  1. Install SKSE
  2. Install JContainers. JContainers is only a modding resource, so there is no .esp included.
  3. Now go into your Papyrus script where you'd like to store some information and try one of these examples. In each example we store both an actor and his level using various data structures included in JContainers:
JMap Quick Start

JMap stores information in {key, value} pairs.

int playerData = JMap.object()  
Form myForm = Game.GetForm(0x000F8117)
JMap.setForm(playerData, "actor", myForm) 
JMap.setInt(playerData, "level", 47)
JValue.writeToFile(playerData, "Data/testMap.json")

Each line above:

  1. Create a new JMap container and store its identifier in the variable playerData.
  2. Get a Form object that you want to store.
  3. Store that Form into playerData with the key "actor".
  4. Store an integer into playerData with the key "level".
  5. Write out your JMap to file so that it can be accessed the next time the game starts.
JFormMap Quick Start

JFormMap is the same as JMap, but the keys are Form objects rather than strings.

int playerData = JFormMap.object()
JFormMap.setInt(playerData, Game.GetForm(0x000F8117), 47)
JValue.writeToFile(playerData, "Data/testFormMap.json")
JDB Quick Start

JDB is a global version of JMap. There is only one JDB, so you can access the same values from anywhere in any script.

JDB.readFromFile("Data/JDBTest.json")
Form myForm = Game.GetForm(0x000F8117)
JDB.solveFormSetter(".JDBTest.actor", myForm, true)
JDB.solveIntSetter(".JDBTest.level", 47, true)
JDB.writeToFile("Data/JDBTest.json")

Each line above:

  1. In this example, we start by reading data from file. If that file doesn't exist, that's fine. Nothing will happen on this line, but we'll create the file later. If the file does exist, then we'll start off with the data that was written out last time.
  2. Get a Form you want to store
  3. Store that Form into JDB
  4. Store an integer into JDB. The last parameter, which is set true here, is necessary when you're adding new values. It tells JDB to create the path ".JDBTest.level" if it doesn't already exist.
  5. Write out the contents of JDB to file.
JFormDB Quick Start

JFormDB is a global version of JFormMap that can be accessed in any script without reading from file again.

JDB.readFromFile("Data/JFormDBTest.json")
JFormDB.setInt(Game.GetForm(0x000F8117), ".JFormDBTest.level", 47)
JDB.writeToFile("Data/JFormDBTest.json")

For more information on JMap, JFormMap, JDB, JFormDB, and other containers, see Container Types.