// find the scripts currently registered for this agent to be run. public void updateSensors(GenericVillager agent) { // get the iterator for this agents scripts Iterator<Script> itr = agent.getSensorScripts().iterator(); bindProxy(agent); while (itr.hasNext()) { Script currentScript = (Script) itr.next(); ArrayList<String> functionsToCall = new ArrayList<String>(); if (currentScript.status == Script.NEW) { functionsToCall.add("onStartSensor"); currentScript.status = Script.RUNNING; } if (currentScript.status == Script.STOPPING) { functionsToCall.add("onStopSensor"); } if (currentScript.status == Script.RUNNING) { functionsToCall.add("onUpdateSensor"); } String[] functions = new String[0]; functions = functionsToCall.toArray(functions); try { // debug: this.scriptprocessor.runScript( cache.getScriptByScriptName(currentScript.getScriptLocation()), functions); } catch (NoSuchMethodException e) { System.err.println( "error while executing an script, identifier:" + currentScript.getScriptLocation()); e.printStackTrace(); } catch (ScriptException e) { System.err.println( "error while executing an script, identifier:" + currentScript.getScriptLocation()); e.printStackTrace(); } } }