playMaker

Author Topic: The Mighty Action has arrived!! Runtime javascript interpretor  (Read 5372 times)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Hi Everyone,

 Many members asked about being able to write small pieces of code to evaluate at runtime within actions, and today, I think I cracked the case!

Using Jurassic Javascript runtime interpretor, you can now write simple javascripts and it will be evaluated.

http://u3d.as/content/unify-community/jurassic-javascript-runtime-interpreter-for-unity/2tv


Now, the big challenge I failed to solved until now was a way to reference the fsm variables, and I finally found the right balance, and it turns out it's not even complicated... this custom action is like less than 100 lines...

example:
Code: [Select]
$result = $My Float*2;
That works fine, wether you want to run it once, or every frame. Notice that even space is allowed 'My Float' will be properly parse and understood as a fsm variable name.

If you have a Fsm variable named "My variable", you simply need to prefix a '$' and it will work!!!!

You want to access global variables? simply prefix 2 $ signs like this:

Code: [Select]
$$MyGlobalVariableName = $$MyGlobalFloat + 1;
this prevents name clash ( cause you can have a local fsm variable with the exact same name as a global variable, and then I would not be able to know which one you want to use.

 I haven't run any stress tests or benchmark nor published to the various platform to see how it performs, so this is really a toy at the moment

I'll build a wiki page soon, with some proper examples, but that is very straight forward really. you can even have if statements, etc etc

Bye,

 Jean

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: The Mighty Action has arrived!! Runtime javascript interpretor
« Reply #1 on: June 04, 2013, 03:29:50 PM »
This is tits.

Just gave it a whirl, the first try I threw down some math on a pile of variables and it filled in the result just like I wanted. Makes life so much easier and cleans up the variable list significantly. Haven't tried to push a build yet.

Is there a way to use a larger field (like the Comment action) so have more visible space to type?

This is much better than I expected and beats the heck out of the picture request I made.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: The Mighty Action has arrived!! Runtime javascript interpretor
« Reply #2 on: June 05, 2013, 04:10:21 AM »
Hi,

 ok, made a wiki page for it:

https://hutonggames.fogbugz.com/default.asp?W1128

and actually, you can fire event easily but just writing
Code: [Select]
Fsm.Event("MY EVENT");
 I have also made the action interface a lot more user friendly, you have now a bigger text area, and the option to select a text asset, all into a neat custom editor :) Thanks Alex!!!


 Bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: The Mighty Action has arrived!! Runtime javascript interpretor
« Reply #3 on: June 07, 2013, 02:30:26 AM »
Hi,

 ok, it will not work on IOS, because IOS doesn't support runtime compilation... too bad, but understandable they would have less control over what the app can do obviously.

If someone can test on Android, that would be great, just so we know if it compiles properly at least.

bye,

 Jean