Implementing character busts during dialogue

Started by SmugMonster, Sat 14/04/2018 00:22:40

Previous topic - Next topic

SmugMonster

#20
The display message didn't work either, which makes me think I messed something up in connecting them. They are connected, though - on the character's events panel, any click has that function associated with it.

I assigned the same view to all the different view types, just in case, because at least so far in this stage, we aren't going to be using animated speech frames (that'll come later).

Edit: I just created an object and stuck it in the room with the same function assigned to it and it didn't work either. So I'm really thinking I just missed something in the configuration somewhere...

Crimson Wizard

#21
Oh, I think I know what this may be.
The default cursor mode in AGS is "Walk to" and Any Click event may not trigger for that.

Since you have a visual novel style of game, you probably may just lock the cursor in "Pointer" mode (generic mode for interacting with GUI), at least for now.

Find "game_start" function in GlobalScript and put this:
Code: ags

mouse.Mode = eModePointer;

Then find "on_mouse_click" and remove the part that switches mode on right click:
Code: ags

  else // right-click, so cycle cursor
  {   
    mouse.SelectNextMode();
  }


Do not forget to assign graphic to the pointer cursor then.

SmugMonster

Okay, that fixed the "not reacting to clicks" problem - which shed light on the next round of problems hahaha... :embarrassed:

One weird thing and one broken thing.

The broken thing: clicking the character gives me an error "AGS had a problem running your game" etc., with the error "GetGameParameter: invalid frame specified" at the following line:

Code: ags
void StartVN(this Dialog*, Character *left, Character *right)
{
    // set the buttons to have first frame of the character's speech view
    // ofcourse you may use different logic, for instance, get character's images from Custom Properties, or other variables
    ViewFrame *vf = Game.GetViewFrame(left.NormalView, 0, 0); //<----------- this line
    btnVNLeftPortrait.NormalGraphic = vf.Graphic;
    vf = Game.GetViewFrame(right.NormalView, 0, 0);
    btnVNRightPortrait.NormalGraphic = vf.Graphic;
    gVisualNovelScreen.Visible = true;
    // add anything else you need to setup
    this.Start();
}


And the weird thing... in both the character and the object, the following line works...but prints the text backwards:

Code: ags
Display("Sylvie click is working!");


I don't think that's meant to be backwards, is it? It's printing as "!gnikrow si kcilc eivlyS"

Crimson Wizard

#23
Quote from: SmugMonster on Mon 16/04/2018 01:25:22
The broken thing: clicking the character gives me an error "AGS had a problem running your game" etc., with the error "GetGameParameter: invalid frame specified" at the following line:

Code: ags

    ViewFrame *vf = Game.GetViewFrame(left.NormalView, 0, 0); //<----------- this line
}


In my example that was "SpeechView", in your code it is "NormalView". These are not same thing. Double check that you have assigned what you are actually using here in character properties. The view you are referencing must have at least 1 loop and 1 frame.


Quote from: SmugMonster on Mon 16/04/2018 01:25:22
And the weird thing... in both the character and the object, the following line works...but prints the text backwards:

Only reason I can think of is "Write text left-to-right" option in the General Settings ("Text output" category). This is for Hebrew and Arabic languages.

SmugMonster

Huh, yep, that was set to "True" for some reason. Hah.

Right, so, I've fixed it up now, changed around some views and whatnot so that the normal view is an empty frame (I don't want the main character to actually appear outside of dialogue scenes) but the speech view is the portrait image, aaaaand I changed the code back to speech view.

Now, when I click, it prints the Display text but doesn't do anything else. No errors now, though! It just doesn't actually seem to be running StartVN().

Crimson Wizard

The interesting thing is that there is another mistake that I missed, WaitMouseKey cannot be called with 0 for some reason (design mistake in AGS imho), so you need to wait for particular time like WaitMouseKey(100); or use the module Snarky linked above.

But this also means that your game never gets to call WaitMouseKey, or maybe even SayVN, otherwise you would seen the error message.

Not sure what to check here. For instance, are you certain that you are starting correct dialog?
What "Visibility" option your GUIs have?

SmugMonster

#26
Yeah, I only have the one dialogue, which is called dDialog1, and here's the code I'm using to start it:

Code: ags
function cSylvie_AnyClick()
{
  Display("Sylvie click is working!");
dDialog1.StartVN(player, cSylvie);
}


The GUI has "Normal, initially off".

Here's a weird thing, though. I just went in and added a display line to the dialogue:

Code: ags
// Dialog script file
@S  // Dialog startup entry point
 Display("Dialogue is working");
 cSylvie.SayVN("Hello, player.");
 player.SayVN("Hello, Sylvie.");
 EndVN();
stop


And that sort of worked. Clicking the character created a the "clicking this character is working" display, and clicking again then actually created the GUI as expected, with the right portraits! It also had the display string "Dialogue is working".

So I removed both Display lines, and then it didn't work again. So I put the one back in the dialog, and it worked again, this time (because the "clicking this character is working" display was still gone) it worked to show the GUI properly on one click.

Soooo it's initializing the dialog properly, but not actually displaying the GUI unless the Display message is in the dialog script.

Also, the actual strings for the name and text "hello player" etc. is not displaying on the labels. The portraits are working, though, so progress!!

