   How to integrate scripting language into a game engine?
  Hi,I have my own simple scripting language and I'd like to integrate it into my engine. But I'm not sure how to do it exactly. I have a compiler and virtual machine, and I can feed them some source code, and run my program. But how do I integrate that into the engine? How are scripts run within a game? Is there one script per sprite? If I wanted to change my sprite's position using a script, how can I make sure that when my "position" variable in the script is updated, it also updates the sprite's "m_position" member variable in C++ ?Any help is appreciated!   
  First let me suggest that you use python or lua instead of your own scripting language. they have ready made interfaces to integrate with other languages. these interfaces are well documented.if you are still interested in developing your own language, i still suggest that you check out these two languages' SDKs and mimic their design.   ;  That's cool that you managed to get your own language up and running.if you look at my lua category of posts you'll find a video presentation i did a while back, which talks about how lua interacts with C++.I also talk about how my engine uses lua scripts.This can be applied to any scripting language really.http://deadbeefgames.com/blog/?p=26there is the direct link. Although it is very cool you have your own scripting language, usually one that is used with a game engine stems from the game engines own need for a specific feature in the scripting language. I sense that this may not be the case with yours, and if this is true, you may want to move to something tried and true like lua.-JEDIT: my architecture has since changed from that video, and i am using the template class more liberally to send data to lua (not just the EngineManager class, but event data classes, and possibly an interface for animators)   ;  Thanks for the replies!I'm working on a 2d tile game engine and last night I dug up an old language interpreter I did a while back... thought it would be cool to integrate it into the engine... I'll definitely look into Lua and Python to do "real" scripting... right now maybe I could get away with an array of string/int pairs and Set(varname, value)/Get(varname) functions for my needs, but I thought it would be cool to learn how to integrate my VM into a game engine.Thanks again!;  I'm also in the same own language/VM/own engine position - it's fun! It might be worth taking a look at UnrealScript and the Quake 3 in addition to Lua/Python. Quake 3's source was released, so you can see how everything was implemented.;Quote:Original post by gsamourHi,I have my own simple scripting language and I'd like to integrate it into my engine. But I'm not sure how to do it exactly. I have a compiler and virtual machine, and I can feed them some source code, and run my program. But how do I integrate that into the engine? How are scripts run within a game? Is there one script per sprite? If I wanted to change my sprite's position using a script, how can I make sure that when my "position" variable in the script is updated, it also updates the sprite's "m_position" member variable in C++ ?Any help is appreciated!Usually you have to write 'glue code' into the script language that interfaces to the game engine and is usually  customized more specificly for the features your game uses (a subset).    Many script language have a mechanism where the 'script' language (run itself as an interpretor or bytecode...) has user created subroutines/functions that the then execute  using the engine's program interface language (often C/C++)This often requires complications of converting the parameters from script data form to the engine's data format (and vice versa).There is usually a way to build a call frame on one side that will be executed by code on the other side. Often you can do it either way (ie-  python can call C routines and C code can invoke python routines  thru a library interface)Data is often replicated/cahed on the script side so that you dont have to convert it constantly (extra layers of processing add overhead). Portions of the 'scripting' data related to AI (working data) is often independant and unneeded for the engine but other info like 'sensor' related (positions and identities) does need to move across.  Similarly much data on the engine side is un-needed by the scripts.A symbolic World Representation' would exist on the script side and be subject to the decision logic (and often the game mechanics are determined on the script side also).