River Nyxx

A development blog for FFVI3D, the fan-made Final Fantasy VI remake in 3D.

平成20年3月1日土曜日

Script Manager down, who's next?

So, the 2nd iteration of my Script Manager is up and running now. Everything is working beautifully, it's fully recursive, which means I can have expressions with parentheses, and math in function parameters, etc.. It also looks a LOT like C++... the only really noticable difference is that I don't use curly braces ( "{" and "}" ) anywhere, and opted to instead go for a "if/endif" and "while/endwhile" route instead. Other than that, it looks quite a lot like C++, function definitions, etc.. Well, I guess more appropriately, it would be closer to C, since my scripting language doesn't support objects, but whatever.

So this is the final test script I was running to make sure everything was working fine (and it is!), just so you can have a taste of what the language is capable of. Take note, that this doesn't actually make any calls to functions in the game itself, but they are fully supported (I was testing those in a different script file...)

number testFunction5(number x, number y);
number i;
i = 2 * (2 * ((1 + 1)) + 2) / 3;
print("*****FINAL RESULT*****");
print(i);
number r;
r = 5 * x * y;
r = r + 50;
r = r - 23;
r = r / 10;
string tst = "part1:";
tst = tst + "part2";
print(tst);
return(r);

void testFunction2(number num);
print(num);
num = 45;
print(num);
return;

string testFunction(string str1, number numbah);
print("Output- displays nothing since it is only useful mid-operation");
output;
number num = numbah;
print(str1);
print(32);
print(num);
print("constant text called explicitly");
expose;
return("text returned from function to main");

void testFunction3();
print("Test function 3");
return;

number testFunction4();
return(1337);

entry;
number n1;
boolean boo = false;
string s;
print("Before loop scopes:");
expose;
print("Inside loop scopes:");
while (n1 == -1 && !boo);
print(s);
s = s + "a";
if (s == "_aaa");
boo = true;
endif;
expose;
endwhile;
print("After loop scopes:");
expose;
while (n1 < 20);
print(n1);
n1 = n1 + 1;
endwhile;
while (n1 <= 40);
print(n1);
n1 = n1 + 1;
if (n1 >= 34);
break;
endif;
endwhile;
string str1 = "yay!";
string str2;
number num1;
print("Before ifelse scopes:");
expose;
if (str1 == "yay!" && str2 != "" || num1 == 0);
print("Inside ifelse scopes:");
expose;
print("Before if scopes:");
expose;
if (str2 == "_");
print("Inside if scopes:");
expose;
print("true");
endif;
print("After if scopes:");
expose;
else;
print("false");
endif;
print("After ifelse scopes:");
expose;
number num2 = 100;
str2 = "text";
num1 = 50;
string str = testFunction("text passed to function and thus is stored in variable", 42);
testFunction2(3);
testFunction3();
number ret = testFunction4();
print(ret);
print(str);
number n = testFunction5(num1, 23);
print(n);
boolean b = true;
number nr = 1.5;
print(nr);
expose;
end;
Of course, all of the variable names, constant values, etc.. are all random and make no sense whatsoever, as they were only being put in to test specific constructs in the scripting language itself. As far as the scripting language itself goes, there's only 3 things I'm currently considering still putting into it: do/while loops (which we can do without, as we have a basic while loop...), and for loops (which we can also do without, but it would be less scripting for a simple type of loop, if it was implemented), and lastly, a means to have the script wait for something in-game to occur, and trigger the script back into action again to finish off. The main thing I'll need this for is to implement in-game cutscenes, so I can have a script (for example...) tell a character to walk north 10 meters, at which point the script will wait until the character arrives at that point, at which time the script could continue to tell that character to say something, or some such.

Now I'm quite firmly involved in finishing off all the little notes I left for myself in my code months ago. With all those little things done, I'll be working on the battle state.

ラベル: , , , , , ,

0 件のコメント:

コメントを投稿

登録 コメントの投稿 [Atom]

<< ホーム