Idea: Expression creator!

New releases and general discussions.

Post » Tue Apr 22, 2008 11:27 pm

I just got an idea that i really think would be awsome! What if, in some way you could take a calculation, and create your own expression for it! You would just copy and paste your calculation, select one part of it and click the "use as variable-button" or something, select a name, and it would be added to your list of expressions. This would be a powerful tool to speed up the coding, organize the code, and make it more readable. You could also have a button to inactivate the homemade expressions so that you could read the code as it would look without them.

What do you think?
B
8
S
2
G
5
Posts: 744
Reputation: 3,288

Post » Wed Apr 23, 2008 2:11 pm

This reminds me of an undocumented feature in the Function object. The expression:

Function.MyCustomFunction(2, 7, "Hello")

will trigger On Function "MyCustomFunction" whenever it comes to be evaluated, with whichever parameters you passed. Does this do the trick?
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,468

Post » Wed Apr 23, 2008 2:15 pm

Hopefully! I'll try.

Edit:Could someone give me some quick instructions on how to use the function object? I've never used it before.
B
8
S
2
G
5
Posts: 744
Reputation: 3,288

Post » Thu Apr 24, 2008 4:14 am

[quote="Ashley":rcwra2bc]This reminds me of an undocumented feature in the Function object. The expression:

Function.MyCustomFunction(2, 7, "Hello")

will trigger On Function "MyCustomFunction" whenever it comes to be evaluated, with whichever parameters you passed. Does this do the trick?[/quote:rcwra2bc]
So if I have you correct Ashley, that would parse an "On Function" event elsewhere in the program when it is used in a compare statement or other usage?

That's handy... if the EditBox object could be hidden in any way (it has no set x/y events like most other windows controls) then this could easily be used to add a console without having to do many events for it.
I assume that it sends back the function's 'Return True' or 'Return X' thing.
B
3
S
2
G
4
Posts: 130
Reputation: 1,735

Post » Thu Apr 24, 2008 8:31 am

That's right, example usage could be:

+ On function "SumParameters"
: Set return value: Function.Param(1) + Function.Param(2) + Function.Param(3) (ie. the sum of the first 3 parameters)

+ Start of layout
: Set edit text to Function.SumParameters(100, 5, 2)

Function.SumParameters(100, 5, 2) would return 107 - the sum of the parameters.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,468

Post » Thu Apr 24, 2008 8:41 am

*Crumples up his now ristupulous attempts at an in-game console and starts over*

That's my new word. "Ridiculous" + "Stupid." This revelation actually caused me to make up a whole new word for my prior ignorance. See what you're doing to me!? DO YOU SEE!?
B
3
S
2
G
4
Posts: 310
Reputation: 2,120

Post » Thu Apr 24, 2008 8:44 am

Yeah, I guess proper documentation would help :-\
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,468

Post » Thu Apr 24, 2008 8:50 am

Naw. I just thought I was being all smrt and stuff coming up with my own little console. This is so much better. In truth, you're racking up so many Cookie IOUs from me I might have to file chapter 13. Or at least, work that much harder so I can more quickly show you guys all the progress I've been making.

EDIT: As per hiding the text box, how about making it its own layer and doing whatever to the layer?
B
3
S
2
G
4
Posts: 310
Reputation: 2,120

Post » Thu Apr 24, 2008 11:26 am

wow this is amazing!
B
2
S
2
G
5
Posts: 448
Reputation: 2,546

Post » Thu Apr 24, 2008 11:38 am

There's no point beating around the bush, so I added Set Visible to edit for 0.95. I think I'll put together a quick wiki article on the Function object - it's got some funky features, like Condition Aliasing too.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,468

Next

Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 2 guests