You have to use brackets for your dependency list when you call require
, like this:
//load NPC dialog given the map
loadNpcDialog : function (dialogNumber) {
require(["npc_dialog_level_" + dialogNumber + ".js"], function(dialog) {
// log(dialog);
});
},
If you don't use brackets, then you're using the pseudo-synchronous form of require
, which would be used like this: var dialog = require("npc_dialog_level_" + dialogNumber + ".js")
. However, this pseudo-synchronous form would not work in your case.
If eventually you want to make these files into JSON files or XML you can use the text!
plugin to load them.