Announcement

Collapse
No announcement yet.

Add a scripting Code Node

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Add a scripting Code Node

    Hi All,

    I posted in the Blueprint forum and have been discussing the idea over there. But seems about time to post it here:

    It's an idea for a custom node called a 'Code Node'. This would be a half way between C++ and Blueprint and would be a node with a text box in it that could could type a simple function into. The connectors would then appear on the node and the results would be processed when it is fired.

    Probably easier to show you what I mean rather than describe it: (Disclaimer: Rough Mock Up)



    Not intended for 'Monster' code, but small sections that would be unwieldy as a node network.
    (Edit: Yes I know the code is a bit wonky )

    vs



    I mean, the Blueprint version is pretty hard to read and work with.

    Yes, you can turn it into a function and clean it up, but it took several times longer to make the network than it did to write the code, and it's relatively simple code. Also it will take the same productivity hit every time I need to modify it in some way.

    The script would likely be limited to a single function, could be a C++ Syntax interpreted script, and maybe only needs flow control, maths and decent string handling to be useful.

    Regards,

    Lee Page
    TeraBit Software
    45
    Yeah, that'd be cool
    77.78%
    35
    Nah, I'll just use VS & C++ instead
    22.22%
    10
    Last edited by TeraBit; 04-04-2014, 10:18 AM.
    Regards,

    Lee Page
    TeraBit Software

    #2
    This would be really useful, please add it mighty devs!

    Comment


      #3
      Would also like to see c++ nodes. It is quite easy to add a script interpreter and access it from blueprint nodes (I have played around with adding a javascript interpreter), but be able to add c++ code that got compilied would be better. Also anything like this needs a decent text editor window so long text strings in a blueprint can be edited. Currently they seem to be limited to a single line text edit box.
      Last edited by MattW; 04-04-2014, 10:56 AM.

      Comment


        #4
        (I have played around with adding a javascript interpreter)
        Had a look at that, looks pretty cool! But, as you say, it needs better support from the node framework to realise the potential.
        Regards,

        Lee Page
        TeraBit Software

        Comment


          #5
          Just to add, as well as flow control, math and string handling, it would need to be able to call all the other Blueprint functions, so in the example above, I used Sin and Cos, but in the blueprint I used the Sin Degrees function. So I suppose it would be SinD or SinR and so forth. I suppose what I'm saying is, it doesn't need to do things Blueprint can't, but be a Blueprint in a bottle.
          Regards,

          Lee Page
          TeraBit Software

          Comment


            #6
            Hnm, I had an idea kind of along similar lines, but that doesn't break (or wound) the whole blueprint paradigm:

            The core issue as I see it is that the blueprint is great (no, brilliant) but is a bit busy for my tastes. Doing a simple 'if' creates too many nodes & wires. I'd like to see this consolidated a bit by making, for example, a branch node that actually contains the conditions instead of being wired to it. Etc etc. This 'could' greatly reduce blueprint complexity. They could even be built alongside the existing 'verbose' style nodes, allowing the developer to choose the style he wants to use...

            Comment


              #7
              An interesting idea, but somehow I don't think the Epic devs are going to bite. (I usually am proved wrong though!)

              The thing that really gets my juices flowing when thinking about this declarative blueprint style of programming is that it (could, potentially) be free-threaded with no effort by the developer. Once you start adding conventional programming language constructs back into the mix, all of the old dependency problems start to come back. It could probably be controlled my intelligently partitioning code across nodes, but somehow I think Tim and the team put a lot of effort into dumping UnrealScript for good reasons and it might be an uphill battle (to liberally mix metaphors).

              Heck, if you could use blueprints to write HLSL, without threading issues, now that would really kick ***!

              Comment


                #8
                I am actually working on the V8 binding, and have this as a goal as well. I have started playing with the ability to expose it to BP and it seems to be working pretty well already.

                The issue with having C++ be parsed, compiled and executed is that, since it would be coming via a text node and possibly a variable, it would likely require that you re-imagine the language as interpreted. The benefit to using JS or another of the dozen or so interpreted languages that already exist is that you can leverage their libraries and code examples and not have to deal with the complication of rolling your own.

                One other note about it being C/C++: If you know C/C++ well enough to write code with strong type checking as a dynamic string and have it compiled out... you probably would be better off using VS and exposing a custom node to do what you want instead of having it compiled out at runtime.

                &TLDR;

                You will be able to do this soon.
                You just have to wait for a couple more iterations of the plugin to be able to do it.
                Last edited by Bob_Gneu; 04-04-2014, 11:23 PM.
                About Me | JavaScript and UE4 | Exodus | Code Notes

                Comment


                  #9
                  I am actually working on the V8 binding, and have this as a goal as well. I have started playing with the ability to expose it to BP and it seems to be working pretty well already.
                  Looks good. Linking existing scripting languages is good as long as it has access to the same resources as blueprint. i.e. can call blueprint functions (like the SinD example) so the results are consistent.
                  On the other hand if you're working on being able to type the code into the node as in the example above and have dynamic variable and execution pins, that would be awesome.

                  Is the result completely cross platform for all targets? It seems like a feature that is useful enough (a few different people are working on similar lines), that official support for something like it would be worthwhile too.
                  Regards,

                  Lee Page
                  TeraBit Software

                  Comment


                    #10
                    Originally posted by TeraBit View Post
                    Looks good. Linking existing scripting languages is good as long as it has access to the same resources as blueprint. i.e. can call blueprint functions (like the SinD example) so the results are consistent.
                    On the other hand if you're working on being able to type the code into the node as in the example above and have dynamic variable and execution pins, that would be awesome.

                    Is the result completely cross platform for all targets? It seems like a feature that is useful enough (a few different people are working on similar lines), that official support for something like it would be worthwhile too.
                    V8 has targets for Android, Windows, Linux and OSX - I am not sure about iOS but if there is a need I can look into it or branch the plugin to support another library if need be. I am not particularly worried about cross platform support though. I understand a lot of people are very interested in finding a solution for everything. I think that it is going to be lofty goal already to be able to get the plugin to expose all of the engine - a request that I was not expecting and am not likely to undertake. I expect that the plugin is going to serve the purpose of sitting between C++ and BP, providing those of us who enjoy dealing with Hoisting and closures but not so much with typing - and that requires that I at least walk down this road of BP nodes.

                    I am not clear how feasible it will be to call out of JS into BP though. Maybe through exposing events, but I'm not sure yet.

                    Join my thread and give me input as things go on. It would be greatly appreciated.
                    About Me | JavaScript and UE4 | Exodus | Code Notes

                    Comment


                      #11
                      V8 has targets for Android, Windows, Linux and OSX - I am not sure about iOS but if there is a need I can look into it or branch the plugin to support another library if need be.
                      You or I may not need so many targets for our own projects, but when thinking of UE4 as a whole, it's good to look at the whole picture. Windows, Linux and Mac could be possibly handled my Mono and the .NET framework, which opens up a lot of possibilities, but it won't work for Mobile.

                      I think that it is going to be lofty goal already to be able to get the plugin to expose all of the engine - a request that I was not expecting and am not likely to undertake.
                      Probably not necessary for the purposes you have in mind, but again it helps keep in mind how 'plugged in' a plug-in it will be.

                      Join my thread and give me input as things go on. It would be greatly appreciated.
                      Sounds good, I'll be looking in, but am also interested in whether it is something Epic would consider making something part of Blueprint in some official capacity. If not I'm tempted to have a go myself too.
                      Regards,

                      Lee Page
                      TeraBit Software

                      Comment


                        #12
                        Just maths. Just a node with variable inputs and a line for typing in operations using the variables.

                        Comment


                          #13
                          Why not just write you node directly in C++. This would make it also easier to reuse it.

                          C++ is not a scripting language, hence you cant just parse it at execute it at runtime. Also Epic has made a clear decission against a scripting language and this example doesnt really make a point toward a scripting language. What you want to achieve here can be easily done just by adding your Node in your sourcecode.
                          July's GameJam Entry: https://forums.unrealengine.com/show...l=1#post341226

                          Comment


                            #14
                            Originally posted by Brainshack View Post
                            Why not just write you node directly in C++. This would make it also easier to reuse it.

                            C++ is not a scripting language, hence you cant just parse it at execute it at runtime. Also Epic has made a clear decission against a scripting language and this example doesnt really make a point toward a scripting language. What you want to achieve here can be easily done just by adding your Node in your sourcecode.
                            I understand the point, but this is positioned as a middle ground for very simple use cases as shown above, not really reintroducing 'Unreal script' with all its hierarchy and complexity.

                            That being said, I have an idea that could give a third approach which solves most of the problems... Could even be better in some ways... Just got to check if it can be done.

                            It would be good to get a view from the Devs, as if I do find the other approach is feasible, it will require a fair bit of work to make happen. I'd hate to spend a couple of months doing it, then without warning have them add a shiny new 'Code Node' to Blueprint.
                            Last edited by TeraBit; 04-07-2014, 04:05 AM.
                            Regards,

                            Lee Page
                            TeraBit Software

                            Comment


                              #15
                              We have a similar feature called the "Expression Node" that's slated for a near-future release that addresses some of these problems!

                              While we don't currently have a full scripting node in the works internally at Epic (and it sounds like you guys are well on your way to doing that ), we aim to make some of the spaghetti of the first post more readable. The expression node basically allows you to type in a mathematical expression like "X + Y / Z" directly on to the node. The expression is then parsed, and inputs for X, Y, and Z are created. That should cut down on a lot of the complex pure-node logic like seen in the original example.

                              Comment

                              Working...
                              X