troublesum's Recent Forum Activity

  • 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

  • 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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!

  • There isn't one unfortunately... C2 doesn't have any referencing for "null" values. For official plugins everything is forced to Numbers, Strings or Boolean. nulls are usually returned as int(0) and then converted to what ever you are setting to.

    Example:

    You have a var myString that you set from a function return and some how that return value is null (shouldn't be possible unless using a 3rd party plugin) this would be the resulting outcome.

    var myString = ""; (defined as type string)

    myString = myfunction.returnValue; (set myString from function return value. if null it will return int(0))

    myString equals "0" (stringified version of int(0))

    Based on looking at the plugins this appears to be by design to either prevent system errors or non-programmers from making mistakes. We just have to work around this limitation.

  • You're all very welcome.. ... I'm glad it helped.. Don't forget that for each C2 window that's open at the same time it increments the port number so adding a range of 50000-50010 might be needed in some cases if you have more than 1 project open for testing.

  • Surprisingly yes! You just need to forward port 50000 on your router to you local computer.

    Example:

    • Your computer at your home is located at 192.168.1.101 and you have a public IP of 65.23.45.65
    • Login to your router and forward port 50000 to 192.168.1.101
    • Open construct and open the project you want to preview.

    On your computer you can go to 192.168.1.101:50000 and see the preview.

    On your friends computer located remotely he will open chrome and go to 65.23.45.65:50000 which your router will forward to your computer and you computer will see the construct is listening to the port and launch the preview

    Your question got me curious so i tested my own so i can say for sure this works. Good luck!

troublesum's avatar

troublesum

Member since 4 Dec, 2013

Twitter
troublesum has 2 followers

Trophy Case

  • 11-Year Club
  • Email Verified

Progress

12/44
How to earn trophies