Returning a value with a number block and accessing arguments values


#1

I am trying to build an extension with the extension builder for a sprite.However, I have two questions :

How do you access, in javaScript, the arguments passed to the block (number, string,…) and what format are they? string or number?
if my argument (number type) is called Number_1, do I use : args.Number_1 or args[0] ?

How do you actually return the value? I tried adding “return 15;” in the live mode handler section and/or in the common settings and both do not work. My block always returns a NULL value.

It is probably not something very complicated, but I am new to this…

Thanks!


#2

Just in case anyone else had these questions as well, here is what I found out (Ok, I started programming in JS in the last three days, so this might seem obvious to others…)

To access the block parameters : if you called it Number1 in the block definition, you access it with args.Number1
however, this is a string. So if you need teh numerical value, you use : parseInt(args.Number1). You may want to return the numerical value if it is a Number type Block.

I hope this can help!


#3

Hello @Em29,
There are several questions in this post, may be I can help you a little:

Best regards
Rodrigo