Using Functions

Get help using Construct 2

Post » Tue Feb 05, 2013 6:26 pm

After reading th manual, which was good at explaining what a function does, but not how to actually make one, I found this thread:
http://www.scirra.com/forum/function-object-vs-function-plugin_topic59653.html That got me further to where I have a working function.
However, I have other questions:
1) Can a function be on a different event sheet (for organizational purposes)? I tried just making another event sheet and put my function there, but that didn't work.
If the functions can't be put on a different event sheet, is there some way to put them 'out of the way' so that the event sheet isn't a mess when your scripting starts getting massive?

2) When I created my function object, I called it 'OrbitCalc' But then I was asked to name it again in a window called "Parameters for Orbitcalc: On Function", with explanation text of "The name of the function that is being called." and a field labeled "Name". Didn't I name it 'OrbitCacl'? What is this extra bit of information for? I found that if the calling event (which also asks for this info) and the "Name" don't match, the function won't run. I don't understand what the extra step is for.
B
11
S
4
G
1
Posts: 159
Reputation: 1,803

Post » Tue Feb 05, 2013 6:37 pm

1)Yes but it has to be imported into a worksheet that is attached to that layout (see manual)

2)You assign the function first and give it a name.
e.g. On mouse click call function "ShowMessage"

Then you have to say what that function does so you call a function (in this case "ShowMessage" and tell it what you want it to do.


https://dl.dropbox.com/u/25176763/function.capx
dsarchy2013-02-05 20:06:23
B
14
S
3
G
5
Posts: 41
Reputation: 3,490

Post » Tue Feb 05, 2013 6:45 pm

1. Yes. Make sure to include event sheet with function to event sheet who call this function. - Right mouse click on event sheet editor and select "Include evant sheet.

2.You named your function object in the layout editor - You have set global name for the object used in actions, conditions...


simpe functions.capx
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Tue Feb 05, 2013 6:55 pm

dsarchy and shinkan:
1) What you said makes sense, I'll try that. Thank you both.

2) I am still confused after reading your replies to number 2 several times. Unfortunately, your examples you've supplied are both from version 117 and the free 114 version I have will not load them.
Are you saying that the function object has a name, but it needs to be referred to by yet another name? This doesn't make sense to me.
B
11
S
4
G
1
Posts: 159
Reputation: 1,803

Post » Tue Feb 05, 2013 6:59 pm

2) Are you saying that a function object can hold many functions, so you need to refer to a specific function inside the function object? That makes sense, if that's the case.
What then delineates one function from another inside that function object when viewing them from an event sheet?
B
11
S
4
G
1
Posts: 159
Reputation: 1,803

Post » Tue Feb 05, 2013 7:03 pm

Ok, I think I've got it figured out. Thanks! I'm out of time but I'll post again if I have trouble getting my functions onto a separate event sheet.
B
11
S
4
G
1
Posts: 159
Reputation: 1,803

Post » Tue Feb 05, 2013 7:04 pm

[QUOTE=Yttermayn] dsarchy and shinkan:
1) What you said makes sense, I'll try that. Thank you both.

2) I am still confused after reading your replies to number 2 several times. Unfortunately, your examples you've supplied are both from version 117 and the free 114 version I have will not load them.
Are you saying that the function object has a name, but it needs to be referred to by yet another name? This doesn't make sense to me.[/QUOTE]

2) The name of function object is that, name of the object. You need only 1 function object in your project and you can use it to run all your functions. In event sheet you pick the function object and call function with `on function` name, not with name of the function object. Name of the function object is quite irrelevant for anything :-)
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Tue Feb 05, 2013 7:05 pm

Thanks Vee41, that made perfect sense!
B
11
S
4
G
1
Posts: 159
Reputation: 1,803

Post » Wed Feb 06, 2013 2:47 am

Shinkan: Thanks, Including the event sheet worked perfectly. This will make organizing everything much much easier. Kudos!
B
11
S
4
G
1
Posts: 159
Reputation: 1,803


Return to How do I....?

Who is online

Users browsing this forum: Rezzon71, tarek2, Yahoo [Bot] and 19 guests