Main Page » My Games » Villainmad »

2011/03/09 (Villainmad): See exclusively sharp

Created: / Modified:

Always use secure-HTTP / Unsecure HTTP / Permanent Link

So, it's been great, Lua, and I've gotten the basics down because of you. But I just might be about to start over from sniff again.

See, I've been looking around Google for "a better scripting-solution than Lua," and the word on the street is that C# is itself a perfectly cromulent scripting language. One of the biggest reasons for this is that the system doesn't have to translate between multiple languages every frame, which slows things down when you're in a hurry and sometimes causes things to get lost in translation.

Sequences (as I'm still calling them) are a bit more complicated than they were before; there's no really good analogue to Thunkify, so instead, you use a delegate, like so:

QueueCommand(6, delegate() {
	AddObject(<details>);
});

It is fairly obvious that you aren't limited to enqueuing just one thing, either; you could put a whole, well, sequence!1 (Don't try to do this recursively; it doesn't look nice.)

And what of security? We don't want someone using Villainmad to hax your compy.2 Well, uh, to be honest, I'm still working on that; I have a number of options, with varying degrees of hackishness and compatibility-with-Visual-Studio.3 For starters, though, the "base" for the levels and games will technically be in an external .DLL library, and stage-scripts will only have access to this and some basic XNA functionality. And the entire System namespace, which has all kinds of abusability. Ah well, I don't expect this to be an insurmountable challenge by any means!

If I go with this, it isn't a roadblock, it's just a speed bump.

1Technically, you could do it in Lua, too, with something like QueueCommand(6, function <stuff> end), but that way isn't an intrinsic part of setting it up.

2Technically, Lua has this issue, too.

3High-compatibility: load the scriptfile as a string first, and parse through it for bits I don't like, i.e. System.IO, and throw an error. Low-compatibility (and also doesn't actually work as a security measure since using "using" isn't actually mandatory to get at certain things): the "using" tokens aren't actually included in the script file, and get added to the beginning at runcompile-time.

7 Comments (auto-closed) (rss feed)

sRc

and stage-scripts will only be accessible in XNA and

and..? and.. what? ... AND WHAT?!? you have me on the edge of my seat here!

Dizzy H. Slightly Voided

God dammit, it lost the edits I'd made while the site was briefly down.

Toawa

Hey, you could always do what I do; create yet another domain specific scripting language all of your own... (Although that might just be because I enjoyed compiler design too much.)

sRc

heh, I've done that too, but not for something that needs to be as real-time as this

MWchase

I wonder if it would be feasible to do the engine in C#, and have the scripting work by telling C# how to assemble game objects from Lua. I mean, like, run some Lua scripts, and it defines functions/templates/something to create specific stages, enemies, sequences, whatever. Then, nothing but C# runs. I get the impression that this is a more normal way of doing things than what I'm doing. (Or... planning to do. DAMN YOU SCHOOLWORK)

Toawa

Well, .NET 4 added a lot of support for dynamically compiled code; Expression trees are now capable of representing block statements (if, while, for, foreach, etc) without having to resort to external helper functions and continuations. Although the documentation is a bit lacking for it...