My dialogue no longer works because of \n's

Started by bx83, Sat 31/07/2021 03:19:29

Previous topic - Next topic

bx83

Hi, could anyone tell me why there's an error in this piece of dialogue?

Code: ags
// Dialog script file
@S  // Dialog startup entry point

  if (TigerRedMeatMentioned) {
option-on 6
  }
  
  if (KingRevealsFurstPrize) {
option-on 9
  }

  if (!ButcherIntroduced) {
    cJulius_spk("&1965 You are a fine, utterly huge, *huge* bison. Or bull. What are you?");
    
    cButcher.SayAtBubble(butcher_talk_x,butcher_talk_y,
    "&1 I am a gigantic bull of bison descent.");
    
    cJulius_spk("&1966 What do you call that then?");
    
    cButcher.SayAtBubble(butcher_talk_x,butcher_talk_y,
    "&2 A Cattalo. Or Beefalo. But that is racist.");
    
    cJulius_spk("&1967 Are there many of your kind on this mostly cow-centric - but not enough to exclude horses - island in the middle of nowhere and also you can talk and own a butcher shop? Why do I even ask? Why do I *even* ask?");
    
    cButcher.SayAtBubble(butcher_talk_x,butcher_talk_y,
    "&3 I am the only one of my kind here. \n
    My pappa left me. My mother was destroyed. \n
    I am ashamed...");
    
    //[Spanish guitar sound] 
    cButcher.SayAtBubble(butcher_talk_x,butcher_talk_y,
    "&4 But I am not alone.");
    cDummy.Say("&1");
    
    cJulius_spk("&1968 But you said you were the las--");
    
    cButcher.SayAtBubble(butcher_talk_x,butcher_talk_y,
    "&5 I have my beautiful wife, of course.");
    
    cJulius_spk("&1969 A cow?");
    
    cButcher.SayAtBubble(butcher_talk_x,butcher_talk_y,
    "&6 A duck.");
    
    ButcherIntroduced=true;
  }

return

@1
return

@2  <----ERROR: buffer exceeded: you probably have a missing closing bracket on a previous line
  cJulius_spk("&1970 So that's quite a bit of... a height difference.");
  cJulius_spk("&1991 How do you even... like... you know...");
...


Adding new lines seems to mess up the length of dialogue (it was exactly as you see it here 20min ago, except no \n's and all text was on the same line), somehow. I've tried everything - \n's bad. No idea what's going on or if anyone's tried to space their dialogue like this.

Crimson Wizard

#1
AGS script does not support wrapping text into multiple lines like that. The text must be ended with a closing double-quotes on the same line where it began.
It's ridiculous, but this is how things are at the moment.

The solution is to use String.Append or String.Format to create larger string from several ones, and then use that.

bx83

Ah well :|
I'll get round it.

BTW are there any plans to make dialogues independent text files? That way we could edit them outside the editor, and they'd presumably be capable of more informative error messages.

Crimson Wizard

#3
Quote from: bx83 on Sat 31/07/2021 06:14:40
BTW are there any plans to make dialogues independent text files?

Yes.

https://github.com/adventuregamestudio/ags/issues/1008

fernewelten

#4
The standard 'C' and 'C++' way of concatenating literal strings is to separate them by whitespace: Whenever the compiler encounters "This is" " a " "string " "in " "five parts." it converts this into one big literal string "This is a string in five parts." and then processes this big literal string.

Newlines are a kind of whitespace, so that allows you to put several strings  onto several lines:

(not implemented)
Code: ags

cButcher.SayAtBubble(butcher_talk_x,butcher_talk_y,
    "&3 I am the only one of my kind here. \n"
    "My pappa left me. My mother was destroyed. \n"
    "I am ashamed...");


I've toyed repeatedly with suggesting and implementing this in the new compiler, but haven't gotten around to get this started.

SMF spam blocked by CleanTalk