Download

Ingame visual programming - how to realize?

Hello there,

i am not sure, if this is the correct section, or if this would belong into UI or blueprint scripting. Well, i just want to ask, if anybody here knows a tutorial or a link to an helpful site for creating a kind of ingame script language or ingame visual scripting here in Unreal Engine (blueprints only, if possible), just like blueprints, but accessible from the game itself and changeable during runtime.

To show you, what i mean, there are some games, that are built around the idea of programming your bots or figures during the game, so that they act on their own and complete the tasks by themselfes (most of the time). Basically, you create their AI during the game, with parts and code, that you create during that game.

One of those games is “Main assembly” currently in development, and they use UE4 for it, here is a look at their solution:

https://store.steampowered.com/app/1…Main_Assembly/

There you can see all the functions and parts, that the user can use to create the programming for his machines, and how he can connect them by just dragging and dropping them on the grid and connect the pins, just like our blueprints here.

Other examples would be systems like this are older games like Carnage Heart and its sequels (there it lacks the ability to connect nodes whereever you want, so its more puzzeling):

or with an old BASIC style programming language, the ancient DOS-game “Omega”:

https://i2.wp.com/62.210.205.110/blogimages/omega_005.png?w=584

Thanks in advance :slight_smile:

You are forbidden by contract to use classes from Unreal Editor in shipped games…

So for something like that you have to build your own “language” and bind that language to functions you have in your game to perform actions based on that language (an API).

Yeah, that´s what i thought about, or that seemed to be the way, all those games used, they created their own (script) language. In some cases this language is represented as a kind of basic dialect, in others just as icons, but they all do similar actions.
But i can´t find much material about this topic for unreal engine (or in general), or i am using the wrong terms for google ^.^

I am writing my own for similar reason…
But I am creating an “expression parser”, not a general purpose scripting language; they are very similar tho, I am reading this series while experimenting with my own lexer/parser/interpreter:

http://craftinginterpreters.com/

Thanks, i will take a look at that :slight_smile:

This is very interesting stuff!
I began making a “Lexer” that is purely written based on “Unreal Types”, no STD dependencies neither RTTI usage (also not using any types from Unreal Editor)…
I input some “script” and the lexer class returns to me an array of UStruct containing all the “data” I need to inject into a “Parser” then later translate those structs from the array into a in-game visual scripting system :slight_smile:

So far input script looks like this:



var int myintvar = 2;
lit float myfloatlit = 4.76;
prop rotator myrotatorprop;

lit char mytchar = 'C';
lit string mySLiteral = "Hello world!";

var int myintArray];

lit float myfloatarray[5] { 1.0 , 3.5, 0.85 , 2.2 , 5.0 }


// This is a comment.

/* this is a
      multi-line comment,
 like in C languages. */


fun exec mFunction(float x, float y) { sin(x) * sin(y) + x * y; }

fun float myMethod (float x, y) {
      return sin(x) * sin(y) + x * y;
}

var float mf = myMethod(myintvar, myfloatlit);


Then the resulting array of structs return to me these results:

I think I should add more work to interpretation of “function bodies”, but for now I’m glad it’s not a total disaster.

That looks like C++, the exact thing, i hoped to avoid :eek: (and why i hoped for a pure blueprint way ^.^ ). Well, i found some older stuff about lexer and parser on the net, so i guess, i start reading this.