forked from SilverIce/JContainers
-
Notifications
You must be signed in to change notification settings - Fork 24
Getting Started
alexdunn edited this page Sep 10, 2014
·
14 revisions
- Install SKSE
- Install JContainers. JContainers is only a modding resource, so there is no .esp included.
- 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
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:
- Create a new JMap container and store its identifier in the variable
playerData
. - Get a
Form
object that you want to store. - Store that
Form
intoplayerData
with the key "actor". - Store an integer into
playerData
with the key "level". - Write out your
JMap
to file so that it can be accessed the next time the game starts.
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
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:
- 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.
- Get a
Form
you want to store - Store that
Form
intoJDB
- Store an integer into
JDB
. The last parameter, which is settrue
here, is necessary when you're adding new values. It tellsJDB
to create the path".JDBTest.level"
if it doesn't already exist. - Write out the contents of
JDB
to file.
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.