This Addon is to handle easily with Dictionary and Arrays in every size.
Its based on JSON, so in Construct this Objects are special strings.
You also can use variables with handwritten JSON strings as objects. But dont forget the "".
If you do something wrong, the returned objects can be null(-1) and if debug is on, you recive a message in browser console what happens.
Plugin
Behavior
Access to the runtime persistent Object:
SetPersistObject(path,value):
You can insert Value to specific path, if path not exist it will create.
"myPath,myPath2,...." , "TestValue"
"myPath,myPath2,...." , "{}"
You can also insert complete Dictionary(Json)/Array(Json) to a specific path.
"myPath,myPath2,...." , MyStringObj
You can create paths also as array.
"myPath,myPath2" , "[]"
"myPath,myPath2[],0" , "TestValue"
DelPersistObject(path):
You can del a Value/Dictionary/Array by specific path.
"myPath,delThis"
Del Array is same like Dictionary. NO [] needed in path.
ExistInPersistObject(path):
You can check if path exist.
"myPath,myPath2"
Check Array is same like Dictionary. NO [] needed in path.
returns true/false
GetPersistObject(path):
You can get Value/Dictionary(Json)/Array(Json) from a specific path.
"myPath,myPath2"
Get Array is same like Dictionary. NO [] needed in path.
returns Dictionary(Json)/Array(Json)/Value
ClearPersistObject:
This cleans all values in PersistObject.
Access to the stored Object:
LoadStoredObject:
Load StoredObject from Storage and triggers OnStoredObjectLoaded if finished.
OnStoredObjectLoaded:
The StoredObject is loaded some ticks after "OnStartOfLayout", use this to have a startpoint with loaded StoredObject.
IsStoredObjectLoaded:
To check for example OnTick.
returns true/false
SetStoredObject(path,value):
You can insert Value to specific path, if path not exist it will create.
"myPath,myPath2,...." , "TestValue"
"myPath,myPath2,...." , "{}"
You can also insert complete Dictionary(Json)/Array(Json) to a specific path.
"myPath,myPath2,...." , MyStringObj
You can create paths also as array.
"myPath,myPath2" , "[]"
"myPath,myPath2[],0" , "TestValue"
DelStoredObject(path):
You can del a Value/Dictionary/Array by specific path.
"myPath,delThis"
Del Array is same like Dictionary. NO [] needed in path.
ExistInStoredObject(path):
You can check if path exist.
"myPath,myPath2"
Check Array is same like Dictionary. NO [] needed in path.
returns true/false
GetStoredObject(path):
You can get Value/Dictionary(Json)/Array(Json) from a specific path.
"myPath,myPath2"
Get Array is same like Dictionary. NO [] needed in path.
returns Dictionary(Json)/Array(Json)/Value
ClearStoredObject:
This cleans all values in StoredObject.
Working with a temporary Object:
SetToObject(object,path,value):
You can insert Dictionary(Json)/Array(Json)/Value to specific path, if path not exist it will create, but here you need to input the target Dictionary(Json)/Array(Json).
"{}" , "myPath,myPath2,..." , "TestValue"
myLocalString , "myPath,myPath2,..." , "TestObject" Dictionary must be json, min. {} | []
anyDictionarytring , "myPath,myPath2,..." , myGlobalString
returns the changed Dictionary(Json)/Array(Json).
DelFromObject(object,path):
You can del a Dictionary/Array/Value by specific path of target Dictionary(Json)/Array(Json).
returns the changed Dictionary(Json)/Array(Json).
ExistInObject(object,path):
You can if a specific path exist.
returns true/false
GetFromObject(object,path):
You can get Dictionary(Json)/Array(Json)/Value from a specific path of target Dictionary(Json)/Array(Json).
returns the Dictionary(Json)/Array(Json)/Value.
The Behavior:
Its mostly like the persist object, but it depends on the object.
Other stuff:
ForEach in actions:
ForEach(handler,Dictionary) Value|Dictionary(Json)|Array(Json) in target Dictionary(Json)/Array(Json).
It trigger Foreach in conditions.
ForEach in conditions:
You can filter by ForEachHandler.
Get current Key by ForEachKey.
Get current Value by ForEachValue.
IsNumber(Value):
returns true/false
IsString(Value):
returns true/false
IsDictionary(Value):
returns true/false
IsArray(Value):
returns true/false
IsBoolean(Value):
returns true/false
IsUndefined(Value):
returns true/false
Debug:
It show debug message in browser console.
It view Dictonary/Array as formatet Json.
It is also in construct, but this is with little extensions.
String:
sprintf(string[,var]):
It formats a string with additional vars(max 26).
myvar = funny
sprintf("Hello {0} {1} World.","my",myvar)
->Hello my funny World.
Array:
sort(array)Returns the sorted array.
reverse(array) Returns the reversed array.
push(array) Returns the array with the added element.
getFirst(array) Returns the first element.
getLast(array) Returns the last element.
lastIndexOf(array,value) Search the array for an element and returns its position.
length(array) Returns the number of elements in an array.
All hard to explain for me, but easy and flexible to use, if you understand once.
Examples:
About feedback I would be very happy.
04.06.2015 BugFix: ForEach was working not correctly
10.06.2015 New: sprintf
19.06.2015 New: ExistInObject, ExistInSaveObject
21.06.2015 New: Name changed, StoredObject, value check
22.06.2015 BugFix: Add LoadStoredObject, because autoload dont work correctly anytime. Switched autoload to settings.
24.06.2015 New: Array expressions
12.03.2016 Remove: AutoLoadStorage option
12.03.2016 Add: LogLevel option
12.03.2016 BugFix: Behavior Logging
13.03.2016 Add: Inspector Values