I realize it is a bit confusing on how to use custom nodes in Vizzy at the moment, so here is a guide that will hopefully help you to get started.

There are two types of custom nodes: Custom Instructions and Custom Expressions. Custom Instructions can execute any number of instructions, run loops, change variables, etc. They are a bit like a mini program. Custom Expressions can only return a value and they cannot execute other instructions.

Right now, there is no UI to create a custom node, so you need to define it via XML. I do plan to add a UI after the winter break to make this part easier.

CUSTOM INSTRUCTIONS

Let's build a custom instruction that does a countdown. Edit your program's XML and insert this blob of XML just above the closing </Program> tag.

<Instructions>
   <CustomInstruction id="9999" format="countdown from |time|" callFormat="countdown from (0)" name="Countdown" style="custom-instruction" />
</Instructions>

Now load the XML in Vizzy and notice there is a purple block on the surface.

The format attribute above defines how this looks. The |time| indicates it can accept an input. This will be the starting time to countdown from. Now let's build the bulk of the custom instruction by dragging blocks out from the toolbox. It should loop and countdown from the specified time to zero. Here's what I ended up with.

Now this is just the definition, so we need to be able to actually call/execute it from our program. Notice there is a new Custom Instructions panel with a new block we can use in our program.

The callFormat attribute in the XML above defines how this looks. The (0) indicates the block takes an input. It passes this input into the time variable in the definition we just made. Finally, let's use this in our program:

CUSTOM EXPRESSIONS

Custom Expressions can be used to return a value. They can't execute other instructions, but they can be useful if you are often repeating the same calculations. For example, an expression that clamps a value between a min and max would be handy. Here's a definition for a clamp expression:

<CustomExpression format="clamp |x| between |min| and |max| return (0)" callFormat="clamp (0) between (1) and (2)" name="Clamp" style="custom-expression">
   <Constant number="0" />
</CustomExpression>

Insert this XML blob between the starting <Expressions> tag and the closing </Expressions> tag and open your program's XML. Notice the new purple, rounded definition block on the surface and the new addition to the toolbox.

Now we can easily define what the custom expression should return by dragging out other built-in expressions from the toolbox. Hopefully, I got it right!

Now that it's defined, we can use it in our program. I threw together a simple program that just displays the result in three different test cases to ensure it is working properly.

It outputs 10, 15, and 20 in the flight scene, so it appears to be working as expected.

That's it for custom instructions and expressions. I will try and get the user interface finished so you can easily create them without having to edit XML manually.


Comments

  • Log in to leave a comment
  • Profile image

    @ShreyashJadhav there's a specific block to control Activation Groups

    one year ago
  • Profile image

    Will you please tell me how to activate particular activation group

    one year ago
  • Profile image
    30 kilobit

    How do I import a program and where do I sew it from?

    1.2 years ago
  • Profile image
    5,287 Fime

    How can I use a condition provided as an argument?
    I've already tried several possibilities but none of them work...

    1.2 years ago
  • Profile image

    @zzazza this can be a misleading answer since in the first beta and in the published version some units changed

    1.6 years ago
  • Profile image
    2,385 zzazza

    @Wings24 You can find out by yourself, it's not hard.

    1.6 years ago
  • Profile image

    means that we can make an target distance detector.

    1.6 years ago
  • Profile image
    503 swope

    Can you show an example with more than one custom expression?

    1.6 years ago
  • Profile image
    15 Wings24

    @AndrewGarrison , what are the base units used for all of the variables, e.g thrust etc.

    1.6 years ago
  • Profile image

    @AndrewGarrison How do I get the variable for craft attitude?

    1.6 years ago
  • Profile image

    @AndrewGarrison maybe something like the subassembly folder but for custom instructions and expressions can come in handy. Doesn't really matter they don't update in all programs after changing things but can help reduce time when building things.

    One custom expression I would like to have easy to access (and may even be an useful block for the stock options) is cap throttle to X twr (it's an easy thing to calculate but annoying to do it each time and may not be obvious for some users)

    EDIT: To clarify, it is min of 100 and X*100*gravity*mass/maxThrust

    1.6 years ago
  • Profile image

    @DPSAircraft that's not what I asked :(

    +1 1.6 years ago
  • Profile image

    @MetalNickA We are planning to release this update this week.

    +1 1.6 years ago
  • Profile image

    @DPSAircraft Good feedback, thank you.

    +1 1.6 years ago
  • Profile image

    @pedro16797 The custom expressions and instructions must exist in the same program XML where they are being used. I would recommend creating a "library" program XML file that you can import into any craft's program. Obviously, one downside to this is that if you make a tweak to a custom node in the library's XML file, then the places where it's already been imported will not inherit the change.

    1.6 years ago
  • Profile image

    @Foxman21
    I play on iOS apple I don’t have a Samsung or LG phone

    1.6 years ago
  • Profile image

    @AndrewGarrison is there any way to keep custom instructions and expressions in the designer and not only per craft?

    1.6 years ago
  • Profile image

    When will this be on the mobile version of the game?

    1.6 years ago
  • Profile image

    When’s the update for ios?

    1.6 years ago
  • Profile image
    5,751 Insanity

    @AndrewGarrison cool thanks

    1.6 years ago
  • Profile image

    @Insanity I see. I'll try to keep that in mind for the next update.

    1.6 years ago
  • Profile image

    @disisto4433 Not currently. That will be available in the next update after 0.8.400.

    1.6 years ago
  • Profile image

    @AndrewGarrison can you create custom instructions on iOS?

    1.6 years ago
  • Profile image
    5,751 Insanity

    @AndrewGarrison im asking because im currently trying to make a controllable character with vizzy and mouse as input would be really useful

    1.6 years ago
  • Profile image
    8 yopo

    Awesome guide, thanks!

    1.6 years ago
  • Log in to see more comments

13 Upvotes

Log in in to upvote this post.
504 PositivePlanes
37.9k KellyNyanbinary
5,751 Insanity
Dev NathanMikeska
Dev PhilipTarpley
Dev HellFireKoder
Mod SupremeDorian
8 yopo
19.7k Rafaele
Dev pedro16797
763 RenxBlake
Mod Ctracerx2
5,861 Probreyene