troublesum's Forum Posts

  • bucktoothfrog - Tell you what I can do... if can you send me an exact example of the JSON string you get from the C2 Data editor (I've never used it) that you want to load into my plugin ill see about making my plugin support merging it. I'm sure I can make it work and It will help others in the future that wind up trying to do the same thing

  • bucktoothfrog - The purpose of this plugin was to get away from index values and access data via names. if you can modify how you input your data into this plugin to contain only JSON objects with named keys instead an Array that is indexed it should work fine

    try loading this (Notice the "0" and "1" are strings)

    {"Data":{"0":{"lat":1,"long":11},"1":{"lat":2,"long":12}}}

    You can then retrieve the values using the get action

    Storage.get("Data","0","lat") = 1

    Storage.get("Data","0","long") = 11

    Storage.get("Data","1","lat") = 2

    Storage.get("Data","1","long") = 12

  • AGCompany - No problem let me see if I can help .. So if I understand you correctly your trying to load this into the table object and and then get the "somekey" value out of out it?

    {
    "USER": {
    	"somekey": "somevalue"
        }
    }
    [/code:2tnb5y4c]
    
    A 2D JSON object is considered a Table and each row in it is a List and each List has fields with Values. 
    
    Table=> [List]  => [Field]      = Value 
    Table=> USER => somekey = somevalue
    
    You need to use the "Merge JSON to Table action to load your JSON object and then use the Table.Get([ul],[field]) expression to retrieve the value
    [attachment=1:2tnb5y4c][/attachment:2tnb5y4c]
    
    The screen shot above will print "somevalue" to the text object
    
    Here is a capx demonstrating how to get the value
    [attachment=0:2tnb5y4c][/attachment:2tnb5y4c]
    
    Hopefully this helps
  • This is a simple 2 dimensional associative array (values access by "name" instead of integer "0" index). It functions just like the official "Dictionary" plugin but it has 2 dimensions instead of 1.

    It supports loading raw JSON data directly to it which can be useful if you do a lot with AJAX.

    It supports minification and I believe all bugs have been found but if you find any please let me know. I use this in all my projects so I will actively maintain it to ensure it works correctly.

    Plugin

    TRBLSM_table.zip

    Example capx that demonstrates all functions supported.

    TableExample.capx

    If you have any questions or need help using it Ill do my best to answer in a timely manor.

    Thank you

    P.S I also created a 3D version so you if you need a larger object you can try out the "Storage" plugin instead.

    [Plugin] - Storage (3D Dictionary)

    https://www.scirra.com/forum/plugin-storage-3d-dictionary_t125861

  • bentwonk - Thank you.. I fixed it in mine. Also because you guys seem to like it so much I created a forum post for this plugin to make it available. Thank you for the kind words

  • bucktoothfrog - I just added this plugin. It will probably work for what your looking for. It supports loading raw JSON directly into it and accessing the data via named indexes.

    https://www.scirra.com/forum/plugin-storage-3d-dictionary_t125861

  • This was a personal plugin i created for my self but I seemed to have received a lot of positive feed back for it so I figured I'd make it publicly available

    Its just a 3 dimensional associative array (values access by "name" instead of integer "0" index). I believe there are other plugins out there similar but may not function entirely the same. This was built to act nearly identical to the official "Dictionary" plugin but instead of only having 1 dimension it has 3.

    It may seem a bit more complicated at first but if you work with JSON objects and send and receive a lot of AJAX data like I do this may be useful for you as it supports loading raw JSON data directly to it.

    It supports minification and I believe all bugs have been found but if you find any please let me know. I use this in all my projects so I will actively maintain it to ensure it works correctly.

    Plugin

    TRBLSM_storage.zip

    Example capx that demonstrates all functions supported.

    StorageExample.capx

    If you have any questions or need help using it Ill do my best to answer in a timely manor.

    Thank you

    P.S I also created a 2D version so you if you don't need this large of "Storage" access you can try out the smaller "Table" plugin instead.

    [Plugin] - Table (2D Dictionary)

    https://www.scirra.com/forum/plugin-table-2d-dictionary_t125862

  • kaiko .. Awesome!! ... Glad it worked for you.

    Yah the debug feature needs to be enabled. I did that because sometimes the storage can be pretty large so you can enable to view the whole thing in the debug view or just a certain table or list.

    To enable it, call one of these action on start of layout.

    [attachment=0:3tigthfm][/attachment:3tigthfm]

    Let me know if you have any questions

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • kaiko Yah.. I see two problems..

    1) You defined the tag for the AJAX request as "get login". But on the event listener you are looking for on "login".. those key names have to be the same or your event listener wont detect when the AJAX response comes back.

    2) Your domain does not appear to allow cross domain AJAX requests. IE the AJAX request is originating from "http://YourTestIP:50000" but its being sent to "http://dev.canvaramanager.com". You need to allow crosss domain AJAX requests by adding a PHP header tag or the AJAX request is blocked by your server. This is standard as it is meant to protect the server from outside attacks.

    You need to add this to your PHP file. Caution this is dangerous as it opens up to potential malicious attacks from out side domains but is needed for testing

    header('Access-Control-Allow-Origin: *');
    [/code:io47tqq6]
  • kaiko you can take the Ajax.LastData and load it into the Storage object using the Merge Table action. When you're done you can dump the JSON string to text object to see it.

    [attachment=0:885qwrwc][/attachment:885qwrwc]

    The storage object is 3 dimensional so if your JSON object is one dimensional it will create top level names of "default".

    Example

    Storage.Get("default","default","myfield")

    Think of it as a C2 Array that works more like a C2 Dictionary

  • kaiko I created a plugin for personal use that might help you? Its a 3 dimensional associative array object (accessed via field name instead of indexed integer values). It can feel complicated at first but It supports loading raw JSON strings right into and easily accessing the data inside it which is what your looking for. I had the same issue as you but couldn't find a plugin I liked so i created this. I don't officially support it but its nothing more than a wrapper to access a 3 dimensional JavaScript variable for named storage purposes and perfectly stable. I use it in all my projects ..I attached the plugin and an example capx below if your interested?

    Plugin

    [attachment=1:1r0thvj6][/attachment:1r0thvj6]

    Example capx usage r195

    [attachment=2:1r0thvj6][/attachment:1r0thvj6]

    [attachment=0:1r0thvj6][/attachment:1r0thvj6]

  • Ashley I understand. That's why I have not released any of my plugins that directly access other plugins to the general public. I don't want to have to maintain them so i get where you're coming from.

    PS. But my plugin (unreleased) that ties the Multiplayer and Function plugin together to allow for calling functions on all peers at the same time with a single call is pretty sweet though ... Taking two powerful plugins and creating a wrapper to combine their functionality adds an amazing amount of power to my projects. I wouldn't be so harsh on others (or myself) that want to do this so long as we respect the C2 eco system. I can actually have a game engine now that is synced across all peers controlled by the host because the host has functional control over everything with super simple control.

  • glad you figured it out. ... I'm not a fan of protoType usage (i extend my class objects using a different method) but to wrap your head around it, its just and extension of the object.

    At the top of each plugin you will something like this

    var pluginProto = cr.plugins_.MyPlugin.prototype;

    "pluginProto" is now a refrence to the MyPlugin plugin prototype extension (not any instance of it but the object definition it self)

    further down in a plugin you will see something like this

    function Acts() {};

    Acts.prototype.DoSomething = function(param1){

    //Code in here that does stuff to the instance that called it.

    }

    This is building a set of actions to add to this object.

    Lastly those actions are added to the object by something like this

    pluginProto.acts = new Acts();

    "pluginProto.acts" is the same as typing "cr.plugins_.MyPlugin.protype.acts"

    So the final location of the DoSomething() function is "cr.plugins_.MyPlugin.protype.acts.DoSomething"

    Now in Javascript if you were to just call the function "cr.plugins_.MyPlugin.protype.acts.DoSomething(param1)" the function would have no refence to the instance it is supposed to do work on.

    To pass the instance you need to add a .call so it would be "cr.plugins_.MyPlugin.protype.acts.DoSomething.call(instanceObject,param1)"

    And thats plugin ACE function calling in a nut shell

  • ACE's are function definitions tied to an object type. Instances of that object type may call those functions but must pass the "this" instance reference to the ACE function when calling it.

    As en example many of the plugins i create for my self call the function plugin directly from plugin. To do that when I instantiate an instance of my plugin I perform a look up to find the global function plugin instance and store it.

    Example: I search for runtime instances objects of Function type objects and store the instance reference to a local variable "this.Function.self "

    var objects = this.runtime.objectsByUid;
    for (var i in objects) {
    	if (objects[i] instanceof cr.plugins_.Function.prototype.Instance) {
    		this.Function.self = objects[i];
    	}
    }
    [/code:21b5l0ir]
    
    Then later on somewhere in my code when ever I want to call a function on the event sheet by its name I have to Call the ACE the Action of the function instance i stored.
    
    [code:21b5l0ir]
    this.CallFunction = function(fnName, params) {
    	cr.plugins_.Function.prototype.acts.CallFunction.call(this.Function.self, fnName, params)
    }
    [/code:21b5l0ir]
    
    so now any where in my plugin that I desire I can call a local function "this.CallFunction()" and pass it the name and paramters and it will call that function on the event sheet.
    
    What you need to do is find the instance of the object you want to pass to the ACE function and call the function and pass that instance to it. The best way to learn about this would be to open up some of the other official plugins and review the code and how they work. You can see that many them of call there ACE's in the same manner. The hard part is figuring out how to get the correct instance object to pass to it.
  • Ashley - Thank you so much for addressing our needs with the function name calling update you made to the latest beta version. It solves a VERY LARGE head ache with respect time spent debugging due to miss typed function names. The editime action "AddFunctionNameParam" is an easy update to make to my current custom plugins that currently incorporate the function plugin so thank you for that as well. I'm sure it wasn't easy.

    It does however leave one missing piece out I hope you will be able to update later on in the future which is that when I am going through and changing my naming conventions (IE I decide to change an "On function" name) it does not fix the all locations in the event actions where i have called it so i still have to do that manually. I know by the way the function plugin works this might not even be possible as it probably requires a string search/replace in the xml file? But if you can look into it and let us know or make this happen it would make the function plugin absolutely solid!

    As always thank you for your hard work. Its appreciated greatly!