Can't test this script, but will it work? -- Macros

Started by monkey0506, Sat 07/05/2005 18:18:55

Previous topic - Next topic

monkey0506

I can't test this script ATM, but I was wondering if it at least looks like it would work right:

Code: ags
function dSetText(char option, string text) {
  #ifdef dialog
    StrCopy(dlg[dialog].opt[option].text, text);
  #endif
  }

function dText() { /* store dialog text -- use this to replace Dialogs tab in Game Editor */
  /**** DIALOG 0 ****/
  #define dialog 0
  dSetText(0, "My name's Guybrush Threepwood.  Prepare to die!");
  dSetText(1, "How did you get up there?");
  dSetText(2, "I'll just be running along now.");
  #undef dialog
  /**** DIALOG 1 ****/
  #define dialog 1
  dSetText(0, "This is the first option of dialog two.");
  dSetText(1, "It's not that fantastic, but it's just for testing.");
  dSetText(2, "I need to make six more after this.");
  dSetText(3, "One down, five more to go for this dialog.");
  dSetText(4, "Funny the way I gave up on trying to build a dialog tree.");
  dSetText(5, "A few more to go now...");
  dSetText(6, "This is making me tired.");
  dSetText(7, "This is the last one thank goodness.");
  dSetText(8, "Here's another just for good measure...");
  #undef dialog
  /**** DIALOG 2 ****/
  #define dialog 2
  dSetText(0, "This is going to try and push the limits of long text display by forcing this string to be cut in half.");
  dSetText(1, "It's just to try and prove that the system is working correctly.  I have no confidence in it at all...");
  #undef dialog
  }


I was trying to find a way to make it easier to setup the dialog text than several:

Code: ags
StrCopy(dlg[0].opt[0].text, "text");
StrCopy(dlg[0].opt[1].text, "more text");
/* ... */
StrCopy(dlg[15].opt[24].text, "other text");


I think you can see how this would become tedious having to redefine the dialog you were working with every time you needed it, so does this look like (and/or) (will/it) (it/will) work?

Pumaman

No, that won't work. #defines are preprocessed before the script is compiled, so the line of code will never be run.

As an alternative, you could pass the dialog number as an extra parameter to the function, or declare a global int variable to store the current dialog number.


SMF spam blocked by CleanTalk