Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


How do i implement a script engine ! aghh

This topic is 6190 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I currently use a self made database to store stuff like items .. ie image id and stats etc. What I would really like is a script engine so i can do something like OnEquip if player.class = mage then return true else player.hp = player.hp - 10 message "you feel a slight pain and drop the weapon" endif end can anyone point me in a direction ?? im guessing i will need to make a compiler which converts the script to a form of binary byte code (to save on space and speed of interpreting) and then the interpretor Thanks for any advice on this :-) -Tim

Share this post

Link to post
Share on other sites

Basically what you are trying to do is create your own restricted natural language. There are heaps of books on this topic and stacks of web sites (google search on ''restricted natural language'' works wonders).

There are many different ways to do it, you can write your own compiler that translates the script into something else. You can use someone elses script and compiler that they have already written or you can set up the scripts as resources that you define macros for so you turn the bare script into proper executable code... of course, unless it''s in an external library, you will have to recompile your entire app if you change a script.... that is a quick way to have scripting though.

-- And that''s my $0.02 worth --

Hang on, where I come from, $0.02 is rounded down. Does that mean my opinion is worthless or priceless?


Share this post

Link to post
Share on other sites
Consider using an existing scripting language.

Unless you have some very special purpose needs or you want to create a scripting language for the experience more than for its utility, you are better off making use of work already done by scripting language experts from around the world.

Some popular scripting languages that are easy to embed in your own apps and have good runtime speed include:







There are many others, both big (like Python or even Java) and small. Do a web search for other alternatives!

Share this post

Link to post
Share on other sites
Thanks all...

I have had an idea...

I was working on a compiler for my language and was thinking back when i made a assembler for my a level project .. and i suddenly though..

Why make a script which makes byte code which is interpreted by a VM.. why not make machine code ?

Im not sure how you could dynamically load code into an executable piece of memory though ? anyone know if you can ? the benefit from this of cource would be V fast code ;-)



Share this post

Link to post
Share on other sites
You just walked in a circle and reinvented the DLL (or .so, if you''re a UNIX programmer).

Loading DLLs into memory and executing them is very easy.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!