trystyncote / scripted-video

This is a project that attempts to produce an animation-looking video based on a given script.
MIT License
0 stars 0 forks source link

Implement "functions" (or like feature). #16

Closed trystyncote closed 1 year ago

trystyncote commented 1 year ago

While this isn't guaranteed, I think this feature would be essential for practical use of this program. It's the use of functions that allow repetitive calls to a function.

I'm going to explain the use with an example. Let's say I want to create a character sprite that can dynamically change. In this example, I would create each sprite and set the opacity to 100% transparency and change it instantly when I change the sprite. If I created a function that acts as a wrapper for changing the sprite, then I could simply call it to change the sprite without making several MOVE OBJECT calls.

The syntax I'm thinking right now looks like this:

DEFINE FUNCTION functionname($parameter) {
    SET parameter = content AS type;
    // contents
}

I think that the parameters should be declared either immediately in the function, or maybe I should change variable declaration, since I think that multiple SET commands would be difficult to read.

CALL functionname($parameter);

See #15.

trystyncote commented 1 year ago

Another note that is along the lines of #15, and it is if I force a specific declaration of a variables, I think I should have a different declaration for parameter variables. This is because I think I will store function parameters separately to prevent intermingling, and I think allowing separate syntax would be for optimization. Let's say it would be $$var. I think I would still allow declaring it as a basic variable $var, but it would be easier for the program if you declare it as a parameter variable.

trystyncote commented 1 year ago

I've decided to add this feature, because it's basically required to use this kind of feature to use this program practically. I was initially thinking of using Python, but I think it would be more wise to define my own syntax for this. Because of this, I added the file svDemo2_LIBRARY.txt to the second demo script, which defines a function that is called.

trystyncote commented 1 year ago

Closed in response to #26.