# Expression Stacker - A kind of 'click' expression

0 favourites
• 16 posts
From the Asset Store
Tower stacker
\$9.99 USD
Template for a tower stacker game, fully documented in comments and video
• Hey guys, I've been pondering over a kind of expression stacker, which might make doing maths a bit easier. I was pondering over the idea in this thread:

So anyway, basically the idea I was was that you had 'blocks' that could snap to other blocks and be dragged around. You could easily insert blocks between blocks and generally it should be pretty easy.

So you could type

distance

Then drag 'distance onto the screen

Then type xy

Drag xy in one of the parameters of distance

Then mouse

Drag mouse into the other parameter

Then type

3 *

And get a block that has a multiply with one parameter '3' already filled in...then drag the 'distance' into the other parameter...

Then type clamp(,0,100) and it would leave the first parameter blank...

Simially you could just type the entire expression, or just type 'clamp', or select 'clamp' from a list....

Anyways, these are some designs I came up with :

<img src="http://dl.dropbox.com/u/939828/stack1.PNG">

And heres just one section by itself with nothing connected to it

<img src="http://dl.dropbox.com/u/939828/stack2.PNG">

I might not even end up programming anything like this, its just a fun idea for a project, and maybe it could be implimented for Construct 1+ or Construct 2, who knows...

So, design wise, what do you think?

Also...by just looking at the picture, do you think it would read logically as:

clamp( 3 * distance( mousexy, xy), 0, 100)

Or does it just look like a big confusing pile of blocks?

• dX=mousex-x

dy=mousey-y

distance=sqrt(dx^2+dy^2)

number = 3*distance

min=0

max=100

clamp(number,min,max)

Basically what you do is condense each operation into one variable and operate on the variables instead. It is much easier to work with units (variables) than whole expressions.

I suppose that these blocks would be named; when clicked, they would expand, showing the details. Click onto each of blocks to expand the whole expression or to collapse them into the simplest form:

clamp(number,min,max)

click on number and it expands that block

clamp(3*distance,min,max)

Etc.

Abstraction, woo.

• I like this concept. I use a lot of these expressions and I think this is a good way to simplify and organize them.

• It's an interesting idea for sure, but (ya know I love ya David, no offense ) in all honesty there's not much difference in reading that than there is in reading

clamp(3 * distance(coordinates, coordinates), 0, 100)

It's just that the components are raised up in their own sections instead of being in between parenthesis. If you were to squash it down flat it would read pretty much the same. Moving the components around is also an interesting idea, but practically speaking is that really any easier than highlighting the part you want to change and typing something else?

I know you were looking for a more visual representation of the structure of a math function, but from the point of view of someone who doesn't understand math, I think it's still going to look pretty much like math. The problem of learning and understanding the math concept behind it is still there.

I'm sorry, I hate to be a naysayer. Perhaps I'm just misunderstanding the point?

• I'm kinda trying to find something in the middle of those weird visual language diagrams and traditional maths so people dont suddenly get locked into learning one style...but yeah I guess it is just like having one equation where brackets are raised.... meh

• It looks more complicated than events / scripting to me. Course that could be entirely different -in practice- cause even node/flowchart setups are complicated if you've never seen or used one before.

How about.. wizards, you know, those things that hold your hand every step. Wouldn't that work as a middle ground and keep everyone happy? It would also mean not changing much at all, so those wanting to learn events or scripting can continue to, but with the added help of more informative steps to help them, cause any language is easy to learn if you've got the proper documentation and help at hand. While others who already know and understand it, can switch the wizard off.

Basically, exactly the same way it is now, but with more information on what that particular step does. So not really a wizard either, just more info given.

--

Or failing that, go with the node based setup after all, but do it backwards like Lightwave's textures and XSI's render tree. Where you've got your base node (in constructs case, this would be things like 'Always' and 'Start of Layout' and anything that begins an event, collisions etc.) then adding other nodes to them as normal.

