The Function Object....how DO you use it?

For questions about using Classic.

Post » Tue May 25, 2010 11:58 am

So I was inside of Construct tinkering around with a special project, when I came across the Function Object. I actually couldn't figure it out but I am assuming it is what I need to create what I want to create...

For starters, I wanted to try my hand at doing something similar to

[code:z417kdrq]messagebox(integer xpos, integer ypos, string message)
{
doStuff();
}[/code:z417kdrq]

But when I tried, I actually crashed the text EXE. I guess Function.Messagebox(x,y,"message") does not work. ;O)

So I ask you guys, how is it used and how do you use it? What would be the equivelient of what I posted above in pseudocode? (The Wiki is down and plus, it wasn't clear on it last I checked it. But it did mention similar things as to how a normal function works last I recall!).
B
2
G
3
Posts: 13
Reputation: 876

Post » Tue May 25, 2010 1:36 pm

this is a very simple example of how to use a function
[url:15y8cvvq]http://dl.dropbox.com/u/1013446/functions.cap[/url:15y8cvvq]


once that makes sense. here's another way to use functions, in an expression:
[url:15y8cvvq]http://dl.dropbox.com/u/1013446/functions2.cap[/url:15y8cvvq]

notice you can also set a return value.


I assumed you had enough programming knowledge that these examples make some sense without more of an explanation, but please ask questions if you have them. Also, you'll notice when you call functions from an action, it lets you choose to 'remember' or 'forget' picking. It does exactly that. It maintains the selected object list, or starts from scratch in the function, depending on your needs.
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Tue May 25, 2010 1:43 pm

Odd, when I try to open them in Construct I get an "Out of Memory" error.
B
2
G
3
Posts: 13
Reputation: 876

Post » Tue May 25, 2010 2:30 pm

here ya go, right click - view image if it doesn't fit in your browser normally:
first one:



second one:
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Wed May 26, 2010 12:38 am

Oh wow. Very different than I imagined. I'm very grateful for you telling me (and posting the screenshots)

So you're literally having to specify the parameters first (as Function.Param(number), and then adding the values later. I get it now.

And then, AFTER telling specifing the parameters you can then use On Function.myFunction(parameter1,parameter2), so for the MessageBox...

Messagebox.Param(1), MessageBox.Param(2), MessageBox.Param(3)
Add parameter xpos
Add parameter ypos
Add parameter message
Call function (And at this point on it works like a normal function)

Again, thank you so much.
B
2
G
3
Posts: 13
Reputation: 876


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 8 guests