Stencyl 3.4.0 is now out. Get it now!

[NATIVE] Guide/Reference for Creating Extension Blocks

Justin

  • *
  • Posts: 3742
Here's an example of that block from a different extension. In this one, success is written instead of the replacement character ~, and attached block has the last id.

Code: [Select]
<block tag="save-load-succeeded"
spec="save/load succeeded [e:tag-arrow]"
code="success"
help="Use inside the custom save/load game block."
hidden="true"
type="normal"
color="red"
returns="boolean">
<fields/>
</block>

<block tag="save-load-custom-game"
spec="%0 game with name %1 [e:dash] %3 [i:save]"
code="~Game(~, function(success:Bool){~});"
help="Save/Load the game with a custom save name. The default name is 'mySave'. [i:save]"
type="wrapper"
color="red"
returns="void">
<fields>
<dropdown order="0">
<choices>
<c text="save" code="save"/>
<c text="load" code="load"/>
</choices>
</dropdown>
<text order="1"/>
<CODE_BLOCK order="2"/>
<attached-block order="3" tag="save-load-succeeded"/>
</fields>
</block>

For Live Support: Join our discord channel and ping me @justin.

danielle53

  • *
  • Posts: 54
thanks a lot Justin, I have now the right block ..
But can you resume what  the differences  are between a normal block and a code block,  so I can learn my lesson !
the logic ones .
For the usage I acknowledge that

and the last question of the day ( update not yet ) :

from the attached block  have the last id, I presume that there may be problems if there are more than one ..

I suppose I will be answered "if it too complex, bring the logic inside your extension .."

If it is not mine, Have I to build another one ? In this case, how do I tell the dependency ?

you may put a link under save-example.png, "Have a try ... here is the solution :)"

Thanks

« Last Edit: September 21, 2016, 01:32:39 am by danielle53 »

Justin

  • *
  • Posts: 3742
You can have multiple attached blocks. Here's an example.

Code: [Select]
<block tag="loop-x" spec="x" code="x" help="Use inside 2D loop block." hidden="true"
type="normal" color="blue" returns="number">
<fields/>
</block>
<block tag="loop-y" spec="y" code="y" help="Use inside 2D loop block." hidden="true"
type="normal" color="blue" returns="number">
<fields/>
</block>

<block tag="loop-2d-list-xy" spec="loop over 2D list %0 position %2 %3" code="var a:Array&lt;Dynamic&gt; = ~;var r:Int = a.length;var c:Int = a[0].length;for(y in 0...r){for(x in 0...c){~}}" type="wrapper" returns="void">
<fields>
<list order="0"></list>
<CODE_BLOCK order="1"></CODE_BLOCK>
<attached-block order="2" tag="loop-x"/>
<attached-block order="3" tag="loop-y"/>
</fields>
</block>

Sorry if I confused you by saying attached blocks are last. I don't think that's a hard requirement, it just happened to be the case in that block.

For Live Support: Join our discord channel and ping me @justin.

yoplalala

  • *
  • Posts: 1376
How can we use custom icons ?

danielle53

  • *
  • Posts: 54
There was recently a problem caused with a modified core block.

I've encounter a similar problem with  one of my extension, I just had a new choice in a dropdown (without any new code) : in quite a lot of scene the choices were mixed (not all and sometimes one out of several on the same scene)
 
I would like to know if it is possible to had a script or something to change a deprecated block automatically, that is without to have to create another block and asking the user to make the change manually 

thanks

Justin

  • *
  • Posts: 3742
@yoplalala: I posted about custom block icons here.

@danielle53: Could you file that in the tracker? I'll look into adding that capability next time I'm working on extensions.

For Live Support: Join our discord channel and ping me @justin.


yoplalala

  • *
  • Posts: 1376
Note : You can add newlines in the xml with

&#xA;

Useful for conditional compiling  https://haxe.org/manual/lf-condition-compilation.html