Temple of The Roguelike Forums
Development => Programming => Topic started by: RoguelikeGCS on June 11, 2010, 11:58:10 AM
-
Eventually I'm going to start writing the scripting language for my RL. The dilemma I'm faced with is whether to commission someone to develop a proper VM to execute low level byte code generated by my parser/compiler, or to develop a perl style interpreter myself.
The main issue seems to be with speed and efficiency; it's hardly rocket science to write an interpreter to execute through a data structure created by a parser. but even with optimisations, I can't imagine this approach producing a very fast scripting language.
The VM would be a complex engineering feat - something I would not likely be able to achieve myself (but it would offer irresistible performance).
-
Why not use an already available scripting language like Lua?
-
Because he can write a scripting language !
-
I like this metaphor:
http://en.wikipedia.org/wiki/Standing_on_the_shoulders_of_giants
It works for software development, too. I picture the giants as libraries, algorithms and knowledge that former software developers and engineers created, and we can use these to lift us up, and empower us.
-
Its a REALLY bad idea to write your own if you lack the knowledge and experience. there have been a few threads on this here before. There are lots embeddedable scripting langs around, choose one.
-
Its a REALLY bad idea to write your own if you lack the knowledge and experience. there have been a few threads on this here before. There are lots embeddedable scripting langs around, choose one.
Well...there are two paths here.
Dream big! [and maybe fail]
Or do as Stu says....
I once had a track coach that told me the exact opposite of what they tell you in High School. He told me to NOT reach for the stars. He told me to do what I could do. Find success. Success breeds success and you'll live a happy life. If you do something that you are not that great at. If you reach too far. If you swim against the steam instead of going with the flow, you will find barrier after barrier and failure. If you set yourself up to fail you will not be happy.
Maybe too deep...I use gamemaker [hangs head in shame.]
-
Maybe too deep...I use gamemaker [hangs head in shame.]
Uh? Don't listen to those who say using tools is bad. There are quite good games made with Gamemaker, and Gamemaker users seem to produce games quickly. One can argue if there are better tools, but seeing what people do with Gamemaker I think it is a pretty sound choice for game creation - at least for a certain type of games.
Most tools are specialized in a way, and I wouldn't call a tool bad, just because it only performs well for certain tasks and not so good for others. If you want to do something, and the tool helps you, it's good.
-
Heck yeah Hojo. Tools are good. I mean, I can USE Pascal and C++ to a level good enough to write a roguelike, but man I don't have the time anymore. I'm an attorney with no aspirations of being a programmer. So Gamemaker and GML are my creative outlet.
It should be noted that Spelunky was written in Gamemaker.
-
Why not use an already available scripting language like Lua?
For the sake of clarity, let me tell you that this scripting language is not for my own use during development of the RL engine, but for use by clients of the GCS. Therefore LUA will need to support adding callable functions in the following manner:
Let say for example, that the client wants to get a reference to an inventory so he can iterate through the items there; he would need some code like the following:
begin()
{
rInv = GetInventory(GetAutoPassedVars(0));
for (i = GetFirstItem(rInv); i; i = GetNextItem(rInv))
{
a = GetItemProp(i, 0);
DestroyItem(rInv, i);
}
}
the begin() function would be specified by the client, and called in the respective creature once upon entering an area, or starting the game.
Having looked at the LUA website, i must say, not only does it look highly complex with very strange python esque code, but it seems that getting it work for my needs (providing it can even do what i want it to) would be too much hassle. I think I'll roll my own. Good luck convincing me otherwise :)
-
Good luck convincing me otherwise :)
I won't. I like to do things my ways too, so I can understand you and your decisions very well. Sometimes, after a while, one finds out that the advice was good, sometimes one finds that ones own idea was better. Only time can tell.
Have fun whipping up your own scripting language, and tell us how it goes and how people like it :)
-
Having looked at the LUA website, i must say, not only does it look highly complex with very strange python esque code, but it seems that getting it work for my needs (providing it can even do what i want it to) would be too much hassle. I think I'll roll my own. Good luck convincing me otherwise :)
Hey its your game so its up to you, honestly everything you have said about lua in the above paragraph is totally wrong.
I'd code your example like;
function Begin()
local rInv
local key, value
rInv = GetInventory()
for key,item in pairs(rInv) do
if item.MyPropertyFlamingSwordVsTrolls == true do
FlamingTrollSnot()
end
DestroyItem(key)
end
end
I'd be interested in seeing the specifics of your scripting language + vm, its design and implementation (I'm a hobby language/compiler/vm junkie).
-
Just a couple cents here:
Lua does do everything you need--I can say this confidently without even knowing the bullet-points of what you need, because I'd bet everything I own that it's not something somebody else has already made Lua do--and it is far simpler than rolling your own. Lua is a well-understood, well-accepted language that is actually used in the real world with some large-scale adoption. It's used in areas from standalone applications to scripting for 3D engines (my colleagues on Sharplike wrote a slick 3D engine with Lua as the primary scripting system). I am not the biggest fan in the world of its syntax, but it is really, really good.
As for Lua itself, one of Sharplike's other devs (and one of the guys behind that 3D engine) had this to say: "Lua = VM. Fastest embeddable scripting language according to the computer language shootout. And lowest memory overhead. And easy to use. And rock solid."
If you don't want to use Lua, there are a ton of other options. You've got a Python interpreter in Boost::Python. You can self-host Mono and give users their choice of CLR language for scripting (and get a JIT compiler and runtime out of the deal--I don't know anyone who can write a VM/compiler for a roguelike engine that will come anywhere close to the perf that you'd get out of Mono--and Lua/Python are faster than that, albeit less featureful). There are good options for pretty much any use case out there. (Sharplike's code runs on .NET, so we get IronPython and IronRuby for free. Gotta love it!)
No disrespect intended, but it has almost certainly been done and done better, and you have all that code out there you can leverage. There are only a very few people in the world with the computer science background and the technical proficiency to develop a sane, effective programming language with a well-performing runtime. I am reasonably sure that none of them, myself very much included, are making roguelikes. Rolling your own off-the-cuff in a project you want other people to actually use is likely unwise. (Not that I'd really mind if you did--I like people doing things that make my own code look better. ;) Just some friendly advice, because I don't like seeing people shoot themselves in the foot.)
-
it look highly complex with very strange python esque code
I find it odd that you would:
1. Find lua to be similar to python.
2. Consider that a bad thing.
It seems to be a lot more ruby or (superficially) pascal inspired to me than python inspired.
It is at any rate a much smaller and simpler language than any of these.
-
[double post, ignore this message.]
-
What is the deal with scripting? I've never thought scripting a good solution to like anything.
-
I see two benefits:
- Scripts usually do not need to be compiled. Sometimes scripts can be re-loaded into a running game and changes can be tested from within this running game.
- If you want the core of your game closed source, but allow modification or expansions, scripts will allow users to do that without need to have access to the core sources.
The latter point may even be useful for open source projects as a hint for mod-makers, like "This is the part that is meant to be modified" and "This is the games core, do not touch unless you know what you do".
But that is definitely more geared towards commercial/professional games than roguelikes which are traditionally open source.
A further point might be that often the scripting interface is quite high level and game specific, so that scripts are an easier way to control or expand the game. But this much depends on how the interface is made, and how high level the core is - that might be equally high level and then scripts do not have such a benefit.
-
A further point might be that often the scripting interface is quite high level and game specific, so that scripts are an easier way to control or expand the game. But this much depends on how the interface is made, and how high level the core is - that might be equally high level and then scripts do not have such a benefit.
Yep. If you are making a game in c scripting makes a lot more sense, as you can program the game-logic much more easily in something like python than in c.