Parse String Plugin

Post your completed addons to share with the community

Post » Thu May 24, 2012 4:09 pm

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 capxrfisher2012-05-24 16:12:32
B
17
S
9
G
7
Posts: 249
Reputation: 6,922

Post » Thu May 24, 2012 4:40 pm

This is raising a check failure on start :
[quote]
---------------------------
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)
[/quote]
This is an issue in the edittime.js file



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

[quote]assignment to undeclared variable a
for (a in temp ) { ; in parse_plugin.js line 106
[/quote]

Also why not simply using the built-in array plugin ?
Not added to the plugins list for now.Kyatric2012-05-24 16:41:49
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Thu May 24, 2012 5:04 pm

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.
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Thu May 24, 2012 5:26 pm

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. rfisher2012-05-24 18:35:26
B
17
S
9
G
7
Posts: 249
Reputation: 6,922

Post » Thu May 24, 2012 6:08 pm

@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.
B
17
S
9
G
7
Posts: 249
Reputation: 6,922

Post » Thu May 24, 2012 8:01 pm

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.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Thu May 24, 2012 8:25 pm

@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".
B
17
S
9
G
7
Posts: 249
Reputation: 6,922

Post » Thu May 24, 2012 10:37 pm

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.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Thu May 24, 2012 10:49 pm

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.
B
17
S
9
G
7
Posts: 249
Reputation: 6,922

Post » Thu May 24, 2012 11:38 pm

Its now working in r91. I just removed a unused code left over from the example.
B
17
S
9
G
7
Posts: 249
Reputation: 6,922

Next

Return to Completed Addons

Who is online

Users browsing this forum: Lof and 4 guests