   How To integrate scripts
  I'm playing about with lua script and have got a basic system up where the scripter can add objects to the levels, set their properties and implement callback functions for certain events they recieve. I just have a few questions about how best to use this in a game environment:- How do you normally separate the data from the functionallity in a script. For example if I had a door script which had functionallity for opening and closing a door then how could I create multiple instances of the door (i.e. position rotation etc.) without duplicating the functionality?And...- If each object has it's own script then how do I call a function of a script belonging to another object?   
Quote:Original post by staticVoid2- If each object has it's own script then how do I call a function of a script belonging to another object?Put all the Objects in a global table that the all the scripts can access and/or make them global functions.   ;  What i do for this is give each script object it's own lua state and load the script file onto each one.I have always had a hunch that might not be the best way to do it, but lua hasnt been a performance problem yet going that route so it's worked well enough for me (:   ;  Instead, just make a new thread for each script so there is multiple scripts that work under the "Main Script", that way you will be able to create global functions and objects.See: http://pgl.yoyo.org/luai/i/lua_newthread   