[PLUGIN] rex_Function2

Post your completed addons to share with the community

Post » Sat Jan 28, 2012 1:17 am

@Geo

You can insert javascript function into function plugin to do some logic/computing.
It's more easy to make a "if...else..." or "switch case" in javascript, and there are some useful functions like sorting. Even you can interact with sprite instances in javascript through function plugin.rexrainbow2012-01-28 01:18:19
B
97
S
22
G
176
Posts: 4,108
Reputation: 103,019

Post » Sat Jan 28, 2012 12:35 pm

Thanks, I can see the benefits. For now though I'll stick to easy event sheets (even though they're more clumsy) because Javascript is not my thing and it would require ramp up time. When the project gets even bigger and I get more advanced, I'll definitely use this approach. Which I hope will be soon

Cheers!
B
14
S
5
G
7
Posts: 235
Reputation: 5,175

Post » Sat Jan 28, 2012 6:04 pm

OK I got into some trouble. While trying to clean up the project and to get it organized better, i got into a situation where the function calls stopped working, and I simply can't figure out why.

Can you please have a look at this very simple capx and help me figure out what I'm doing wrong?

If I understand correctly, the functions should get called when I click the button. But they don't.

Thanks in advance.
B
14
S
5
G
7
Posts: 235
Reputation: 5,175

Post » Sun Jan 29, 2012 1:38 am

@Geo

Hum... I add a new function object and it works fine.

I guess that the original function object is not in layout "MainL".
On the other word, the layout "MainL" can not find the original function object, although the property "Global" is "Yes".


Global object only can be found if it had been declared already.
A little suggestion about using "Global" object -- create an empty layout to be the first layout, put all global objects there. And add one event:
[code]+ start of layout
- go to layout ...[/code]
B
97
S
22
G
176
Posts: 4,108
Reputation: 103,019

Post » Sun Jan 29, 2012 9:55 am

Hey Rex thanks for the reply. I still can't get it to work, even after creating a "Globals" layout with an event sheet, putting a new (global) function there and going to main from there.

I get the feeling that this scenario isn't supported, i.e. having function "definitions" in an event sheet, and calling them from another event sheet. If I'm wrong and this IS possible, I'd appreciate if you could post a little demo capx.

Thanks again.
B
14
S
5
G
7
Posts: 235
Reputation: 5,175

Post » Sun Jan 29, 2012 10:24 am

@Geo: Did you try to include the event sheet where the definitions are made in the event sheet you're actualy calling the function ?
That's the way to make code "global".
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: 6,998
Reputation: 57,791

Post » Sun Jan 29, 2012 11:06 am

Yes, I had the "function code" on a separate event sheet, which I included both in the global and the main event sheet. It wouldn't work. I'm "refactoring" the project now, using only local functions (almost done actually). Lots of tedious manual replacing of object names, a "Replace all" functionality in C2 would've come real handy .
B
14
S
5
G
7
Posts: 235
Reputation: 5,175

Post » Fri Feb 10, 2012 9:33 am

Thanks for downloaded function plugin. Has any suggestion about this plugin?rexrainbow2012-02-10 09:33:20
B
97
S
22
G
176
Posts: 4,108
Reputation: 103,019

Post » Wed Feb 22, 2012 12:18 pm

Thanks again for the plugin. It is an absolute MUST that I use in all projects.

I think I found a bug however. Check out this Simple CAPX.

Basically, it's a function, getting called from another function.

Run the project:

Expected result:

1A#B2A#B3A#B4

Actual result:

1A#B#2A#B#3A#B#4

It seems that the "F2" function gets called twice. Once when it should get called, from within the "F1" function, and once more. I don't understand why it gets called once more, to me it looks like a bug .

Or am I missing something?
B
14
S
5
G
7
Posts: 235
Reputation: 5,175

Post » Wed Feb 22, 2012 4:15 pm

@Geo

Thanks for testing. It might be an engine bug. I'll post this bug latter.
B
97
S
22
G
176
Posts: 4,108
Reputation: 103,019

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 6 guests