Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
So this whole thing started back in September;
I drew some ASCII diagrams of how the nodes would be connected, and how you'd make a simple Garrysmod thing in Blueprints.
I also poked around at Unreal's nativization tech to get a feel for how they 'compiled' a blueprint.
I decided to start with an extremely simple 'script':
OnThink -> If player is crouching -> Set player velocity to 0,0,1200
I wrote a Lua script to represent nodes and their connections: https://pastebin.com/kvM6zHi6
The blueprint did not function in anyway, I was mainly trying to feel out the structure of a graph:
- There are nodeTypes, each with a list of input and output pins
- There are nodes, each pointing to a nodeType and having an X, and Y coordinate
- There are connections, each containing 4 values (nodeA, pinA, nodeB, pinB)
With those fundamentals, I could hard-code a graph and represent it on the screen visually.
If you look at line 106 in the code listing above you can see the hard-coded simple test blueprint.
After I had a graph structure laid out, I started working on the compiler.
The goal was to convert these nodes into Lua code.
The approach I came up with is as follows:
1. Make a 'variable' for every output pin on all the nodes and emit them at the top of the script.
2. Compile each node into a Lua statement, this pass pulls variables from the previous pass.
3. Compile function nodes, and at each function node, walk backwards through all its connected pure-nodes, prepending their code.
4. Emit each compiled function node with a jump label and a goto statement to jump to the next function.
If you want to see what this looks like, this is the earliest version of the compiler I could find (6 days after starting the project):
https://pastebin.com/nR5UUVQw
If you look at the function on line 536, you can kind of see the broad strokes of how the compiler builds a script from the graph.
Now of course compilation isn't the only way to run a visual graph.
You could give each node a function to run, and have it pull from an input pin, and store the result on an output pin.
Then have your program tell all the nodes to do their thing.
My advice to you is to start as simple as possible, and build things out as you go.
Start with a simple representation of a graph of nodes, and build the simplest logic to test it.
Make a graph as simple as: "5 -> square number -> print" and see if you can get it to print 25.
If you have more questions, or just want to chat, feel free to drop by the Discord server, I'm most active there.
Cheers,
-Zak