Announcement

Collapse
No announcement yet.

[GAUGING INTEREST] Blueprint only embedded scripting language

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

    [GAUGING INTEREST] Blueprint only embedded scripting language

    I have been working on a blueprint only project and I required a simple scripting system to help content creators to drive gameplay through data.

    What it does:
    Using the blueprint node 'ExecuteScriptString', a text string will interpret and run a set of instructions at runtime.
    The syntax is similar to C like languages, and the variables are held in string format.

    Code:
    //Example1:
    // Create or set the variable x to 4
    x = 1 + 3;  
    
    //Example2:
    //Concatenate a string and set as a variable
    x = "Hello " + "World";
    
    //Example3:
    //Call a custom function
    x = 1; y = 2;
    Sum(x,y); //returns 3
    
    //Example4: 
    //This more complex example will concatenate strings
    //and use the ternary operator ?: (?: - 'if else') to set x to a string value
    y=6;
    x = y > 0 ? "Y is " + y " which is larger than zero" : "Y is not larger than 0";

    How I am using it:
    This scripting system is used extensively in my Blueprint Dialogue System for testing conditions, inlining dynamic text, and executing functions from within a datatable.

    I will also be using it to drive the quest system in our game(s).

    Other uses for an embedded scripting language might also apply, although anything too intensive (like running complex ai) is going to be too slow, since it is interpreted at runtime through blueprints.

    About other scripting languages:
    There are plugins for LUA and JavaScript which would be much faster and more powerful, but these require plugins, so it wasn't a good fit for me at this time.

    While Blueprint is itself a scripting language, and embedding a language within it is almost tacky, I have found it to be an obstacle when trying to drive gameplay with data.

    I am wondering if there would be any interest in this system on the marketplace?
    7
    Yes, I would like to have this blueprint system
    57.14%
    4
    No, I have no use for it
    42.86%
    3
    I have use for it, but I prefer a plugin
    0.00%
    0

    #2
    cant this be workin also with executeconsole ?

    Comment


      #3
      Originally posted by Kanizitas View Post
      cant this be workin also with executeconsole ?
      I don't believe execute console can create/set variables, perform arithmetic, or string manipulations (although if it can, it would save me a lot of trouble haha). Is that what you meant?

      Comment


        #4
        Hi Grogger. A simple scripting language makes perfect sense to me in a Quest/Dialog system. In fact, I initiated work on the UE4 Powered WIZMO 3D Interactive Fiction Drive starting with its Scripting system. I think it comes down to a balance of features and syntax. I elected to go with a BASIC-like Markup Language in anticipation of heavy use of Text for Dialogue and Narration. I've written a few Scripting Parsers over the years and would be interested in sharing notes on the technical side of implementing a Scripting Language w/ Blueprints.
        GOD of DREAMs: A Unique FTPS/RPG Sandbox MMO

        Comment


          #5
          Originally posted by TechLord View Post
          Hi Grogger. A simple scripting language makes perfect sense to me in a Quest/Dialog system. In fact, I initiated work on the UE4 Powered WIZMO 3D Interactive Fiction Drive starting with its Scripting system. I think it comes down to a balance of features and syntax. I elected to go with a BASIC-like Markup Language in anticipation of heavy use of Text for Dialogue and Narration. I've written a few Scripting Parsers over the years and would be interested in sharing notes on the technical side of implementing a Scripting Language w/ Blueprints.
          Hi TechLord, great to hear it makes sense to others too

          Because of the language constraints and performance limitations of Blueprint and the limited need for complexity, I have chosen to use a simpler to parse c-like syntax without keywords and 1 to 2 character operator support ('if-else-else if' are possible through ternary operators ( ?: ) or functions). So operators like "(, ), =, ?:, >=, ==, &&, ||, +=, +, etc..." will be used.

          Data types are contextual, and are stored as strings in the virtual machine. Doing something like 1 + "string text" will result in converting the 1 into a string and concatenating it.

          That's the gist of it anyway. Being in blueprint only removes the power of regular expressions, binary tree dictionaries/maps, and existing libraries, so I have found it very constricting when trying to move too far into more complex syntax.

          Comment


            #6
            Originally posted by Grogger View Post
            Hi TechLord, great to hear it makes sense to others too

            Because of the language constraints and performance limitations of Blueprint and the limited need for complexity, I have chosen to use a simpler to parse c-like syntax without keywords and 1 to 2 character operator support ('if-else-else if' are possible through ternary operators ( ?: ) or functions). So operators like "(, ), =, ?:, >=, ==, &&, ||, +=, +, etc..." will be used.

            Data types are contextual, and are stored as strings in the virtual machine. Doing something like 1 + "string text" will result in converting the 1 into a string and concatenating it.

            That's the gist of it anyway. Being in blueprint only removes the power of regular expressions, binary tree dictionaries/maps, and existing libraries, so I have found it very constricting when trying to move too far into more complex syntax.
            Agreed. Blueprints does have limitations, but, for a simple super high-level scripting language it can get the job done. Mark Sibly's BASIC Compiler Code was my intro to writing compilers. I translated Mark's Code into a BP Tokenizer to parse for statements, operators, constants, and identifiers into bytecode. Curious as to how you are handling functions calls? Example: Sum(x,y).
            GOD of DREAMs: A Unique FTPS/RPG Sandbox MMO

            Comment


              #7
              Originally posted by TechLord View Post
              Agreed. Blueprints does have limitations, but, for a simple super high-level scripting language it can get the job done. Mark Sibly's BASIC Compiler Code was my intro to writing compilers. I translated Mark's Code into a BP Tokenizer to parse for statements, operators, constants, and identifiers into bytecode. Curious as to how you are handling functions calls? Example: Sum(x,y).
              Thanks for the links, it's very handy to see other implementations!
              I am currently using a variation on the simpler Shunting Yard algorithm to support ternary operators and function tokens in the form of FunctionName(arg1,arg2,arg3, ...argn)

              It doesn't support function declarations and definitions (at least not at this time), but instead the custom function call and it's arguments are passed to an optional custom handler that can process the event.
              Does your implementation support function declarations/definitions? I have been thinking about adding this, but I don't really have a need for it, so it is difficult to justify.

              Comment


                #8
                Wow. This is the first I've heard of Shunting Yard Algorithm and invented by the famous Djikstra at that. The VM I'm blueprinting is a Stack Machine using bytecode that mimics assembly instructions: MOV, PUSH, POP, ADD, MUL, DIV, SUB, LBL, JMP, XOR, OR, AND, NOT, GT, LT, GE, LE, EQ NE, CALL. The Tokenizer recursively parses statements expressions, terms, facts, leafs, to process nested code. Perhaps I'll implement the Shunting Yard Algo to deal with math this go around.

                The implementation can handle function declaration. This is not a requirement, however, executing UE4 Blueprint Functions/console commands are considered mandatory, and I'm using a custom handler (essentially a glorified switch...case). I store the identifiers for these functions in a function table which are compared by the parser to generate PUSH instructions for Arguments and a CALL Instruction followed by Function Index. For the VM when it encounters a CALL Instruction it calls the handler, Arguments pushed on the stack are popped off and assigned in the function call within the handler.

                I aim to keep it BASIC with the most complex feature being a 2 dimensional array.
                GOD of DREAMs: A Unique FTPS/RPG Sandbox MMO

                Comment

                Working...
                X