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
    100 BNKAB

    How do i do this on Android?

    3 months ago
  • Profile image
    547 kilobit

    @N1ghtH4wk Hi spoiler alert!! Building pretty fast

    2.8 years ago
  • Profile image
    559 N1ghtH4wk

    @kilobit hi kilobit

    2.8 years ago
  • Profile image
    Dev Pedro

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

    4.4 years ago
  • Profile image

    Will you please tell me how to activate particular activation group

    4.4 years ago
  • Profile image
    547 kilobit

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

    4.5 years ago
  • Profile image
    6,047 Fime

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

    4.5 years ago
  • Profile image
    Dev Pedro

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

    4.9 years ago
  • Profile image
    2,542 zzazza

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

    4.9 years ago
  • Profile image

    means that we can make an target distance detector.

    4.9 years ago
  • Profile image
    507 swope

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

    4.9 years ago
  • Profile image
    15 Wings24

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

    4.9 years ago
  • Profile image

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

    4.9 years ago
  • Profile image
    Dev Pedro

    @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

    4.9 years ago
  • Profile image
    Dev Pedro

    @DPSAircraft that's not what I asked :(

    +1 4.9 years ago
  • Profile image

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

    +1 4.9 years ago
  • Profile image

    @DPSAircraft Good feedback, thank you.

    +1 4.9 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.

    4.9 years ago
  • Profile image

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

    4.9 years ago
  • Profile image
    Dev Pedro

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

    4.9 years ago
  • Profile image

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

    4.9 years ago
  • Profile image

    When’s the update for ios?

    4.9 years ago
  • Profile image
    10.9k Insanity

    @AndrewGarrison cool thanks

    4.9 years ago
  • Profile image

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

    4.9 years ago
  • Profile image

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

    4.9 years ago
  • Log in to see more comments

15 Upvotes

Log in in to upvote this post.
504 PositivePlanes
40.7k KellyNyanbinary
10.9k Insanity
Dev NathanMikeska
Dev PhilipTarpley
Dev HellFireKoder
Mod SupremeDorian
8 yopo
21.4k Rafaele
Dev Pedro
868 RenxBlake
16.0k Mod
6,445 Probreyene
6,831 Yoon
100 BNKAB