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

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:

Lua

http://www.tecgraf.puc-rio.br/lua/

TCL

http://www.scriptics.com/

Small

http://www.compuphase.com/small.htm

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