playMaker

Author Topic: Conditional Expression Action (BETA)  (Read 12580 times)

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3205
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Conditional Expression Action (BETA)
« on: May 17, 2014, 09:58:57 AM »
First a huge thanks to Lea Hayes for doing all the hard work on this action!!

The Conditional Expression action lets you evaluate an expression as true or false and store the result or send events based on the result.

You can use named FSM variables in the expression. If the variable name has spaces use this format: $(variable name with spaces)

Anyway, have a play with it and post feedback. This should be considered a beta release. The final version will be included in the next update.

And again, a huge thanks to Lea Hayes for contributing this action to Playmaker!
Lea makes the excellent Rotorz Tile System: http://u3d.as/content/rotorz-limited/rotorz-tile-system/2UU
He also has a great blog: http://leahayes.wordpress.com/
And Rotorz blog: http://rotorz.com/blog/

EDIT: Updated to v1.1:
- Made text field bigger.
- Added Refresh button.

Some sort of auto-refresh is preferable, but it will need editor support, so for now there is a manual refresh button for when you add/remove/edit variables and then return to the action.

EDIT: Fixed build error.
« Last Edit: May 21, 2014, 09:40:15 AM by Alex Chouls »

TrentSterling

  • Junior Playmaker
  • **
  • Posts: 89
  • Someday I'll make games!
    • View Profile
    • My Blog
Re: Conditional Expression Action (BETA)
« Reply #1 on: May 17, 2014, 10:17:22 AM »
 :o oWoow

EDIT: I like seeing programmer centric actions. Being able to evaluate little bits of code like this might not be strictly 'playmaker style', but it would really cut down on action clutter and it's quite awesome!

And I'm also happy I avoid spaces in my variable names now :)
« Last Edit: May 17, 2014, 10:21:01 AM by TrentSterling »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
Re: Conditional Expression Action (BETA)
« Reply #2 on: May 17, 2014, 10:19:42 AM »
Awesome!  ;D

1) First thing I would suggest is a bigger space to type the expression =) Like the comment action field has.

2) Also during the editor mode you have to actually click and change the expression field if you want it to re-evaluate any variable changes you've made in the editor.
« Last Edit: May 17, 2014, 10:21:54 AM by Lane »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12344
  • Official Playmaker Support
    • View Profile
Re: Conditional Expression Action (BETA)
« Reply #3 on: May 19, 2014, 06:35:11 AM »
Hi,

 Very cool, I would see straight away a lot of thing to expand on this.

 expression should allow the return of more than a bool, floats, ints, string, etc. I feel it could be frustrating to get such a convenient action to just return bools, but I am not sure how it's made under the hood, so it may be not really possible to expand on this.

also, I tried to use a string variable but I think the value will always evaluate to true, I think it should evaluate string for "1", "true" "false", empty or with content and return true or false on these cases.

Or, maybe double check what variables are use and warn the user about unsupported variable types within this expression

Bye,

 Jean

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3205
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Conditional Expression Action (BETA)
« Reply #4 on: May 19, 2014, 01:22:23 PM »
Awesome!  ;D

1) First thing I would suggest is a bigger space to type the expression =) Like the comment action field has.

2) Also during the editor mode you have to actually click and change the expression field if you want it to re-evaluate any variable changes you've made in the editor.

Great feedback! I've uploaded v1.1 above...

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3205
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Conditional Expression Action (BETA)
« Reply #5 on: May 19, 2014, 01:25:42 PM »
Quote
expression should allow the return of more than a bool, floats, ints, string, etc. I feel it could be frustrating to get such a convenient action to just return bools, but I am not sure how it's made under the hood, so it may be not really possible to expand on this.

I'm looking into this - maybe Lea will help out :)

But I think it will be a separate action, e.g.,: Math Expression.

Quote
also, I tried to use a string variable but I think the value will always evaluate to true, I think it should evaluate string for "1", "true" "false", empty or with content and return true or false on these cases.

Or, maybe double check what variables are use and warn the user about unsupported variable types within this expression

Good point. This should be possible...

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
Re: Conditional Expression Action (BETA)
« Reply #6 on: May 21, 2014, 04:35:22 AM »
Build errors! Woo!

