I'd like some help about spliting javascript in different files, in order to avoid placing in my main JS file a lot of data (mainly text for tooltips, so I need to be able to use BGA's _() in this data file to mark the tooltip strings to translate). I know I could use material.inc.php and transfer it with getAllDatas(), but this data is only needed client-side, and since there's a bit of code (not much) required to construct this data (some of the strings are duplicated for different elements), I'd rather avoid placing it in material.inc.php since this file is executed each time an action is triggered. I believe it would be best to have this data client-side only, but feel free to say if you disagree. material.inc.php is still an option for me if I don't find how to do otherwise properly.
There's an example of how to use several JS files in the doc, in the BGA Studio Cookbook.
Code: Select all
define([ "dojo", "dojo/_base/declare", "ebg/core/gamegui", "ebg/counter",
// load my own module!!!
g_gamethemeurl + "modules/ggg_other.js" ], function(dojo,
declare) {
If I only declare variables in this file without declaring a class / module, I have access to these variables in my main JS file, but if I try to use _() I have a JS error ("_() undefined" in the console) and the game interface won't load.
Can anyone explain me a clean way to have a separate file for data that can use BGA's methods?