by Tu rf

Version 1 (December 20, 2021)

Download (24 downloads)

A parser to simplify array experssions in Automate, written in JavaScript, ported to... Automate.

This program aims to compress multiple variable expressions and operators (conditionals also included) into a single expression.

Due to the nature of a webpage, the entire flow is only written in 2 blocks: One for the flow start and one for the web dialog block.

The code

The code must begin with var followed by the array name and the number of elements in an array.
All statements are separated by semicolons.
Only if-else statements are supported for now.
Comments (//) are also supported.


Let's say you wanted to check whether this player has enough coins to buy an item. The item costs 100 coins. If the player had the money, take the money and give the item. Otherwise, don't take the money and don't give the item. Oh, and you also wanted to know whether the transaction succeeds or not. Normally, this takes 1 "Expression true?" block and 4 "Variable set" block to process....

var g[3];
if(g[0] >= 100){ //player has enough money?
g[0]=g[0]-100; //take 100 money
g[1]=g[1]+1; //give 1 item
g[2]=true; //transaction success
else{ //not enough money!
g[2]=false; //transaction failed

But now all of these above can be compressed into this statement, which does all of the above in one "Variable set" block!

[((g[0] >= 100) ? (g[0]-100) : g[0]), ((g[0] >= 100) ? (g[1]+1) : g[1]), ((g[0] >= 100) ? (true) : (false))]

Which will save 4 blocks from your flow.

Feedbacks and bug reports, please...
Hopefully I'll be able to add something in the future.

The code is also available here:

4.2 average rating from 4 reviews

5 stars
4 stars
3 stars
2 stars
1 star

Rate and review within the app in the Community section.