NPC Code:
function compileScript() {
script = "";
script.add("function onCreated() {");
for (con: this.containers)
addControlCreationScript(script.link(),con,0);
script.add("}");
script.savelines("weapon.txt",0);
ScriptEditor.openScriptWindow(script);
}
Here an example of writing into a file (savelines), the new for-each operator, calling functions with parameters (addControlCreationScript), and calling public functions of other scripts/objects (ScriptEditor.openScriptWindow).
You can do similar things with addstring script,... instead of script.add, passing parameters by setting this. variables, and doing callnpc, but with the new script it's more simple (e.g. the functions of other objects can return values).