Can i use a macro function in my c# scripts

coolwen 3 years ago updated by Lazlo Bonin (Lead Developer) 3 years ago 6

A superUnit or macro like a method in c#, so can i use this to code?

But macro is class FlowMacro , and how can i use change it into maybe a delegate?

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):

Lol last post, also talked to him in private, you'll have the solution ready within an hour or two. Hit me up on discord and we can talk about it if you have any extra ideas about this, could be missing something viable, never know.

Sorry it's actually going to take a little longer. I found something odd with Bolt as I am assuming some of this might be intentional, because we arent using it on a game object, not sure If am just doing something weird though, because the Bolt units pick up on the values correct, my return doesn't. If I do this with the FlowGraph units to do this, it works fine. If I do this with my C# static methods to trigger these events, the returning callback does some weird stuff. Even though all the callback is is just accepting back an object.

The inputs are 20 and 5. I should get 55.

This returns 40... trigger from a flow graph.... 55.

And this gives me back the proper 55 with triggering with a callback in C#, same with trigger in a flow graph.

That makes me think it could be something that Lazlo does that I do not. 

And just for your information, Super Units are not like functions, on the surface you can think of this way when using bolt itself.... but a graph returns nothing. So there is no direct beginning and end. In a return graph, you would have it like above, an entry point and exit. but you can't delay without tasking or some other form, in a single line. You can in Bolt, so that defeats how a normal C# script should work.

Edit: You can trigger custom events through code already, but they must be attached to an object, and are not the equivalent of a C# script inheriting from an object base. To use them like that, we have to invent this somehow, like I am.

uhh, i have not spent so much time learning about it, but if you can give more details about how to trigger with a callback in c#, i'll be very appreciate.

Actually at first i work with my team,and some others know little about c# coding so they use bolt , and i just want to use their graph(like macro) in my code, i dont havt to know their logic, i just use them as callback in c#, so i question this, emm but even now i havnt got the solution..

emm!I try to trigger custom event in scripts, and it does work in another way, thanku very much!

no problem, that is a more reliable way. Wasnt sure if you were talking about new graph instances in the background but apparently not. Good you got what you want though.

On my side I'm beginning to think it's really my fault how I'm handling the event outputs, but wasting too much time. I'll revisit in the future after the next update. Because there is some goodies that should help me.


Hi coolwen,

At the moment, there is no simple API function to do that. There is a suggestion for this feature here, if you want to upvote it: https://support.ludiq.io/communities/5/topics/1260-macro-invocation-from-code-api