I'm working on a few projects, trying to figger out what order I want to do them (which ones will be useful to the other ones, that kind of thing). It's also helped that my computer is not working right... it means I have plenty of time to (GASP!) plan before I code. It's done wonders for my error/warning count!
Anyway, one of the projects I've been working on is IrrScript. It's a BASIC-like scripting language for Games which use Irrlicht. (I thought of calling it Yet Another BASIC Based Scripting Language Using Irrlicht, but calling the project YABBSLUI (Yab-slooey?) just didn't appeal! )
I want some comments on syntax and implementation. I know there are a few BASIC coders here, some Visual Basic coders, and a few people who have asked if there was a BASIC version of Irrlicht. I also know there are a few ports of Irrlicht to BASICs of many varieties. So there should be at least a FEW comments... I hope.
Anyway, forgive me if this is a little wierd... it's 11:00PM and I've been up way too long to be typing... but I'll forget if I don't

1) [IMPLEMENTATION] Virtual Machine or Interpreter?
I thought of making a "Irrlicht Virtual Machine" which I named "Luigi." "Luigi" code would have instructions for general programming (ADD, MUL, DIV, SHIFTR, etc), Irrlicht Stuff (ADDMESH, TRANSLATE, DELETENODE, etc), Sound (PLAYSOUND, PLAYDITTY, PAUSESOUND, UNLOADSOUND, etc), etc.
I would then write a IrrSkript->Luigi Compiler.
I would also write a runtime IrrSkript->Luigi Interpreter.
I could then write a VM using a "switch," or if I wanted to be really snazzy, a STL LIST of LuigiCommand objects which then have decendants? with overloaded Virtual DoInstruction commands.
It would be easier, I think, to simply write a IrrSkript interpreter which directly runs the IrrSkript commands. However, I've been told that this would be slower than the IrrSkript->Compiler->Luigi route because I would just call DoInstruction on everything in the command list (IS->Comp->Luigi), instead of having to parse the file otherwise (IS only).
Questions? Comments? Suggestions?
(I'd like to have "multitasking" with the scripts. Would this be easier by having all the "interpreters" simply pass operations after each line to a different script, or would it be more efficient by having each interpreter/source file put out a pool of command which the "Luigi" processor would perform multitasking? If that doesn't make sense, ask

2) [SYNTAX] To BASIC or not to BASIC?
I wanted to make the IrrScript syntax BASIC like, because "non-programmers" seem to like it better. But would that be combersome (sp?) for Current Irrlicht Programmers would would like to add the scripting ability to their applications?
I'm too tired to come up with a real example, so I'll just sketch out the syntax:
Each line looks something like this:
COMMAND PARAMETER_1, PARAMETER_2, PARAMETER_3....
If COMMAND is a built-in command, the parameters are pushed on a stack, and passed to the command handler.
If COMMAND is NOT a built-in command, it looks to see if "COMMAND" is SUBROUTINE. If so, PARAMETERS are pushed on a stack, and passed to the subroutine.
If COMMAND is NOT a built-in command or a subroutine, IrrSkript assumes it's a VARIABLE. It then checks to see if the next token is a "=". If so, it checks to see if COMMAND is in the symbol table. If not, it makes it a new variable, otherwise, it assigns the solution of the expression to the variable.
VARIABLES can either be (1) any "non-reserved" word, without a postfix symbol, which becomes an "anytype" variable (ala BASIC), or (2) any word with a postfix symbol.
Type 1 variables are more flexible, but it's type changes throughout operation, which means all that "what the heck type this is" stuff for the interpreter.
Type 2 variable can have these postfix symbols:
variable$ ($) = String
variable# (#) = u8
variable% (%) = u16
variable! (!) = u32
variable^ (^) = resourceHandle (meshes, sounds, bitmaps, etc).
Type 2 variables allow you to speed up interpretation (no type checking), and know what type is in there, and catch logic errors (attempting to put a number in a string, for example).
Did all that make sense? Do you think it'll work? Is it BASIC enough to be BASIC, or am I making it too complex? Should I use a C syntax, or maybe Pascal, ProLog, LISP?
Anyway, that's where I'm going. However IrrSkript works, it'll allow you to operate Irrlich stuff from a scripting language, while allowing the C++ code to modify said stuff.
I'm tired, but some of my best ideas have come from too much Mountain Dew at 2 AM, so I'm not sure.
Questions? Comments? Please???[/code]