0 Favourites

[Plugin][Behavior] DirectData

  • 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

  • I tried the behavior, so far it's usefull, but it's missing one important feature - get length of the object and forEach to go through the objects.

  • I tried the behavior, so far it's usefull, but it's missing one important feature - get length of the object and forEach to go through the objects.

    I only builded a dataspace in behavior.

    The tools are in the plugin. You think it make sense to have it in behavior, so in every instance?

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • Depends, IMHO behavior is easier to use and more logical, because json objects belongs to the instance and is easily accessible that way.

  • Depends, IMHO behavior is easier to use and more logical, because json objects belongs to the instance and is easily accessible that way.

    What I mean is the ForEach/Count of the plugin works well for behavior object. They are not needed in behavior itself.

    If you have them in behavior, for example you need to pick the correct instance to have a valid foreach (handler,key,value), thats brings all mussy.

    They are like system expressions, you also dont have a foreach in every sprite to go through sprites, you have it in system and input the sprite, true?

  • Ah, I see

  • Thanks for the awesome tool, I have a bug to report though.

    When exporting, with the latest version of construct the runtime crashes because runtime.name can't be used anymore and thus the "project" variable will be null.

    Best,

    Luca

  • Sorry, I was bussy a long time. Now I have time to go on with my project, so also with the plugins.

    Thanks for the awesome tool, I have a bug to report though.

    When exporting, with the latest version of construct the runtime crashes because runtime.name can't be used anymore and thus the "project" variable will be null.

    Best,

    Luca

    Well, I am not good in javascript.

    I updated it. Lost the "autoloadstorage", because many problems.

  • Can you put a shuffle for the array?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
[Plugins/Behaviors] Rez Repo
131 63,784
Guif0DA's avatar
Guif0DA
Topic
22 1,441
saiyadjin's avatar
saiyadjin
Topic
12 690
skymen's avatar
skymen