0 Favourites

Idea: Expression creator!

This forum is currently in read-only mode.
  • 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?

  • 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?

  • 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.

  • 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?

    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.

  • 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.

  • *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!?

  • Yeah, I guess proper documentation would help :-\

  • 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?

  • wow this is amazing!

  • 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.

  • 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.

    It's indeed very usefull, but it doesn't really help me in my problem. you se.. when you get events like these, and plan to add like 20 more events like this one, it would be nice to have some short-version of, in this case;

    Find(Detector.Value('Overlapping') , "(variable.1)")

    <img src="http://img166.imageshack.us/img166/5261/infiniteeventjt0.jpg">

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • Ouch, thats a nasty way of going about things. Have a subevent that loops through a list maybe, rather than hard coding it

    And out of curiosity, what the hell do those numbers mean?!

  • Don't really know much about sub-events, but wouldn't it look just as bad, only i'd be able to hide it with a little [-]/[+]?

  • No no no, put all those numbers/strings in an array or whatever, then loop through the list! (you dont actually need subevents for this) For example - from memory, so dont try pasting:

    + On function "MyExpression"

    + For each element in Array

    + Find(Detector.Value('Overlapping'), Array.CurrentXValue) equal to 0

    Do stuff...

    or something along those lines. Basically store all those strings in an object somewhere, and iterate them, instead of laboriously listing the conditions one by one...

    But as I type this I think what kind of ugly obfuscated system requires string searches with weird numbers like that??? You're crazy!!

  • But with an array, i would instead get to hardcore all the Array.set index at (a,b) to (c)... or is there a way to set the values? It would be nice to have an array that you could actually see! that looked kind of like an excel document, and you could just klick a cell and write a value. Maybe even use the excel commands like =1,5+1,6

    [quote:320ctzj8]what kind of ugly obfuscated system requires string searches with weird numbers like that??? You're crazy!!

    Wait and see...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
Original idea in this thread...
98 12,608
Ashley's avatar
Ashley Construct Team Founder
Unread hot topic
76 39,575
moxBorealis's avatar
moxBorealis
Unread hot topic
0 Favourites
Suggestions and ideas
60 9,077
Rich's avatar
Rich