[PLUGIN] rex_Function2

Post your completed addons to share with the community

Post » Mon Apr 02, 2012 1:06 am

@Geo

SOL is "selected objects list".

[QUOTE=Geo] nothing will be pre-filtered, and no filter that the function does is kept past its scope.[/QUOTE]
That is SOL, to decide which instances to be operated. For example,
[code]Event function called "destroySprite"
    action: sprite -> Destroy[/code]
What instances do you expect to be destroyed?

Test case A.

In "test" function, it will destroy all instances of sprite object. i.e. the SOL of sprite object in "test" function contain all instances.

Test case B.
Creating instance before call "test" function.

The SOL of sprite object in "test" function only contain the new instance. So only one instance had been destroyed.


The function body is the same, it does the same operation to different instances. Function plugin does not select which instances should participate in these actions. It depend on what you do before calling function (and the design of engine).


--
The SOL confuse me sometime, too.rexrainbow2012-04-02 01:17:13
B
97
S
22
G
177
Posts: 4,113
Reputation: 103,531

Post » Mon Apr 02, 2012 11:07 am

Hey, I'm trying to do something like this in C2:



Problem is, functions can't be called within functions. And the lack of an "else" condition means it's impossible to check whether a function is NOT being called, due to the nature of how the plugin works. Trying to replace the function with a variable work-around doesn't, well, work, or at least not very well.

Would it be possible to implement a solution to these issues?
B
94
S
37
G
11
Posts: 404
Reputation: 11,275

Post » Mon Apr 02, 2012 11:28 am

@Candescence

I can catch if a function is NOT being called. Could any one provide a name of this condition?rexrainbow2012-04-02 11:47:12
B
97
S
22
G
177
Posts: 4,113
Reputation: 103,531

Post » Mon Apr 02, 2012 12:05 pm

How about "Function <Name> Not Called"? Might be better names for it, but it's the best I can think of right now.
B
94
S
37
G
11
Posts: 404
Reputation: 11,275

Post » Mon Apr 02, 2012 12:05 pm

@Candescence

I will think about implementation of recursion call.
B
97
S
22
G
177
Posts: 4,113
Reputation: 103,531

Post » Mon Apr 02, 2012 2:05 pm

Thanks! I would really appreciate it! :)

Also, I think I discovered the reason why the Construct Classic version of the engine I'm trying to replicate placed a function within a function - for some reason, the "else" wouldn't work unless it was sub-event! Hilarious, really.
B
94
S
37
G
11
Posts: 404
Reputation: 11,275

Post » Tue Apr 03, 2012 1:23 am

@Candescence

Here is a beta version of function plugin with recursion supporting, and a test capx.

I add a memory stack to support recursion and test it by factorial calculation in capx.

This can calculate factorial correctly.


However, this can not.



Event sheet is not designed for recursion, so some styles will not cause correct result.

Sorry, I failed.rexrainbow2012-04-03 01:25:24
B
97
S
22
G
177
Posts: 4,113
Reputation: 103,531

Post » Tue Apr 03, 2012 1:44 am

@Candescence

Function can be called in other function like


I had fixed nested call bug before
B
97
S
22
G
177
Posts: 4,113
Reputation: 103,531

Post » Tue Apr 03, 2012 3:56 am

@Candescence

I check "Else" in your picture. C2 can not put triggered condition under other condition anymore.
I would like to add "No triggered function" (or other name if possible) after "action:call function".

[code]- action: call function
+ condition: No triggered function
    - do something[/code]

It can do something if no matched triggered function in event sheet.

What do you think?
B
97
S
22
G
177
Posts: 4,113
Reputation: 103,531

Post » Tue Apr 03, 2012 2:00 pm

OK rexrainbow, I looked into this thing some more. There is something that I can't understand, can you please have a look at this simple capx.

Repro:

1. Open capx and run the game.
2. In the game, click the Continue button.
      - it says "You lose, 4 enemies still alive"
3. Go back to Construct 2, on the event sheet there is a disabled action "system wait 0 seconds". Enable this action
4. Run the game again
5. Click Continue button
      - this time it says "You win, all enemies destroyed"

This is what troubles me. The sprites should get destroyed before the function gets called, regardless of the wait 0 seconds.

The function call just counts the enemies and displays a message.

Can you help me figure this out? Why does the count return 0 with the wait, and 4 without the wait?

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

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 3 guests