Script Engine (I think)
Let''s see, I''m making this game and I hoping to make a script engine (I think that is what I''m talking about) which reads scripts from the user and then uses them. I''ll elaborate. . .I want the user to be able to say that if a certain event takes place, then go ahead and do an action. Now, carrying out the action is very simple. As for the if part, I could use a bunch of switch case statements but that would be inefficient. I actually found a way to narrow down the code uses classes and arrays, but I still think it is a little too inefficient and I can''t do everything I want. For instance, I want the user to be able to say if this event took place AND that event took place AND this event results in this, then carry out the action. I guess what I''m looking for is a simple solution (I doubt there is one, but sometimes the hardest questions have a simple solution) or some kind of resource which goes over this. Hmmmm, that might have been a little confusing, so tell me if I didn''t make any sense.
Without knowing much more than what you say, I can suggest the following:
Firstly dont do the script checks all the time - perform them as little as possible (say once a second) as this will give more CPU time to the game and takes out unneeded parsing of scripts.
Secondly, you could half-compile the users scripts into bytes which you process.
regards,
GeniX
Firstly dont do the script checks all the time - perform them as little as possible (say once a second) as this will give more CPU time to the game and takes out unneeded parsing of scripts.
Secondly, you could half-compile the users scripts into bytes which you process.
regards,
GeniX
regards,GeniXwww.cryo-genix.net
Hi!
If you are going to implement your first scritping engine, then take a look at www.flipcode.com. They had a scripting engine tutorial series, covering everything from scanning, parsing, code generation and virtual machines. A nice intro, if you are new to this kind of stuff.
MK42
If you are going to implement your first scritping engine, then take a look at www.flipcode.com. They had a scripting engine tutorial series, covering everything from scanning, parsing, code generation and virtual machines. A nice intro, if you are new to this kind of stuff.
MK42
If you''re going to build a scripting language, check out Jack Crenshaw''s Let''s Build a Compiler! tutorials. I believe there are one or two chapters in there about boolean expressions (which is what you described in "if this event took place AND that...")
/. Muzzafarath
Mad House Software
/. Muzzafarath
Mad House Software
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
Before you go off half-cocked and write a scripting engine, I HIGHLY recommend checking out Lua. Lua is an excellent scripting language which is ideally suited for games (it''s fast, it''s lightweight, it compiles to bytecode, it''s portable as hell ;-)
The Lua homepage is Here.
I''m using it for a backend scripting language in my game, and it was the scripting language used for Baldur''s Gate.
-- Pryankster
(Check out my game, a work in progress: DigiBot)
The Lua homepage is Here.
I''m using it for a backend scripting language in my game, and it was the scripting language used for Baldur''s Gate.
-- Pryankster
(Check out my game, a work in progress: DigiBot)
-- Pryankster(Check out my game, a work in progress: DigiBot)
You should also check out the Small language.
It''s designed mainly for speed and doesn''t have lots of features, but it''s fine with me. It also comes with an assembly bytecode interpreter and a just-in-time assembly compiler.
Pretty nice, although I couldn''t get the assembly stuff to work with VC++. Still, the code works very well and is easy to use.
It''s designed mainly for speed and doesn''t have lots of features, but it''s fine with me. It also comes with an assembly bytecode interpreter and a just-in-time assembly compiler.
Pretty nice, although I couldn''t get the assembly stuff to work with VC++. Still, the code works very well and is easy to use.
Thanx for your advice on the different tutorials on writing a scripting language, I will check those places out. I don''t really want to use someone else''s scripting language since the whole point of this project is for me to LEARN how to write my OWN scripting engine (I apologize for not mentioning that in my first post). Thanks again for all your replies.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement