Thank you Kexter! When I thought about what you were asking, I realized I was going about it in much too complicated a way. I've just changed it to support that, and the code is simpler as a result.
Tlaero
var stuff = {};
stuff["first"] = function ()
{
// Do stuff
var cur = "first";
};
stuff["second"] = function ()
{
// Do other stuff
};
var stuff = {}; // I assume stuff is global.
// The following are all the same:
stuff["first"] = function () {};
stuff.first = function() {};
window.stuff.first = function () {};
window["stuff"].first = function () {};
window["stuff"]["first"] = function () {};
var stuff = {};
stuff["first"] = function ()
{
// Do stuff
var s2 = stuff2["first"];
var str = s2.t;
};
stuff["second"] = function ()
{
// Do other stuff
};
var stuff2 = {};
stuff2["first"] =
{
t: "string1"
};
stuff2["second"] =
{
t: "string2"
};
function GotoPage(page) {
// Assuming there's a global object (currentStrings) that stores the strings for the current page,
// fill it with the relevant data for `page´.
currentStrings = locales[currentLocale][page];
// Do the page transition.
pages[page]();
// Where the pages[page] function has calls to, say:
// setTopText();
// addHotspot(...);
// addResponse(...);
// and all of the above get the string-data from currentStrings.
// For example setTopText() would look up currentStrings.topText,
// the Nth addHotspot() would look up currentStrings.hotspots[N], etc
}
// Note: you could also fill out `currentStrings´ a bit "smarter". First you would fill it with the English data,
// then update it with, say, translated French strings. This way if a string is missing from the translation then
// the English counterpart would still show up.
function fillOutStringData(page) {
var i,
original = locales["en"][page],
translated = locales[currentLocale][page];
currentStrings.topText = translated.topText || original.topText;
currentStrings.hotspots = [];
for (i = 0; i < original.hotspots.length; i++) {
currentStrings.hotspots[i] = translated.hotspots[i] || original.hotspots[i];
}
// ... same for responses, etc ...
}
Mostly so that the assets are a bit more organized. And we can quickly add and remove scenes to the test and/or release versions by simply copying a directory and regenerating the game-data files.tlaero wrote:Now that you've got everything in one or two files, why do you need the episode subdirectories?
Development is done with standard AC so we have all the html files as well. I made a custom build-script that generates the game-data files every time a page is saved in AC. So the single data files you see are actually auto-generated, we never touch them. Also, we use source control so all the files are versioned.tlaero wrote:With everything in one file, how do you deal with two people working on the file at the same time?
Not yet.tlaero wrote:Have you found any number of "pages" where the size gets unwieldy and the game slows down?
tlaero wrote:I'm playing around with the various ways to move AC from individual htms to a single file. I'm trying a bunch of things to decide which I like the best. In this version, I have two objects, one for pages and one for strings.
- Code: Select all
var stuff = {};
stuff["first"] = function ()
{
// Do stuff
var s2 = stuff2["first"];
var str = s2.t;
};
stuff["second"] = function ()
{
// Do other stuff
};
var stuff2 = {};
stuff2["first"] =
{
t: "string1"
};
stuff2["second"] =
{
t: "string2"
};
It's not the end of the world to have to repeat the "first" once (especially since AC would write it anyway), but if there was an easy way to get it, I'd use that instead. I didn't think there was an easy way to get it though, and you've confirmed that I wasn't missing something obvious. So I'll continue on this path.
Thanks!
Tlaero
pages["achieve1.htm"] = function (page)
{
var pt = pts[page];
SetTopText(pt.t);
};
function LoadPage(page)
{
ClearPage();
SaveCurrentPage(page);
topInit();
pages[page](page);
bottomInit();
}
pages["achieve1.htm"] = function (pt)
{
SetTopText(pt.t);
};
function LoadPage(page)
{
[..]
pages[page](determinePagestext()[page]);
}
pages["achieve1b.htm"] = function (pt)
{
SetTopText(pt.t);
SetImage("../images/animb1.jpg");
AddSay("say1_1", "#", "achieve2.htm", pt.s[0]);
};
tlaero wrote:Yeah, I can step through in the debugger and figure out where I had an old "document.write" or, worse, a "window.location," but a lot of the people who use Adventure Creator are artists and writers, not programmers. And this stuff isn't even Greek to them, it's Mesopotamian.
Mortze wrote:tlaero wrote:Yeah, I can step through in the debugger and figure out where I had an old "document.write" or, worse, a "window.location," but a lot of the people who use Adventure Creator are artists and writers, not programmers. And this stuff isn't even Greek to them, it's Mesopotamian.
"Back then, Code was easy." - Hammurabi, contemplating C++
tlaero wrote:I didn't have to think very long. Your second suggestion is a wonderful one.
tlaero wrote:Regarding loading the language files, I'm not a fan of how the collective wisdom suggests to programmatically load js files, so I'm sticking with individual language directories. I also want the ability to change css and sizes for different languages if I need to. So I'm heading toward a place where the files in "English" are duplicated in a "French" and "Italian" directory, etc. It's not ideal, since single.htm gets repeated, but not terrible either.
Return to The workshop of creators
Users browsing this forum: No registered users and 2 guests