Global Custom Block Storage

darrigaz

  • Posts: 124
I've got some functions I want to wrap up into global custom blocks so that I can run them from multiple locations but only have to maintain one function.

Is there a way to create a global custom block that doesn't place it in a behavior and just keeps it somewhere separate (like global attributes) or should I just make a "store all the global custom blocks" behavior and stick them all in that?

rob1221

  • *
  • Posts: 9471
Quote
should I just make a "store all the global custom blocks" behavior and stick them all in that?
Yes.

darrigaz

  • Posts: 124
Is it okay if that behavior isn't assigned to anything and just sits around in the editor?

darrigaz

  • Posts: 124
Hmm. Seems that Global Custom Blocks can't refer to game attributes?

That kinda scuppers the whole thing...

mdotedot

  • Posts: 1608
Hanging out in the Chat:  http://www.stencyl.com/chat/

Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

rob1221

  • *
  • Posts: 9471
A lot of standard blocks are tied to an instance of the Script class, which means that they can't be used at all in global custom blocks.  I'll probably look into fixing the game attribute functions though as that is the most common thing that developers want to use with global custom blocks (not now though as there's an OpenFL update going on).

Until that is fixed, you can attach your custom block behavior to all scenes and just use regular custom blocks.

EDIT: mdotedot has an alternative if you're OK with using code.

doctorfox

  • Posts: 21
Such an annoying error message.
I thought I was doing something wrong with my global custom code block by referencing the game attributes.
I finally settled for just a custom block which I had to create all over in the different behaviors I needed to use that code in.
That's not very nice for attribute scope...

captaincomic

  • *
  • Posts: 6108
Trick:
https://dl.dropboxusercontent.com/u/107982821/stencyl/global_custom_block.png


Hope it helps.

Best regards from
M.E.
Oh, I didn't notice setGameAttribute was already defined in Engine. Thanks for pointing that out. In that case the fix is easy. Fixed in the latest build.


mdotedot

  • Posts: 1608
Sorry, I moved the public folder  >:(

Should be there again!

Hanging out in the Chat:  http://www.stencyl.com/chat/

Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

Justin

  • *
  • Posts: 4449
Starting in 3.3, almost all blocks will be accessible from global custom blocks.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)