Page 4 of 5

Re: Adventure Creator feature discussion thread

PostPosted: Fri, 16Mar11 03:35
by tlaero
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

Re: Adventure Creator feature discussion thread

PostPosted: Sat, 16Mar12 04:37
by tlaero
Hey Kexter (or other JavaScript Gurus).

Say I have the following:

Code: Select all
var stuff = {};
stuff["first"] = function ()
{
    // Do stuff
    var cur = "first";
};
stuff["second"] = function ()
{
    // Do other stuff
};


Note the var cur = "first";
That's intentionally the same string as stuff["first"]. Is there a way to get "first" without repeating the text? Something like "stuff.currentHash" or "stuff.currentKey" or something?

Thanks!
Tlaero

Re: Adventure Creator feature discussion thread

PostPosted: Sat, 16Mar12 14:11
by kexter
First of all, what is it for? What are you trying to do? Are you sure you're not overthinking it? I can only think of ugly, contorted ways to achieve it. Note that stuff["first"] is the same as as stuff.first, see:
Code: Select all
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 () {};

Re: Adventure Creator feature discussion thread

PostPosted: Sat, 16Mar12 16:52
by tlaero
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

Re: Adventure Creator feature discussion thread

PostPosted: Sat, 16Mar12 19:12
by kexter
As far as I see it, stuff["first"] doesn't have to know about stuff2["first"]. If you make GotoPage() "smarter" then it can set the localized strings as well when it jumps to a page. So it could do something like this:
Code: Select all
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 ...
}
This above idea is a stripped down version of how BEW will operate in a future release.

Re: Adventure Creator feature discussion thread

PostPosted: Sun, 16Mar13 03:54
by tlaero
I'm still trying to find the right balance between understandability and functionality. I really like the way you do the pages in BEW, but I don't like the strings as much. I like the idea of a developer being able to search the string file for the page name and see everything for that page there. That's why I'm leaning toward two objects with the same names. I'm still experimenting, though.

Question for you and Wolf, now that you've got everything in one or two files, why do you need the episode subdirectories? Do you find that people download episodes without updating the main file? It seems like it would be just as easy to download the entire file, since it's only going to be a megabyte or so.

Second question for you an Wolf, with everything in one file, how do you deal with two people working on the file at the same time? With individual htms one guy can update some htms while another is updating other ones. But if it's all in one file, you need to merge their changes together. That won't be a problem for me, since I'm the only person editing the English text in my games, but it seems like it would be a challenge for bigger teams.

Third question, have you found any number of "pages" where the size gets unwieldy and the game slows down? RfJ is roughly the same size as BEW, but no one else has ever used AC to make a game approaching that size. So you're doing the trailblazing for us. (-:

Tlaero

Re: Adventure Creator feature discussion thread

PostPosted: Sun, 16Mar13 11:51
by kexter
tlaero wrote:Now that you've got everything in one or two files, why do you need the episode subdirectories?
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:With everything in one file, how do you deal with two people working on the file at the same time?
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:Have you found any number of "pages" where the size gets unwieldy and the game slows down?
Not yet.

Re: Adventure Creator feature discussion thread

PostPosted: Tue, 16Mar29 22:00
by nale
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



Hey Tlearo,

i now looked in your single.htm up what your intention was: a way to not type it twice in your current code would be:
Code: Select all
pages["achieve1.htm"] = function (page)
{
    var pt = pts[page];
    SetTopText(pt.t);
};


The function LoadPage(page) would look than like this:
Code: Select all
function LoadPage(page)
{
    ClearPage();
    SaveCurrentPage(page);
    topInit();
    pages[page](page);
    bottomInit();
}


A quick check with your single.htm works well ;).

One could improve this in my opinion to remove the pts file completely from the _pages.js, then the changing of the language would be really easy ;).
Code: Select all
pages["achieve1.htm"] = function (pt)
{
    SetTopText(pt.t);
};

function LoadPage(page)
{
[..]
    pages[page](determinePagestext()[page]);
}


I didn't implement the function determinePagestext, which would return the correct pts-array from the _pagetext.js in the correct language but i think you get the idea.

Re: Adventure Creator feature discussion thread

PostPosted: Wed, 16Mar30 03:33
by tlaero
Thank you, Nale. Those are both great suggestions. I'll think about them.

Tlaero

Re: Adventure Creator feature discussion thread

PostPosted: Wed, 16Mar30 04:13
by tlaero
I didn't have to think very long. Your second suggestion is a wonderful one. I changed the one line in LoadPage to

pages[page](pts[page]);

And then the individual pages became:
Code: Select all
pages["achieve1b.htm"] = function (pt)
{
    SetTopText(pt.t);
    SetImage("../images/animb1.jpg");
    AddSay("say1_1", "#", "achieve2.htm", pt.s[0]);
};


Thus removing a line per page. I like it a lot!

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.

Tlaero

Re: Adventure Creator feature discussion thread

PostPosted: Wed, 16Mar30 04:25
by tlaero
I'm continuing down the "single htm" route, but I'm concerned about how much harder it is to understand for non-programmers. I think about the kinds of questions I've answered over the years and then think about how I'm going to explain why you can't LoadPage in a PreLoad but can in a PostLoad. 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.

So I've come to the conclusion that, no matter what, I'm going to have AC support both individual HTMs and the single one. That's why the new _functions.js is so schizophrenic.

I'm not sure yet whether to have separate tutorials for htms and single, or whether to continue to teach people about htms until people start asking how to do the single stuff. I'll continue to think about this.

Tlaero

Re: Adventure Creator feature discussion thread

PostPosted: Wed, 16Mar30 14:36
by Mortze
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.


Image
"Back then, Code was easy." - Hammurabi, contemplating C++

Re: Adventure Creator feature discussion thread

PostPosted: Wed, 16Mar30 21:10
by Greebo
Nice one, Mortze! :roi: [img]images/icones/icon7.gif[/img] Now lets see -- does Google Translate handle Mesopotamian - English? [img]kator/smiley130.gif[/img]

Re: Adventure Creator feature discussion thread

PostPosted: Thu, 16Mar31 11:10
by Ehlanna
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++


The C being short for Cunieform, I presume? ;)

Re: Adventure Creator feature discussion thread

PostPosted: Thu, 16Mar31 22:08
by nale
tlaero wrote:I didn't have to think very long. Your second suggestion is a wonderful one.

I'm honored to help you ;)

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.


Of course it is eligible choice to have language directories but i don't see the overall benefit, because in the end you always have to have one place where the language choice has to be done programmatically, either through jumping to different files via html as done in your translated game RfJ or through javascript functions. Also the CSS Files could be changed dynamically in dependence of the language. One smaller feature if you use javascript functions would be that it would be possible to implement a language change in every moment in the game, however i don't know how often such a feature would be used. In my Opinion it would also lead to slightly nicer looking directories.