Thanks for the reply, sproingie.
I am using javascript, and my scripts aren’t that complex. I could be invoking it wrong, I’m pretty new to javax.script.
I followed this tutorial: http://java.sun.com/developer/technicalArticles/J2SE/Desktop/scripting/
and made a simple script class:
package util;
import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
//import javax.swing.JOptionPane;
import file.FileManager;
public class Script
{
ScriptEngineManager mgr;
ScriptEngine jsEngine;
Invocable invocableEngine;
String m_script;
public Script(String _strFile)
{
mgr = new ScriptEngineManager();
jsEngine = mgr.getEngineByName("JavaScript");
m_script = "";
invocableEngine = (Invocable)jsEngine;
m_script = FileManager.LoadFileToString(_strFile);
}
public void ExecuteFunction(String _strName, Object... args)
{
try
{
invocableEngine.invokeFunction(_strName,args);
}
catch(Exception e)
{
e.printStackTrace();
//JOptionPane.showMessageDialog(null, "Error: " + e.getMessage());
}
}
public void ExecuteScript()
{
try
{
jsEngine.eval(m_script);
}
catch (ScriptException ex)
{
ex.printStackTrace();
}
}
public void AddObject(String _strName, Object object)
{
jsEngine.put(_strName, object);
}
}
Every single player has a Script object (Is this bad? I have to load the same file 200 times which is not good, although I want the variables inside the script to be separate for each player)
Also I have ScriptEngineManagers for each script. Can I just have one? and one engine?
I could have a look at Groovy++. I don’t especially want to learn a whole new language, JS was nice.
Thanks again