This is for Standalone. It also happened on the previous version.

The line compiles apparently, so I assume its not being picky about formatting. (edit, actually it fails without any actions being used, so its in the dll)
« Last Edit: May 21, 2014, 04:37:08 AM by Lane »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3205
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Conditional Expression Action (BETA)
« Reply #7 on: May 21, 2014, 08:52:33 AM »
Thanks! I'll fix this in the next release...

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3205
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Conditional Expression Action (BETA)
« Reply #8 on: May 21, 2014, 09:40:44 AM »
Uploaded a new version that should fix the build error.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
Re: Conditional Expression Action (BETA)
« Reply #9 on: May 21, 2014, 10:28:50 AM »
Works great, I can't seem to break anything else on it. Going to start using it on future iterations of the flight AI and might find more out then. Bundling lots of conditions into a bool value is going to be so useful for AI, especially with a delegate fsm just reading contextual data and flipping bools, then the behavior fsm responding to those flags async.... *hnnnngggghh*..

Only other thing I notice that could be a small nuisance is toggling the expression box to a variable and back will null the field, so you lose anything you might have typed in. Really just a minor inconvenience on the rare occasion that you hit the button accidentally.

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3205
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Conditional Expression Action (BETA)
« Reply #10 on: May 21, 2014, 10:34:51 AM »
Great! Please also keep an eye on performance as you use this. I'll build a stress test to compare expressions to regular actions, but I'd also like real world tests...

Red

  • Hero Member
  • *****
  • Posts: 563
    • View Profile
Re: Conditional Expression Action (BETA)
« Reply #11 on: July 29, 2014, 09:39:51 AM »
This is fantastic! Many, many thanks to the developer!

One question... What if I wanted to get the "X" value of a vector2 variable (or vector3 variable) to test? Would it be something to simply extract and place into a float or would there be something like a "Vector2.x" or "Vector2[1]" kinda thing?

edit: using "Vector2.x", "Vector2[1]" and "Vector2{1}" all produce errors... So, can I get it to fetch the values within the expression itself or is this something that I'd do with an action external to this function? If the suggestion to me is to extract them separately, I'd love to suggest the ability to work with vectors (both 2 and 3)
« Last Edit: July 29, 2014, 09:49:40 AM by Red »

gsmetzer

  • Playmaker Newbie
  • *
  • Posts: 24
    • View Profile
Re: Conditional Expression Action (BETA)
« Reply #12 on: August 06, 2014, 09:50:27 AM »
I also agree with Jean that it would really expand functionality if we had different variable outputs.   I would love a similar math action where I could do things like, example:

(myFloat1 + myFloat2)/myInteger  = myOutput float


everyframe

Does that make sense? 
It could really cut down on the clicks and extra actions

Yanifska

  • Full Member
  • ***
  • Posts: 159
    • View Profile
    • My Portfolio
Re: Conditional Expression Action (BETA)
« Reply #13 on: August 07, 2014, 05:24:33 AM »
That would definitly help a lot !
+1 for math action
Visit my portfolio: http://www.yanivcahoua.com/

Red

  • Hero Member
  • *****
  • Posts: 563
    • View Profile
Re: Conditional Expression Action (BETA)
« Reply #14 on: August 25, 2014, 09:04:26 AM »
I think I may have stumbled on a potential bug here... Not sure if this is with the expression system itself or if it's with the prefab management thing but here goes the details.

I've noticed that sometimes the conditional expression doesn't always update the proper expression in the field when working with it as a prefab and adjusting or changing it. The expression shows the right one but it behaves like a previous change/edit/etc... The workaround I found was to simply remove that action and re-add it and put the expression in again which makes me think that there may be a bit of confusion in how the expressions are stashed and handled. It's not something I can easily reproduce but if I do come across it again I'll do what I can to save the information so that I can maybe post a package link.

Still, I can't say that this sours me on this system... It's fantastic! But as with it being beta I can totally understand how there may be some bugs to work out or that kinda thing (and it may not even be with the system itself but rather the prefab management thing that was (is?) an issue.)