Now at the same time as that, you've got two columns, practically like you have now, and just move events up and down in the order, add sub events (which I admit could be more clear) and so on. Each node can have a help text attached, or linked to specific wiki pages. (Because clear documentation is the key really).

Each possible event could be represented as a node. So visually it would be much clearer if a node required more than one input to work.

As for keeping it clean, just have a + and - icon for expanding each event. So everything could be put away and kept nice and tidy. And also allow the option of displaying it in the current event method (since the above wouldn't be that different on the inside).

I know, I know. I posted a pic the other week complaining about these node things being a headache when they get complicated, but I admit in hindsight I was being unfair and did use Massive (which will always look complicated lol), but Lightwave or XSI do have much nicer node layouts.

• meh

I'm sorry, now I feel like a jerk

I do think the search for a more visual method of displaying math functions is an interesting idea though. I just can't think of anything that doesn't involve a picture of five apples over a picture of three apples and a cartoon worm wearing glasses asking how many apples there are all together.

• Thing is its already freakishly simple. When you come to a input section all you have to do is click on the system icon, and that brings up all the system expressions. Heck you guys made picking expressions easy. Instead of just saying lerp(), or distance(), it says linear interpolation, and distance between two points.

• ## Try Construct 3

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

Construct 3 users don't see these ads
• But wait! What if you used that stacker for EVENTS rather than expressions?

• I agree with Deadeye, Its practically the same thing. I think it may even end up destroying readability for those really long expressions; you'd have a pyramid sky high.

I just can't think of anything that doesn't involve a picture of five apples over a picture of three apples and a cartoon worm wearing glasses asking how many apples there are all together.

Basically, exactly the same way it is now, but with more information on what that particular step does.

I think that's what the wiki is for though, all the expressions are explained clearly. It could use some expansion however.

It would be great to find a middle ground like Davo said; between text and graphics. I just don't see how multiplying by 3 with (*3) in text is any more complicated or unreadable than a square or node which says multiply::::__3___::::: __number__:::::.

• i think this would help those who are weaker with their math skills but are strong visual learners to be able to see a visual organization

• You know, there's another idea that I think tossed around in the chat a while ago...

Make the expression editboxes multiline-togglable. I noticed that if you write the expression on multiple lines in say Notepad and paste it to the expression editor it doesn't destroy the multi-lining and it even shows up in the event sheet editor.

So that instead of having just

clamp(3*distance( mousexy, xy),0,100)

you could have:

clamp(

3*distance( mousexy, xy),

0,

100

)

Of course for such a simple sentence it doesn't do much but for me it helped writing some more complex stuff.

Another thing that would be useful is syntax highlighting. And one thing specifically - when your text cursor is over a bracket, ( or ), it will highlight the equivalent start/end bracket. This is what editors like Notepad++ do by default and it helps so ridiculously much it should seriously be implemented in everything. Especially in Construct, since you can easily write expressions that end up looking like lisp (with (all (the (goddamn (brackets))))).

• multi-line and color coding would be helpful, I agree.

• I tend to write stuff in notepad in multiline and when I'm done, I remove spacing and copy to construct.

What do you mean with stacking? HP48 had "stack" (RPN) and most people were baffled by it. It was awesome for doing big calculations without using parenthesis but that wouldn't even apply here.

• haha 'Expression Stacker' was just a name for it because I imagined people dragging and dropping expression bits and pieces onto each other like a stack...or a pile...

Anyway I dont think it's really something that would be useful. Its good practise to learn how to type expressions. I added syntax highlighting and bracket matching to the expression editor anyways.

Here was a final design I came up with

<img src="http://dl.dropbox.com/u/939828/stack3.PNG">

Basically, a 'block' could be setup so the text was in the middle...so the Multiply looks like a proper multiply...and secondly the parameters dont have text for them (Multiply doesn't need text with A, B) then the stack above is lowered.

The only remaining problem with the stack is if you do something like:

5 + 3*3 + 2 you end up with 3*3 as one stack, and 5 + (3*3) as the stack below, then (5+(3*3))+2 as the stack below that.

• 16 posts