Skip to content

Commit

Permalink
Put injected objects into script entries created by IF. This allows t…
Browse files Browse the repository at this point in the history
…hings like <context.args> to be read inside IF statements (Good find, Morphan1)
  • Loading branch information
aufdemrand committed Jul 2, 2013
1 parent ebb33be commit 8f230c8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main/java/net/aufdemrand/denizen/scripts/ScriptEntry.java
Expand Up @@ -191,5 +191,15 @@ public ScriptEntry setScript(String scriptName) {
public void setSendingQueue(ScriptQueue scriptQueue) {
queue = scriptQueue;
}


// Keep track of objects which were added by mass
// so that IF can inject them into new entries.
// This is ugly, but it will keep from breaking
// previous versions of Denizen.
public List<String> tracked_objects = new ArrayList<String>();
public ScriptEntry trackObject(String key) {
tracked_objects.add(key.toUpperCase());
return this;
}

}
Expand Up @@ -285,6 +285,10 @@ private void doCommand(ScriptEntry scriptEntry, String mapName) {
.setNPC(scriptEntry.getNPC()).setInstant(true)
.addObject("reqId", scriptEntry.getObject("reqId"));

// Put tracked objects into new script entries.
for (String tracked_object : scriptEntry.tracked_objects)
entry.addObject(tracked_object, scriptEntry.getObject(tracked_object));

entries.add(entry);

} catch (ScriptEntryCreationException e) {
Expand Down

0 comments on commit 8f230c8

Please sign in to comment.