[Plugin] Data structures in associative lists

Post your completed addons to share with the community

Post » Fri Feb 03, 2012 5:22 pm

Hi All,

First of all hello, my name is Bhavan, I have just purchased Construct 2 and starting to play around with some of its features (plugins etc.)

Congratulations to you all for having an excellent forum. I have been finding it very helpful in the short period I have been using C2.

However!
There is some strange behavior I began to notice. I tried using the Array (array plugin) and something really simple, (such as adding a value, and retrieving it) seems to simply not work. (always retrieves 0, which I have read is the value when you go out of bounds)

So, I arrived here, thinking must be a bug in the plugin, and this plugin provides similar behavior (i required a 1D array). So I downloaded data structures, made the cr.plugins_ change as posted in one of the replies here (runtime.js) to avoid an assert, and guess what, some simple push, pop still retrieves 0. (On a side note, one of the other plugins I installed too, "function" does not work, but here I think my usage is incorrect, so not sure of this yet.)

So I downloaded the example you have posted above, and opened it up in C2, and hey, the stuff works. I replicated the simple push, at() behavior I had in my project in the example project, and this too worked!

So I cannot see what I am missing, I am not aware of what difference a .capx and .caproj makes (mine is .caproj, the example is a .capx). Maybe I made a mistake while installing the plugin?

Any hints will be appreciated, I will upload my .caproj if required. But I think this may be trivial.
B
4
G
1
Posts: 26
Reputation: 1,146

Post » Fri Feb 03, 2012 6:21 pm

Maybe you're using bracket notation?
such as array[1][2]

if so, it isn't the proper way to use arrays.
You should use it as array.at(1,2)

Also, arrays are zero based, and no dimensions should have size zero. If you want a two dimensional array, Z should be 1.

Without seeing your caproject, I can't say.
B
35
S
8
G
8
Posts: 532
Reputation: 6,868

Post » Fri Feb 03, 2012 6:32 pm

Yes yes,

I know..
I am really sorry about not posting the project file.

Ok.. So. Forgive me for not following protocol for I am new.
Next time will be posting the project file.

Anyway..
So I first ran into this..
http://www.scirra.com/forum/read-first-how-to-report-bugs_topic43329.html

And realized this must have occurred before..

So found this:
http://www.scirra.com/forum/adding-array-with-no-properties-in-r76_topic48444.html

And this is exactly whats wrong.
The new object has to be inserted with a layout selected.
I believe no "instance" is created otherwise..

Umm. How can I attach a project file to this post? only URLs?
Maybe it can be helpful to reproduce this..

Thanks!
B
4
G
1
Posts: 26
Reputation: 1,146

Post » Fri Mar 02, 2012 7:36 pm

OK, So I downloaded this little plugin to view an example CAPX for maze creation. However with r80.2 I am getting

Assertion failure: cr.plugins not created

Stack trace:
assert2((void 0),"cr.plugins not created")@http://localhost:50000/preview_prelude.js:12
@http://localhost:50000/dataStructs_plugin.js:5

Any Ideas? (I placed the folder in the Plugins folder...)
B
192
S
6
G
7
Posts: 213
Reputation: 10,178

Post » Fri Mar 02, 2012 8:36 pm

@Zetar
Might want to read over the thread a bit PR gave a fix.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Fri Mar 02, 2012 8:39 pm

[QUOTE=PixelRebirth] It seems to work fine with current C2 versions if you edit the runtime.js a little.

Search for all occurences of "cr.plugins" and add an underscore, so it'll be "cr.plugins_". I think it just appears four times at the beginning of the file.[/QUOTE]


Found it! Thanks bud.
B
192
S
6
G
7
Posts: 213
Reputation: 10,178

Post » Mon Mar 12, 2012 11:50 pm

I just noticed my "plugin" was being used by some of you guys, so I decided to reupload a working version.

While at it I decided to add the possibility to use the "set" method to insert data at a non-existing index, by effectively expanding the dataStructure. Empty strings will fill the missing indexes. If the dataStructure is not initialized, it will be created first too.
B
46
S
17
G
18
Posts: 847
Reputation: 13,802

Post » Tue Jan 15, 2013 1:49 am

Hi there! I'm using your plugin with my game, but I can't export it properly. The screen is all black, and Chrome's console gives me the following error:

Uncaught TypeError: Cannot call method 'apply' of undefined

Here's the link for my game http://db.tt/OqNHWIv2

Thanks in advance.
B
12
S
6
G
3
Posts: 100
Reputation: 3,836

Post » Tue Jan 15, 2013 4:44 pm

So the plugin works in test mode but fails when exported ? Could it have anything to do with a minifying process of any sort ?
B
46
S
17
G
18
Posts: 847
Reputation: 13,802

Post » Tue Jan 15, 2013 5:02 pm

Yes. Works fine in test mode. But when I export the game, it doesn`t load. All I get is a black screen after loading.

As a test, i exported other .capx that uses your plugin (found at this topic: http://www.scirra.com/forum/eek-slowdown_topic46528.html) And the result is the same.

Sorry, what did you meant with "minifying"? (Not a native english speaker, sorry the trouble.)
B
12
S
6
G
3
Posts: 100
Reputation: 3,836

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 2 guests