JsonToObject(json, location, object, int)
Deserializes the game object described in jObject.
Parameters
- jObject
- object to deserialize from json.
- locLocation
- specifies the location where the object is created.
- oOwner
- object owner. If valid, for valid use cases, the object is placed in owner's inventory and locLocation is ignored.
- bLoadObjectState
- specifies whether to include more detailed info in some cases; see below.
Description
Deserializes the game object described in jObject.
Returns OBJECT_INVALID on errors.
Supported object types: creature, item, trigger, placeable, door, waypoint, encounter, store, area (combined format). For areas, locLocation is ignored.
If bLoadObjectState is TRUE, local vars, effects, action queue, and transition info (triggers, doors) are read in.
Remarks
Use TemplateToJson to easily initially generate the JSON needed, else you'll be rolling your own by hand - there is no loadable JSON datatype at the moment.
Once generated make tweaks and changes then use this function to spawn it into the world.
Version
This function was added in 1.85.8193.31 of NWN:EE.
This function was updated in 1.88.8193.36 of NWN:EE. Fixed traps created by nwscript not being detectable until after a save/load cycle.
Example
Example will take a placeable of resref "plc_resref" (invalid - replace with your own) and alter the appearance to line ID 33, a Ballista, then spawn it.
void main()
{
// Generate JSON from resref template
json jPlaceable = TemplateToJson("plc_resref", RESTYPE_UTP);
// Change to appearance 390
jPlaceable = GffReplaceDword(jPlaceable, "Appearance", 33);
// Spawn
JsonToObject(jPlaceable, GetLocation(OBJECT_SELF));
}
See Also
functions: |
JSON Functions GFF Functions GffReplaceDword ObjectToJson TemplateToJson |