Jump to content
Sign in to follow this  
Extraordinay

Can you create your own function ?

Recommended Posts

So if we create a script in-game with many many blocks, and I want that script to work as function, which means that I can summon it with a simple command like myFunction() is it possible in this engine?

Edited by Extraordinay

Share this post


Link to post
Share on other sites

Yes, and there are a few ways to do this.  One way is to put it in a Global Storage, and give it the name you want and define the parameters it needs.  Then, if you go to the Instructions section from inside any entity or logic, and click the name of that Global Storage, it will show that function as a tile you can drag out into your script.

Remember to use the right type, whether it needs to return information or not.  There's one that will return a single value, one that will return an array, and one that doesn't return any value.

 

You can also do this with instructions inside Entity Storage or Logic Storage.  Those can be assigned to specific objects, and it basically makes a dedicated copy of it for that object.  When you call a function that's in one of those, you have to specify which object it's attached to.

  • Thanks 1
  • Upvote 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×