EDIT: How do I get the actual GUI window to be invisible/transparent? Like I just want the buttons and labels to show up, but not the big grey box they're on top of. Setting it to 100% transparency makes the buttons/labels also transparent.

Snarky

You're running into a lot of basic problems that could have been avoided if you'd gone through the tutorial and read the manual before jumping straight into this task.

As for transparent GUI background, you just have to set the background color to 0 in the editor.

Crimson Wizard

#28
Quote from: SmugMonster on Mon 16/04/2018 03:22:39
Soooo it's initializing the dialog properly, but not actually displaying the GUI unless the Display message is in the dialog script.

Hm, still don't have any idea what may be going on. Yesterday I quickly made a test game to see if the code works, and it worked immediately.

Quote from: SmugMonster on Mon 16/04/2018 03:22:39
Also, the actual strings for the name and text "hello player" etc. is not displaying on the labels.

Are the labels on same GUI as the portraits? If not, is their GUI set visible?

Snarky

I'm betting you haven't changed the WaitMouseKey() call, and the problem is that it never blocks, so it just falls straight through the entire dialog in one go before you can see it. The Dialog() calls provide the blocking, but because they're placed before text is set on the Labels, you don't see it.

SmugMonster

#30
I actually did change the WaitMouseKey call, to a fairly large number precisely to avoid that happening.

The labels are on the same GUI as the portraits, yup. They're appearing, with the text "new label" on them. The actual speech string isn't being written. Sorry, could have been a bit clearer with that explanation.

EDIT: Hmm. Crimson, would it be possible for you to share the scripts you used where it worked immediately, so I can compare to mine and see if I might have messed something up somewhere in there?

I just got it a bit closer to working - I put the Display command below the speech lines instead of above it and they printed on the labels as expected. So I just need to figure out why the UI isn't appearing when there's no Display command in there... and, after having fixed the actual UI box to be transparent, I gotta figure out why my portraits have a fuzzy grey box over them, but I figure I've just messed up something in importing them or in setting up the button.

Crimson Wizard

#31
Quote from: SmugMonster on Mon 16/04/2018 16:28:54
EDIT: Hmm. Crimson, would it be possible for you to share the scripts you used where it worked immediately, so I can compare to mine and see if I might have messed something up somewhere in there?


I simply copied the code from those posts above into a new game.

Spoiler


In GlobalScript
Code: ags

void StartVN(this Dialog*, Character *left, Character *right)
{
    ViewFrame *vf = Game.GetViewFrame(left.SpeechView, 0, 0);
    btnVNLeftPortrait.NormalGraphic = vf.Graphic;
    vf = Game.GetViewFrame(right.SpeechView, 0, 0);
    btnVNRightPortrait.NormalGraphic = vf.Graphic;
    gVisualNovelScreen.Visible = true;
    // add anything else you need to setup
    this.Start();
}

void SayVN(this Character *, String text)
{
    lblVNName.Text = this.Name;
    lblVNSpeech.Text = text;
    WaitMouseKey(100);
}
 
void EndVN()
{
   gVisualNovelScreen.Visible = false;
   // add anything else you need to cleanup
}



Room script:
Code: ags

function dummy_AnyClick()
{
	dDialog1.StartVN(player, cSylvie);
}



Dialog script:
Code: ags

// Dialog script file
@S  // Dialog startup entry point
 
 cSylvie.SayVN("Hello, player.");
 player.SayVN("Hello, Sylvie.");
 EndVN();
stop


[close]

Created two characters, one GUI with 2 buttons and 2 labels.


Idk what may be else. Make sure that the background color and color of the label texts are different?...

Snarky

#32
Quote from: SmugMonster on Mon 16/04/2018 16:28:54
EDIT: Hmm. Crimson, would it be possible for you to share the scripts you used where it worked immediately, so I can compare to mine and see if I might have messed something up somewhere in there?

It'd probably be more efficient if you shared yours.

QuoteI just got it a bit closer to working - I put the Display command below the speech lines instead of above it and they printed on the labels as expected. So I just need to figure out why the UI isn't appearing when there's no Display command in there...

I'm telling you, it's because it's not blocking. Maybe the number you put in is too big (the max is... uh, I think something like 15000. Edit: It's 32767 â€" some 13.6 minutes at 40 fps). You could also try changing the WaitMouseKey() call to a simple Wait() â€" try something like Wait(200) (IOW 5 seconds).

The BlockMouseKey() code I linked to above was created precisely for this purpose: the timeout can be as long as you want (within the size of an int), or you can make it wait indefinitely.

Quoteand, after having fixed the actual UI box to be transparent, I gotta figure out why my portraits have a fuzzy grey box over them, but I figure I've just messed up something in importing them or in setting up the button.

The "fuzzy grey box" is the "GUI disabled" gray-out. You can get rid of it by going into General Settings, under Visual, and changing "When player interface is disabled, GUIs should" to "display normally".

SmugMonster

THAT was it - the number in the WaitMouseKey call was too large! Changing that fixed it all.

Thank you, Snarky - it's working as I hoped. Got some prettifying to do with the UI (need to add a background image for the labels, basically just a text box graphic) but I can just tuck another button behind the labels and that should do the trick.

You guys rock!

Snarky


SMF spam blocked by CleanTalk