Parse String Plugin

0 favourites
  • 12 posts
From the Asset Store
This collection of music is the beautiful performance of rather small strings ensemble (8 first violins, 6 second violin
  • I have made my first plugin for Construct 2 and it is used to parse a comma delimited string full of numbers. You set the string like "100,200,300,400" and access each number by referencing its index. Like if you want 200, this index would be 1.

    I'm using it so that i can place alot of the same sprite all over the layout in a easy way.

    my string is like "x1,y1,x2,y2,x3,y3" and then i reference each variable to place the sprite.

    parse plugin

    parse example capx

  • This is raising a check failure on start :

    ---------------------------

    Construct 2 Check failure

    ---------------------------

    Check failure! This is probably a bug:

    Plugin specified both world type and single-global flag; these settings are incompatible

    Condition: plugin_->GetPluginType() != era::pt_worldtype || !(plugin->GetPluginFlags() & era::pf_singleglobal)

    File: Exporters\Plugin.cpp

    Line: 783

    Function: __cdecl Plugin::PluginInfo::PluginInfo(class era::IPlugin *)

    Build: release 91 (64-bit) checked

    Component: Construct 2 IDE

    (Last Win32 error: 2)

    This is an issue in the edittime.js file

    And when clicking on ignore and previewing your example anyway, firebug raises :

    ssignment to undeclared variable a

    for (a in temp ) { ; in parse_plugin.js line 106

    Also why not simply using the built-in array plugin ?

    Not added to the plugins list for now.

  • you can also use tokenat from system expressions

    from the manual:

    tokenat(src, index, separator)

    Return the Nth token from src, splitting the string by separator. For example, tokenat("apples|oranges|bananas", 1, "|") returns oranges.

  • I didn't get a error with r90 and if all i got to do is add the variable "a" it will be easily fixed.

    I also didn't know about "tokenat" or i would have not made the plugin. It was a good learning experience.

    I did ask how to do this a couple of days ago - http://www.scirra.com/forum/place-100-sprites-with-plugin_topic52422.html If i just would have read Mipey's second sentence i would have known what to do days ago.

    I didn't use ARRAY because i didn't understand how to use it and load data into it in a easy way. Although i have no trouble using arrays in PHP & C.

  • Kyatric

    Well I installed r91 on another computer and checked out my plugin and fixed all the problems and now it doesn't work like it did before. On r90 it still works. I'm only interested to know whats wrong and what i have to change as a learning experience.

  • For learning purpose, C2 has a magnificient manual, that also covers C2's SDK.

    Read again the check failure reported it indicates what part of the code you need to modify.

    Apparently, the flags for the plugin in the edittime.js are not right.

    It's unlikely that the plugin should work in r90 as the only SDK change between r90 and r91 was about dependencies. And the type of the object and the plugins flags are not related to that (or at least I don't think), so in theory, even r90 should be raising up check failures on run.

    Anyway, just follow the SDK manual to clear up the code of your plugin.

    About arrays, you can find about it in the dedicated manual article and look for example of use listed in the how do I FAQ under the section "Arrays".

    About tokenat and other alike system expressions be sure to check the system references.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Kyatric

    Well i did fix my plugin so that no more errors happen when using r91. No errors did occur with r90 otherwise i would have never posted about it. So just to fix the problems, i installed r91 on a different computer and when i run my test capx the result is not the same as with r90. So what i mean is, the plugin works with r90 correctly and with r91 is doesn't work correctly.

    Its a simple example that displays a number on the screen. With r90 it displays "200". With r91 is displays "0".

  • FYI r90 does not report plugin errors, because it is a stable release and most of the error checking is not included. You should develop plugins with beta releases which do additional checking to make sure your plugins are working properly.

  • Thank you for the information, but To try and fix what is not broke in r90 which is broke in r91 is beyond me. I need some kind of feedback to let me know whats wrong.

  • Its now working in r91. I just removed a unused code left over from the example.

  • rfisher I like your parse plugin. It is just what I am looking for. However, it has one function missing and that is "count". How many items are in the string? I need this as I don't know how many numbers are being passed to my app i.e., MyOPtion=2,3,7,9 or MyOption=1,2,9

    parse.count = 4 and count = 3 in the second example

    I don't suppose you would consider adding that function to your plugin?

  • rfisher scrub that - I have just discovered tokenat and tokencount

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)