Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: LuminescentJester on Wed 01/04/2015 03:46:27

Title: Removing mouse modes, walking with arrow keys, adding images to dialogue boxes
Post by: LuminescentJester on Wed 01/04/2015 03:46:27
I'm very new with AGS and have lots of questions that aren't being answered by the wiki or the manual. I've been searching the bfaq and wiki in general for hours but either I'm terrible at it, or its just not there. I apologize in advance if I'm doing something wrong, but everything is kind of new and confusing. My questions are:

1. Is it possible to remove some of the mouse modes? I'd like to try my hand at a game that doesn't have so many mice to cycle through. (Why have a "talk to" button and a "look at" button when one simple "interact" button can work for all of them?) Edit: This one is now solved.
2. Is it possible to change it so you walk with the arrow keys or wasd keys by holding down said keys? (Instead of the default setting where you tap a direction and it starts the walk cycle in that direction until you stop it)? Edit: This one is now solved as well. Just one left.
3. Is it possible to change the dialogue boxes?(I'd like to add character sprites so I can show expression when characters talk to each other, if I can figure it out). Edit: This is solved.

0. Also this is a tad miscellaneous but I'm having general trouble finding a list of basic functions, or keys on this particular programing language. For example, I can't figure out how to assign keys if I start scripting. It seems the "KeyDown" refers to the num 2 on the far right of my keyboard for example, so how would I assign something to the arrow keys under my shift key? Edit: This is solved.
Title: Re: Removing mouse modes, walking with arrow keys, adding images to dialogue boxes
Post by: Monsieur OUXX on Wed 01/04/2015 10:50:39
HEllo,

I'll answer all your questions:

1) How to remove a mouse mode :
     - (the most important step) Simply go to the "cursors" section in the pane on the right-hand side of the AGS editor (http://www.adventuregamestudio.co.uk/wiki/Tutorial_Part_9_-_Cursors_and_fonts), and delete the ones you don't need.
     - (follow-up step #1) make sure the deleted modes cannot be accessed anymore : 1) Remove the buttons for them in the in-game icons GUI at the top of the screen. To do so, edit that GU int he AGS editor 2) Make sure they cannot be selected using in-game shortcuts. To do so, go to your global script in function on_key_press and make sure no key selects "look at" and such.
     - (follow-up step #2) Make sure to never use the deleted modes in your custom scripts. Always just use eMouseUse, for example, if that's the mode you kept.

2) Use the arrow keys to walk: yes, it's perfectly possible, once again you would edit the on_key_press function to intercept the arrows being pressed down, and then you would move and animate your character accordingly (Character.WalkTo, Character.ChangeView, etc...). But it will be easier to use a module that already does it. The default game already contains such module! Create a test game base don the default game, and test the module to see if it suits you. If yes, then import it into your own game.

3) Custom close-up dialog boxes. Yes. You're talking about the "Sierra" speech style, that you can enable in the general options of your game. I'm not a specialist of that dialogs style, so I'll let others explain how to use it. But rest assured that there are modules enhancing the base one offered by AGS, making it possible to create any kind of fancy portrait speech style that uou could ever dream of.

4) List of keys. If you open the help, you can look up "key codes" to find the corresponding help section. Here's the wiki version of that list : http://www.adventuregamestudio.co.uk/wiki/ASCII_code_table
Oh, and when you wrote that pressing the "2" key of your keypad acts as pressing "down", it's simply because the NumLock key of your keyboard is not activated. Otherwise it would indeed act as "2". And I can see no reason why the "regular" arrows of your keyboard wouldn't work.
Title: Re: Removing mouse modes, walking with arrow keys, adding images to dialogue boxes
Post by: LuminescentJester on Wed 01/04/2015 20:18:58
Quote from: Monsieur OUXX on Wed 01/04/2015 10:50:39
HEllo,

I'll answer all your questions:

1) How to remove a mouse mode :
     - (the most important step) Simply go to the "cursors" section in the pane on the right-hand side of the AGS editor (http://www.adventuregamestudio.co.uk/wiki/Tutorial_Part_9_-_Cursors_and_fonts), and delete the ones you don't need.
     - (follow-up step #1) make sure the deleted modes cannot be accessed anymore : 1) Remove the buttons for them in the in-game icons GUI at the top of the screen. To do so, edit that GU int he AGS editor 2) Make sure they cannot be selected using in-game shortcuts. To do so, go to your global script in function on_key_press and make sure no key selects "look at" and such.
     - (follow-up step #2) Make sure to never use the deleted modes in your custom scripts. Always just use eMouseUse, for example, if that's the mode you kept.

2) Use the arrow keys to walk: yes, it's perfectly possible, once again you would edit the on_key_press function to intercept the arrows being pressed down, and then you would move and animate your character accordingly (Character.WalkTo, Character.ChangeView, etc...). But it will be easier to use a module that already does it. The default game already contains such module! Create a test game base don the default game, and test the module to see if it suits you. If yes, then import it into your own game.

3) Custom close-up dialog boxes. Yes. You're talking about the "Sierra" speech style, that you can enable in the general options of your game. I'm not a specialist of that dialogs style, so I'll let others explain how to use it. But rest assured that there are modules enhancing the base one offered by AGS, making it possible to create any kind of fancy portrait speech style that uou could ever dream of.

4) List of keys. If you open the help, you can look up "key codes" to find the corresponding help section. Here's the wiki version of that list : http://www.adventuregamestudio.co.uk/wiki/ASCII_code_table
Oh, and when you wrote that pressing the "2" key of your keypad acts as pressing "down", it's simply because the NumLock key of your keyboard is not activated. Otherwise it would indeed act as "2". And I can see no reason why the "regular" arrows of your keyboard wouldn't work.

Ah. Thanks for the reply but I still seem to be stuck.

1) I see the mouse options (and this was one of the first things I tried) but when I right click it and try to delete it, the "delete this cursor" option is grayed out and won't let me do so. :(
2) I know the default mode lets me walk with the arrow keys, but the way it does so is counter intuitive. If you hold down the left key, for example, you don't walk left. Your character sorta stutters around until you let go of the button. I was wondering if its possible to change that to more of a Super Mario Bros style and if so, how. (minus the running and jumping of course).
3) Hm... okay its called Sierra-style. More specific help would still be awesome but maybe I can find something on the wiki with this new found knowledge. Edit: Just found this topic (http://www.adventuregamestudio.co.uk/forums/index.php?topic=23339), which would be amazingly useful if any of those links worked for me. :-\
Title: Re: Removing mouse modes, walking with arrow keys, adding images to dialogue boxes
Post by: Snarky on Wed 01/04/2015 22:24:21
1. You might not be able to actually delete the built-in cursor modes from the game. But you can just not use them. If you're just using one mode, you can just remove all the code to switch cursor modes. If you're using a subset, you should probably start by editing the "next cursor mode" property so the ones you're using will loop between each other.

Built-in cursor modes is a pretty stupid AGS feature, IMO, but in the early days AGS was designed specifically to make Sierra-style games, and even once it became flexible enough that it would make more sense to just let you define them yourself, it remains for legacy reasons.

2. It's possible, but maybe not entirely trivial. AGS is by default designed to use "click-to-walk", where you just indicate where the character should walk to and the game figures out the path. So the "walk" command works in that way: you tell the character to walk somewhere, and it will walk there without any further input. Direct control, where you guide the character every step of the way, breaks this paradigm. However, you should be able to modify the current keyboard-walk system to do what you want, so take a look at the code in the default game. The trick is to put some code in repeatedly_execute() to check which arrow keys are pressed (using IsKeyPressed(eKeyCode)), and if it doesn't match the previous state, stop/change the walk direction.

3. A few years ago AGS moved to a different domain name, so old links are now broken. If you replace the "www.adventuregamestudio.co.uk/forums" part with "www.adventuregamestudio.co.uk/forums", they should work.

Basically the way Sierra-style speech works is that you create a view that contains the character portrait, and set this as the character's speech view. If the game is set to use Sierra-style speech, the portrait should be displayed next to the text box when the speech pops up. There are a number of ways to make this more fancy (talking animation, lip sync, different facial expressions, change the appearance of the text, better control over where the text and portrait appear on the screen, etc.), but that's the basic idea.
Title: Re: Removing mouse modes, walking with arrow keys, adding images to dialogue boxes
Post by: HandsFree on Wed 01/04/2015 22:49:13
Do you have the KeyboardMovement_102 in your scripts? I believe it comes with the standard template.
To disable the 'tapping' control of the the arrow keys just put 'return;' under where it says 'Tapping Mode'

Code (ags) Select

function on_key_press(int keycode) {

//--------------------------------------------------
// Tapping mode
//--------------------------------------------------

return;


edit: I'm not entirely sure, but if you just set option 'StandardMode' for the mousecursors you don't want to use to 'false', wouldn't that solve the problem?
Title: Re: Removing mouse modes, walking with arrow keys, adding images to dialogue boxes
Post by: LuminescentJester on Wed 01/04/2015 23:51:38
1) I searched and searched but cannot figure out how to remove cursor options from the loop as you suggested. Could you spell it out for me a bit more? (I'm very new to scripting and sometimes this looks like Japanese to me.) edit: I'm having trouble finding the StandardMode for mouse cursors though. ??? Where exactly should I look?
2)Hm...
*opens up script* *cntrl f "tapping"*
*finds the read me* Oh. *reads* *changing "tapping" to "pressing"*
Awesome. Now if I could just figure out how to assign keys to the movement options I would have total control over the movement. Edit: Figure that out. I go to Scripts, then Keyboard movement, then under "get new direction" I add some keys to it.The code:
Code (ags) Select
else if (IsKeyPressed(KeyboardMovement_KeyDown)) newdirection = eKeyboardMovement_Down; // down arrow" ] is already there. So I just copied it and added a letter instead. Making it
Code (ags) Select
else if (IsKeyPressed(eKeyS)) newdirection = eKeyboardMovement_Down; // down arrow S ]
3) Ohhh. We should change that in the wiki so newbs don't get confused. I'll let you know how that goes. Edit: The forums work now but none of the downloads do...
Title: Re: Removing mouse modes, walking with arrow keys, adding images to dialogue boxes
Post by: Monsieur OUXX on Thu 02/04/2015 09:17:15
You're getting there! Slowly but surely! Congrats for your efforts in understanding how scripting works. Once you master basic things, you'll feel so empowered ;) Then you can't get enough!

About the wiki and stuff: yes, it would be useful to replace all "adventuregamestudio.co.uk" with "adventuregamestudio.co.uk". The sad thing is that it has to be done manually. Feel free to do it whenever you spot a broken link.
One thing, though: you seem to rely a lot on online help. But never forget that when you press F1 in AGS you have the built-in help, which is very VERY useful when you learn how to search properly. Sometimes it's better to search in the index, and sometimes it's better to do a full-text search.
Title: Re: Removing mouse modes, walking with arrow keys, adding images to dialogue boxes
Post by: LuminescentJester on Fri 03/04/2015 04:26:45
Quote from: Monsieur OUXX on Thu 02/04/2015 09:17:15
You're getting there! Slowly but surely! Congrats for your efforts in understanding how scripting works. Once you master basic things, you'll feel so empowered ;) Then you can't get enough!

About the wiki and stuff: yes, it would be useful to replace all "adventuregamestudio.co.uk" with "adventuregamestudio.co.uk". The sad thing is that it has to be done manually. Feel free to do it whenever you spot a broken link.
One thing, though: you seem to rely a lot on online help. But never forget that when you press F1 in AGS you have the built-in help, which is very VERY useful when you learn how to search properly. Sometimes it's better to search in the index, and sometimes it's better to do a full-text search.

Reading the built-in help was the first thing I did. But I find it to be a tad confusing, and also very limited. Which is to say, it doesn't answer the questions I have when they're this specific.

1) It seems like disabling certain mouse options should be trivially easy and covered in the help section but for some reason I am completely stumped.
3) I got an updated download for one of the guis. (http://duals.agser.me/Modules/GuiPortrait_v1.0.rar) There's just one problem. The gui has no readme or any kind of guide that I can find. (on the wiki, in the folders, in the forums... do I really just suck this much at searching)?

Edit: I'm not even sure it does what I think it does. I can get it to make a portrait appear at the top of the screen, but what I really want, is for a portrait to appear next to text every time a text box/dialogue option appears. (Again, Phoenix Wright style)

Its hard to become a game maker because first there's all this really hard learning curb stuff to get past while everyone else acts like its easy I guess? I suppose rather or not I succeed will show rather or not the victory simply goes to the most stubborn.
Title: Re: Removing mouse modes, walking with arrow keys, adding images to dialogue boxes
Post by: Snarky on Fri 03/04/2015 09:44:33
The manual actually does answer a lot of your questions, if you know where to look (which, admittedly, is often non-obvious).

1. Sorry, I may have misled you about changing the "next mode" property. Since there is a "go to next mode" function, I thought for sure there had to be a way to define what the next mode is. But it turns out there isn't. (Like I said, the built-in mouse modes are a fundamentally bad idea.)

However, what you do have is a property called "Standard Mode". As the manual says (http://www.adventuregamestudio.co.uk/site/ags/tutorial/ags/9/): "Standard Mode tells AGS that this is a normal user-selectable cursor. It is used when cycling through mouse cursors, to determine whether to use the cursor or skip over it. For example, if during the game you disable the current cursor, AGS will change to the next available Standard Mode."

This suggests the first possible solution: Set "Standard Mode" to false for the cursors you don't want to use.

You see that the text also mentions disabling a cursor. That refers to this function: Mouse.DisableMode(CursorMode) (http://www.adventuregamestudio.co.uk/wiki/Mouse_functions_and_properties).

This suggests the second possible solution: At the start of the game, call Mouse.DisableMode() for each of the cursors you don't want to use.

The third possible solution comes from the key point that mouse modes can only change in a couple of different ways (as described in the manual):
-An event (typically clicking on a button) that has as its action "Set Mode X"
-A script that uses the commands "mouse.Mode = X" or "Mouse.SelectNextMode()"

There are also the following special cases:
-If your current mouse mode is disabled, the game automatically goes to the next available mode that has standard mode set to true
-If the game blocks (when you call Wait() or a blocking function), the mouse mode is set to the wait cursor
-If you're over a popup GUI (e.g. the quit menu), the mouse mode is is set to the pointer cursor

Assuming you're OK with the wait and pointer cursor, and aren't going to disable any of the modes you're using, you don't need to worry about these. Then the solution is simply to make sure that 1) there's no button that sets the mode to one you don't want to use, and 2) the script that changes the mouse mode (e.g. when you right-click) does what you want (in the default game, this is in the on_mouse_click() function of the global script, so have a look at that).

That's three pretty simple ways to achieve what you want.

3. Like I told you before, this is built-in behavior in AGS, and you don't need a module for (a simple version of) it. Start by getting the basic scenario to work: just adding a portrait to the text box. You can then add different facial expressions by using "Character.SpeechView = X". The relevant manual entries are "Text display / Speech functions: SetSpeechStyle() (http://www.adventuregamestudio.co.uk/wiki/Text_display_/_Speech_functions#SetSpeechStyle)" (which only implicitly lets you know that this is one of the game settings in the editor) and "Character.SpeechView (http://www.adventuregamestudio.co.uk/wiki/Character_functions_and_properties#Character.SpeechView)".

BTW, what you describe doesn't sound like Phoenix Wright at all. This is what you seem to be describing:

(http://www.adventuregamestudio.co.uk/images/games/1851_1.png) (http://www.adventuregamestudio.co.uk/images/games/1413.jpg)

And this is how speech works in Phoenix Wright (i.e. Visual Novel-style):

(http://dsmedia.ign.com/ds/image/article/655/655732/phoenix-wright-ace-attorney-20051004012908225.jpg)

Quite different! To get something like Phoenix Wright is a bit more complicated, but definitely doable.
Title: Re: Removing mouse modes, walking with arrow keys, adding images to dialogue boxes
Post by: Ghost on Fri 03/04/2015 09:51:12
Quote from: LuminescentJester on Fri 03/04/2015 04:26:45
Its hard to become a game maker because first there's all this really hard learning curb stuff to get past while everyone else acts like its easy I guess? I suppose rather or not I succeed will show rather or not the victory simply goes to the most stubborn.

There is a learning curve and at times it can feel steep- keep in mind that most people who respond to help threads are experienced AGS users so from their/our point of view things "are easy".


Mouse modes:
You can actually disable a mouse mode via a script command. You'd place it in the GlobalScript's game_start section:


mouse.DisableMode(eModeInteract);

Snarky already covered this... :)

Dialog with Phoenix-style face:
This requires you to code your own dialog code. By default, AGS only supports dialog being displayed as a set of lines where you pick one. You can, however, override this. The manual has a whole section about it, just search for "custom dialog rendering" and you'll get a simple but easy-to-follow explanation with example code. What you want to achieve *is* possible but AGS can be a bit tricky once you step off the "beaten path".
Title: Re: Removing mouse modes, walking with arrow keys, adding images to dialogue boxes
Post by: LuminescentJester on Sun 05/04/2015 06:52:07
Quote from: Snarky on Fri 03/04/2015 09:44:33
The manual actually does answer a lot of your questions, if you know where to look (which, admittedly, is often non-obvious).

1. Sorry, I may have misled you about changing the "next mode" property. Since there is a "go to next mode" function, I thought for sure there had to be a way to define what the next mode is. But it turns out there isn't. (Like I said, the built-in mouse modes are a fundamentally bad idea.)

However, what you do have is a property called "Standard Mode". As the manual says (http://www.adventuregamestudio.co.uk/site/ags/tutorial/ags/9/): "Standard Mode tells AGS that this is a normal user-selectable cursor. It is used when cycling through mouse cursors, to determine whether to use the cursor or skip over it. For example, if during the game you disable the current cursor, AGS will change to the next available Standard Mode."

This suggests the first possible solution: Set "Standard Mode" to false for the cursors you don't want to use.

You see that the text also mentions disabling a cursor. That refers to this function: Mouse.DisableMode(CursorMode) (http://www.adventuregamestudio.co.uk/wiki/Mouse_functions_and_properties).

This suggests the second possible solution: At the start of the game, call Mouse.DisableMode() for each of the cursors you don't want to use.

The third possible solution comes from the key point that mouse modes can only change in a couple of different ways (as described in the manual):
-An event (typically clicking on a button) that has as its action "Set Mode X"
-A script that uses the commands "mouse.Mode = X" or "Mouse.SelectNextMode()"

There are also the following special cases:
-If your current mouse mode is disabled, the game automatically goes to the next available mode that has standard mode set to true
-If the game blocks (when you call Wait() or a blocking function), the mouse mode is set to the wait cursor
-If you're over a popup GUI (e.g. the quit menu), the mouse mode is is set to the pointer cursor

Assuming you're OK with the wait and pointer cursor, and aren't going to disable any of the modes you're using, you don't need to worry about these. Then the solution is simply to make sure that 1) there's no button that sets the mode to one you don't want to use, and 2) the script that changes the mouse mode (e.g. when you right-click) does what you want (in the default game, this is in the on_mouse_click() function of the global script, so have a look at that).

That's three pretty simple ways to achieve what you want.

3. Like I told you before, this is built-in behavior in AGS, and you don't need a module for (a simple version of) it. Start by getting the basic scenario to work: just adding a portrait to the text box. You can then add different facial expressions by using "Character.SpeechView = X". The relevant manual entries are "Text display / Speech functions: SetSpeechStyle() (http://www.adventuregamestudio.co.uk/wiki/Text_display_/_Speech_functions#SetSpeechStyle)" (which only implicitly lets you know that this is one of the game settings in the editor) and "Character.SpeechView (http://www.adventuregamestudio.co.uk/wiki/Character_functions_and_properties#Character.SpeechView)".

BTW, what you describe doesn't sound like Phoenix Wright at all. This is what you seem to be describing:

(http://www.adventuregamestudio.co.uk/images/games/1851_1.png) (http://www.adventuregamestudio.co.uk/images/games/1413.jpg)

And this is how speech works in Phoenix Wright (i.e. Visual Novel-style):

(http://dsmedia.ign.com/ds/image/article/655/655732/phoenix-wright-ace-attorney-20051004012908225.jpg)

Quite different! To get something like Phoenix Wright is a bit more complicated, but definitely doable.

2) Ohhh! Thank you so much! Threw a "mouse.DisableMode(eModePickup);" in my starting room and all is well. I don't know if it will carry over to other rooms but if it doesn't, I could just add it again to each new room, so I consider this done.

3) I suspected this might be hard. I tried "cCharacterName.SpeechView = 2;" but that was a tad... horrifying. And not what I want.
I think you are right. I just want portraits. But I have absolutely no idea what I'm doing. D: I tried the manual but it said: "This topic involves some advanced scripting. If you're just starting out with AGS, please just use one of the built-in dialog option styles for now, and come back to this later when you're comfortable with scripting." And then it proceeded to prove itself horribly right by giving paragraphs of instructions beyond the comprehension of my pathetic mind.

And I would take its advice except, A. I know for a fact I'm not going to learn what I need to understand this by ignoring it and B. this is literally the only other challenging scripting project I foresee. After that I'm content to make my character do basic things, walk around rooms, interact with things. Maybe the dialogue will give me trouble but there's video tutorials on that.

So I fiddled in the code, and pasted things like "SetSpeechStyle(eSpeechSierraWithBackground);" in various places, and my game told me it had no idea what I was trying to do or why I was putting that there. And then I clicked around on the wiki looking for help and found none.

How, specifically, do I make portraits appear next to the dialogue box? What are the codes? Do I paste saids code to do that in the global script or the first room script? Or in both places?
Title: Re: Removing mouse modes, walking with arrow keys, adding images to dialogue boxes
Post by: Snarky on Sun 05/04/2015 08:32:42
If you just want portraits, like in A Date in the Park or King's Quest 3, it shouldn't be difficult at all, and you don't need to write any code. You only need to do this:

1. In your game settings (the tab with lots of configuration options that opens by default when you launch the editor), set the speech mode to Sierra-style (IIRC there are a couple of variations depending on exactly how you want it to behave; I'll leave that up to you).
2. Import your portrait image as a sprite.
3. Create a new view. Create a loop within the view, with one frame. Assign your portrait image to that frame. Remember the number of this view.
4. In your character's properties, set the speech view to the view you just created.
5. That's it! Speech should now look essentially identical to the first example ("It's dead, I guess you have to insert some coins") from A Date in the Park.
Title: Re: Removing mouse modes, walking with arrow keys, adding images to dialogue boxes
Post by: Cassiebsg on Sun 05/04/2015 09:24:24
Quote
2) Ohhh! Thank you so much! Threw a "mouse.DisableMode(eModePickup);" in my starting room and all is well. I don't know if it will carry over to other rooms but if it doesn't, I could just add it again to each new room, so I consider this done.


Ahhmmm.... just add it to Global Scripts and it will carry on to every room you code. Better than adding the code to every single room. ;)
Title: Re: Removing mouse modes, walking with arrow keys, adding images to dialogue boxes
Post by: LuminescentJester on Sun 05/04/2015 19:59:46
Quote from: Snarky on Sun 05/04/2015 08:32:42
If you just want portraits, like in A Date in the Park or King's Quest 3, it shouldn't be difficult at all, and you don't need to write any code. You only need to do this:

1. In your game settings (the tab with lots of configuration options that opens by default when you launch the editor), set the speech mode to Sierra-style (IIRC there are a couple of variations depending on exactly how you want it to behave; I'll leave that up to you).
2. Import your portrait image as a sprite.
3. Create a new view. Create a loop within the view, with one frame. Assign your portrait image to that frame. Remember the number of this view.
4. In your character's properties, set the speech view to the view you just created.
5. That's it! Speech should now look essentially identical to the first example ("It's dead, I guess you have to insert some coins") from A Date in the Park.

*does that* Omg yay! Thank you X2! Just two questions about this.
3A. How do I change the speech view mid-game? (for example, what if I want the first speech bubble to have a calm portrait but then an event occurs that scares the character and the next speech bubble has a frightened portrait?) I tried cCharacter.SpeechView(1); but keep getting a parsing error for some reason? (I get the same thing when I try to change the gPortrait's background graphic midgame. :-[)
3B. For some reason this generated a box around the text. Which is perfectly fine by me, but the background for the box is white and I can't seem to find where to change this? From what I see its not in game settings, colors, text parser, character settings, or global settings. (Now that I look, I don't see any place to change the font for individuals characters either, although I suppose that's not strictly necessary and maybe not worth the headache).
Title: Re: Removing mouse modes, walking with arrow keys, adding images to dialogue boxes
Post by: Snarky on Sun 05/04/2015 23:48:48
3a. You have basically the right idea, but the thing is that SpeechView is a property, not a method. Therefore, to change it you need to write it as "cCharacter.SpeechView = 1;" (assuming your character is named cCharacter - and if it is, I'd recommend using something more descriptive, like cGuybrush or cRoger - and the view you want is 1). And yes, this is inconsistent with how the WalkView (aka NormalView) is set; again, that's for legacy reasons, but it is definitely annoying and confusing. (The risk of confusion between properties and methods is also why I always try to include the parenthesis when talking about a method, e.g. ChangeView() and not just ChangeView.)

3b. I haven't looked into this myself, but I think the text background box is an automatic part of Sierra speech mode (since that's how it looked in Sierra games). To customize how it appears, you have to create a Text Window GUI formatted to look the way you want, and change the game setting "Text windows use GUI" to the ID of that GUI. This is explained in the manual under "Other Features | Editing the GUIs | Customized Text Windows".

When you say "change the font for individuals characters", do you mean text characters (letters, numbers, etc.) or game characters (Roger, Guybrush, etc.)? The first case might be quite difficult: AGS is in no way designed to change font in the middle of a text, and doesn't really support it. A starting point would be SSH's Hypertext module (http://www.adventuregamestudio.co.uk/forums/index.php?topic=29358.0), but you might have to replace the whole dialog system.

If you mean having different fonts for different game characters, that's much easier. Basically, you just have to change the Game.SpeechFont property right before the character speaks. You can store the font as a custom character property (see "Custom Properties"), e.g. "SpeechFont" - you have to match the number to the font list yourself, though. The easiest way to be sure you always remember to set it is to create an extender function (see "Extender Functions"):

Code (ags) Select
void SayFont(this Character*, String message)
{
  int fontNum = this.GetProperty("SpeechFont");
  Game.SpeechFont = fontNum;
  this.Say(message);
}


And now whenever you would call Character.Say("blah blah"), you just call Character.SayFont("blah blah") instead, and it will use that character's speech font.
Title: Re: Removing mouse modes, walking with arrow keys, adding images to dialogue boxes
Post by: LuminescentJester on Mon 06/04/2015 01:03:51
Quote from: Snarky on Sun 05/04/2015 23:48:48
3a. You have basically the right idea, but the thing is that SpeechView is a property, not a method. Therefore, to change it you need to write it as "cCharacter.SpeechView = 1;" (assuming your character is named cCharacter - and if it is, I'd recommend using something more descriptive, like cGuybrush or cRoger - and the view you want is 1). And yes, this is inconsistent with how the WalkView (aka NormalView) is set; again, that's for legacy reasons, but it is definitely annoying and confusing. (The risk of confusion between properties and methods is also why I always try to include the parenthesis when talking about a method, e.g. ChangeView() and not just ChangeView.)

3b. I haven't looked into this myself, but I think the text background box is an automatic part of Sierra speech mode (since that's how it looked in Sierra games). To customize how it appears, you have to create a Text Window GUI formatted to look the way you want, and change the game setting "Text windows use GUI" to the ID of that GUI. This is explained in the manual under "Other Features | Editing the GUIs | Customized Text Windows".

When you say "change the font for individuals characters", do you mean text characters (letters, numbers, etc.) or game characters (Roger, Guybrush, etc.)? The first case might be quite difficult: AGS is in no way designed to change font in the middle of a text, and doesn't really support it. A starting point would be SSH's Hypertext module (http://www.adventuregamestudio.co.uk/forums/index.php?topic=29358.0), but you might have to replace the whole dialog system.

If you mean having different fonts for different game characters, that's much easier. Basically, you just have to change the Game.SpeechFont property right before the character speaks. You can store the font as a custom character property (see "Custom Properties"), e.g. "SpeechFont" - you have to match the number to the font list yourself, though. The easiest way to be sure you always remember to set it is to create an extender function (see "Extender Functions"):

Code (ags) Select
void SayFont(this Character*, String message)
{
  int fontNum = this.GetProperty("SpeechFont");
  Game.SpeechFont = fontNum;
  this.Say(message);
}


And now whenever you would call Character.Say("blah blah"), you just call Character.SayFont("blah blah") instead, and it will use that character's speech font.

3a Ohhhh. Thank you again! Well that fixed those problems. Must remember that rewriting a value requires an =

3b1 Opened the help thing and it told me to right click GUIs and say "new text window gui." I changed the background color on that aaaand nothing happened. It... sounds like it should work and yet.

3b0 Ah yes, I mean individual characters as in... Roger or Guybrush. In this case I'm using a character called Luigi as a placeholder until I'm ready to make the real character. I imported a font (cloisterblack in this case, again just to test it). and then added this to the global script
Code (ags) Select
void SayFont(this Character*,  String message)
  {
    int fontNum = this.GetProperty("SpeechFont");
    Game.SpeechFont = eFontCloisterBlack;
    this.Say(message);
  }

I wasn't sure how this would work since this code doesn't seem to specify my character, and when I tried to substitute "cLuigiSay" for "cLuigi.SayFont" the game kind shrugged at me. Then I deleted that and found that the quoted code above wasn't compiling correctly.

It says "error Nested Functions not supported. (You may have forgotten a closing brace)
Title: Re: Removing mouse modes, walking with arrow keys, adding images to dialogue boxes
Post by: LuminescentJester on Mon 06/04/2015 01:05:40
Quote from: Cassiebsg on Sun 05/04/2015 09:24:24
Quote
2) Ohhh! Thank you so much! Threw a "mouse.DisableMode(eModePickup);" in my starting room and all is well. I don't know if it will carry over to other rooms but if it doesn't, I could just add it again to each new room, so I consider this done.


Ahhmmm.... just add it to Global Scripts and it will carry on to every room you code. Better than adding the code to every single room. ;)

Ah, I was considering that but afraid to mess with the global code too much since the first time I tried that it ended badly. But you're right. It works pretty nicely there. Thanks for the suggestion though. This works much better.
Title: Re: Removing mouse modes, walking with arrow keys, adding images to dialogue boxes
Post by: Snarky on Mon 06/04/2015 01:38:38
You don't need to quote the whole of the preceding post. Just include the bits you're replying to if it helps with clarity.

Quote from: LuminescentJester on Mon 06/04/2015 01:03:51
3b1 Opened the help thing and it told me to right click GUIs and say "new text window gui." I changed the background color on that aaaand nothing happened. It... sounds like it should work and yet.

Well, did you set the Text Windows GUI to the ID of the GUI you created? We're going to need more details to debug this.

Quote3b0 Ah yes, I mean individual characters as in... Roger or Guybrush. In this case I'm using a character called Luigi as a placeholder until I'm ready to make the real character. I imported a font (cloisterblack in this case, again just to test it). and then added this to the global script
Code (ags) Select
void SayFont(this Character*,  String message)
  {
    int fontNum = this.GetProperty("SpeechFont");
    Game.SpeechFont = eFontCloisterBlack;
    this.Say(message);
  }

Right, first of all, if you haven't actually created a custom property for characters called "SpeechFont", you might want to comment out that line while testing, though it shouldn't really make a difference since you're not using the result. Second of all, why have you messed with the indentation? By convention, you're supposed to leave the curly brackets aligned with the outside level, and indent the block of lines in between by one level. Now the block gets indented two levels, which is... not standard.

QuoteI wasn't sure how this would work since this code doesn't seem to specify my character, and when I tried to substitute "cLuigiSay" for "cLuigi.SayFont" the game kind shrugged at me.

It does actually specify the character. It's the "this Character*" part, which means you can call it like any other Character function. Look up extender functions.

QuoteThen I deleted that and found that the quoted code above wasn't compiling correctly.

It says "error Nested Functions not supported. (You may have forgotten a closing brace)

That probably means you've placed it inside of another function, or that you have indeed forgotten a closing brace somewhere above. The code snippet should be a separate function, either at the top of global script or in its own script module. You'll also need to add an import statement to the corresponding header, but now we're getting into very basic, general aspects of AGS scripting, and I would point you back to the manual and tutorials.
Title: Re: Removing mouse modes, walking with arrow keys, adding images to dialogue boxes
Post by: LuminescentJester on Mon 06/04/2015 02:44:29
3b1) I.... what text windows gui? I don't see any. My GUIs are: 0 gstatusline, 1 giconbar, 2 ginventory, 3 gpanel, 4 grestartyn, 5 gsave, 6 restoregame, 7 potrait, and 8 the one I created by right clicking the guis and saying text window gui.

Oh wait... *goes to general options* Ohh its calling upon gui 0 here. I see. I'm an idiot. *sets it to 8* :shocked: Oh. that overwrites the text options. (example, if Luigi speaks in green, this overwrites it so that now he speaks in white or something). That.. solves a pretty small problem while creating a much bigger one. Maybe I'll just deal with white text windows...? Unless I can find a way to set it to the speak character's text color... *fiddles* I can't change the textcolor value to something like "cLuigi(textcolor)"... or at least, I don't seem to be able to.

This... is a weird problem to have... maybe if I could figure out how to write a script that sets the current text gui to the speaking characters.. but then I'm right back where I started, wishing for a line of code to change the value of a pre-existing gui. And if I do that I might as well just use the default textbox gui hidden in #0, and then use that code to change the background instead....? *frustrated noises go here*

3b0 Oh you're right. *moves the script a bit* Now it doesn't give me errors. Yay! Of course it still doesn't work but, progress?

I have looked up extender functions. I am more lost than I was previously. I know this explanation in the guide looks simple but I think I need it even more simple if that's possible... reading this is like if I read an instructional guide on the rules of Japanese grammar written in Japanese.

Do... do I put the header in front of the rest of the text like

Code (ags) Select
import function SayFont(this Character*);
functionSayFont(this Character*)
{
void SayFont(this Character*,  String message);
}

Cause if I do that I just get an error saying I already defined the function.
And if I remove the second line and leave it with just the header and the void I get a different error about how it doesn't expect me to use { or } in the places I am. I feel like I'm shooting darts into a pitch black room while blind folded.

As for the indentation... does... it actually affect things? ??? If.. you have a specific tutorial for this (extender functions). Like... aside from the one in the manual that I'm seriously trying to understand as hard as I can.

The logical thing to do is say "eh, different text colors for each character are good enough. Who needs different fonts?" but if the color scheme thing goes awry.... arg I don't know.
Title: Re: Removing mouse modes, walking with arrow keys, adding images to dialogue boxes
Post by: Snarky on Mon 06/04/2015 09:39:46
I'm starting to feel you need to read the manual more thoroughly, and maybe take a step back and think a bit before you post questions. This forum isn't intended to give you step-by-step instructions on every problem you have, but to help you gain understanding to solve things on your own, and help you out when you're really stuck.

So when you're having an issue with the character's speech colors, for example, you should go look in the manual under "Scripting | Character functions and properties". The list is short enough that you can look through it to see if there's anything relevant there. If you do, you'll find an entry for "SpeechColor property." If you read that entry, you'll see that it says "Gets/sets the character's speech text color. This is set by default in the editor." In other words, you can set the character's speech color in the editor, on the character's property pane. So do that.

The other thing is that "cLuigi(textcolor)" is not correct AGS syntax. cLuigi is a Character (technically a Character pointer, written Character*, but you don't need to worry about that), not a function. A Character is a kind of class or struct, a data structure: it represents a particular game character, e.g. Luigi. A function is a command that can do something. You can't "do" Luigi (well, not in a coding sense, you can't := ). You only put the parenthesis after a word like this when calling a function: saying "do this". A character can have function (functions that belong to a class/struct are usually called methods), but to access them you need to use a dot: "cLuigi.Method(argument)". For example, if the speech color was set using a method, you might call "cLuigi.SetSpeechColor(63255);" When you type the dot, AGS usually brings up a list of possible methods and properties, making it quite easy. If you don't understand the difference between a function and a class/struct like Character, you really need to read up on the basic programming concepts.

The header is a separate text file. In AGS, every script (except for the room scripts) has a header (.ash - for AGS script header) and a main script body (.asc - for AGS script code) as separate documents. In the header you declare things (tell scripts that there is a method or variable with a particular name, usually by writing "import xxxx;"), while in the body you define them: you put the actual content of the function or the value of the variable, i.e. the code.

Most of the time you put all your code in the script body. You should only put in the header the declarations of anything other scripts (e.g. the room scripts) might need to know about. In this case, "Hey, there's a function called SayFont() you can use, and this is how you call it!":

Code (ags) Select
import void SayFont(this Character*, String message);

That's it! Then in the script body you put exactly what I had in my earlier post.
OK? Try rereading the manual entry and see if it makes more sense now.

What you tried is wrong in multiple ways, apart from where you put it:

Code (ags) Select
functionSayFont(this Character*)
{
void SayFont(this Character*,  String message);
}


1. What the hell does "functionSayFont()" mean? If you're trying for "function SayFont()", that space is important. And it should be "void", not "function": void means that it's a function that doesn't return a value. If you put "function", it means it might return an integer. (Again, this somewhat confusing syntax is a legacy thing.) And why aren't you including the second argument? All of this matters! You have to declare and define it exactly the same way.
2. If you fix that, you are declaring the same thing again inside of itself. There's no reason to do this, and it won't work.
3. The indentation is still wrong.

As for indentation, it doesn't actually change the behavior of the code, but it helps you and others read and understand the logic of the code more easily. Once you begin writing more complex code, you'll need it to keep track of which lines belong to each block of code (this is based on very solid psychological principles), so you should learn the conventions and get into the habit now. Badly indented code is a frequent source of bugs. There are some variations in whether to put the opening brackets on a separate line (like I do) and how to treat single lines, but the standard rule is that any time you have a block of code enclosed in curly brackets, you indent it by one level. And you don't indent unless there's a reason for it. Look at well-written code examples to see how they do it.

Apart from the benefit to yourself, if you neglect to indent your code properly, people on the forum may eventually conclude that you're not making an effort, and may stop helping you.
Title: Re: Removing mouse modes, walking with arrow keys, adding images to dialogue boxes
Post by: LuminescentJester on Mon 06/04/2015 20:19:39
Quote from: Snarky on Mon 06/04/2015 09:39:46
I'm starting to feel you need to read the manual more thoroughly, and maybe take a step back and think a bit before you post questions. This forum isn't intended to give you step-by-step instructions on every problem you have, but to help you gain understanding to solve things on your own, and help you out when you're really stuck.

So when you're having an issue with the character's speech colors, for example, you should go look in the manual under "Scripting | Character functions and properties". The list is short enough that you can look through it to see if there's anything relevant there. If you do, you'll find an entry for "SpeechColor property." If you read that entry, you'll see that it says "Gets/sets the character's speech text color.

Okay I can't reply to this whole thing right now because this isn't my computer. I will probably give it a better read/reply later tonight but for this part right here.

I did do that though! I had cLuigi's text color set for most of this topic. It was working fine. Then the moment I changed it to sierra style aka portrait that messed it up and that's what I was confused on. I don't understand why changing that would break it.

Reading the manual works fine for me when it comes to basic things but when it comes to scripting I have no idea what I am reading. I tried starting at the basics in manual but it does not seem to start you with the basic of "this is how scripting works." It seems to jump right in and that is really confusing.

Edits start here:

Now that I have my game again, I double checked that Luigi's text color is indeed set to green, which it is, and that it didn't revert to default or something when I switched to sierra style. Then I fiddled with speech style trying to figure out why it overwrites Luigi's text options and realized that I'm using sierra with backgrounds. When I first saw that I thought it defined something about the portraits but apparently that means it overwrites pretty much everything to do with the text boxes. (At the very least it changes the font as well as the background? That is probably clear to everyone but me...)

So I guess the problem of Sierra portraits eating the text settings is now solved. Meaning all my original questions are now solved. Yay.

If for some insane reason you still want to help me with the font I did this in the global script:
Code (ags) Select
void SayFont(this Character*, String message)
{
  int fontNum = this.GetProperty("SpeechFont");
  Game.SpeechFont = fontNum;
  this.Say(message);
}


And that works now. (Well, it doesn't freeze the game). But I'm still not really clear on how/why it works or how to actually call it in the game. (yes I tried re-reading the help section on that).

You're right, I do need more information on the mechanics of basic scripting. I didn't really realize that when I downloaded this program and the first time I opened the tutorial it didn't seem to cover any of my questions. I guess part of my mistake at this point has been in presuming that the tutorial would be written in a way that would allow me to skip to the parts that are relevant to my current goals, but its more like a novel that needs to be followed from the beginning.

We could call it a day since its just font, and really my characters don't need their own super special font and its probably not worth the headache at this point. It might be better for us to just shelf the remaining problem for now and I can work on those things I do understand for a bit until I encounter another thing that is absolutely necessary, or until I've leveled up my understanding of basic scripting.

I'm really sorry for the headache. Thank you so much for all the help.
Title: Re: Removing mouse modes, walking with arrow keys, adding images to dialogue boxes
Post by: Snarky on Tue 07/04/2015 15:40:23
Glad you've got most of it working!

If you're looking for a basic "this is how scripting works" tutorial, that's what the Scripting Tutorial part of the manual is. It's by no means complete, but it should be enough to get you a basic grasp of the key ideas. If you're still having trouble with basic concepts like functions, variables, structs, headers, etc. having gone through that, you'll have to look elsewhere. These are pretty standard concepts from the C-family of programming languages, so any intro to C tutorial should do the trick.

There ARE certainly aspects of AGS scripting specifically that are not explained (or at least well explained) anywhere (among the more relevant ones: how all the different scripts interact, and how to import and export variables, functions and structs), and it would be good to get some input on trouble spots from a beginner, so if you note down what information seems to be missing, hard to find or difficult to understand, perhaps we could use that feedback to improve the manual.

As for the font... instead of just telling you what to do, I'll step you through how I would go about solving it, step by step. Try to make sure you understand what's going on at each step:

1. First, I would test that the basic approach works. So take somewhere you have "cLuigi.Say("blah blah");", and replace it with:

Code (ags) Select
    Game.SpeechFont = eFontCloisterBlack;
    cLuigi.Say("blah blah");

This should be pretty clear, right?
So, does it now use the right font? If yes, great. If not, we have to figure out why it's not working before we continue. Let's assume it works.

2. Now you might have noticed that after you set the font, all the text uses CloisterBlack for the rest of the game. Let's try to reset it after displaying the line:

Code (ags) Select
  FontType oldSpeechFont = Game.SpeechFont;
  Game.SpeechFont = eFontCloisterBlack;
  cLuigi.Say("blah blah");
  Game.SpeechFont = oldSpeechFont;

You see how we back up the current font, change it, display the message and restore the previous value? This is a pretty common programming pattern. I'm not actually sure whether this will work or not; it depends on whether AGS displays the text right away when we call cLuigi.Say(), before we have time to change the speech font back, or only makes a note to do it later (some game commands aren't executed immediately, but only as soon as the engine can get around to it). If it doesn't, we'll have to figure out some other way to reset it. But let's proceed assuming it does work.

3. If we had to write all of this every time a character says anything, that would be pretty tedious. So let's wrap it up as a function. We'll just use a regular, plain AGS function for now:

Code (ags) Select
void SayFont(Character* cSpeaker, String message, FontType speechFont)
{
  FontType oldSpeechFont = Game.SpeechFont;
  Game.SpeechFont = speechFont;
  cSpeaker.Say(message);
  Game.SpeechFont = oldSpeechFont; 
}

You see how it's just the same code, but we've put all the things that can vary each time you call it (the speaker, the font and the text) as an argument for the callers to fill in?
If you put this function at the top of the global script, you can call it from another function in the global script using this syntax:

Code (ags) Select
  SayFont(cLuigi, "blah blah", eFontCloisterBlack);
Test this to see that it works.

4. If you want to be able to call it from room scripts as well (and you almost certainly do), you need to declare it in the global script header:

Code (ags) Select
import void SayFont(Character* cSpeaker, String message, FontType speechFont);
The idea with headers is that they get added to all the scripts below (so the global script header gets added to all the room scripts), and by putting this definition there, you're letting the scripts know about the function SayFont() they can call. Try calling SayFont() from a room script (the same syntax as in the previous step).

5. It's usually best not to clutter the global script with lots of helper functions like this that aren't specifically about the content of the game. So let's create a new script file and move the code there. I usually keep a script with useful functions in a script called "Convenience." To create a new script, right-click on the script node in the project explorer, and name the script "Convenience" (or whatever else you like). Move the function definition from the global script to the new script (Convenience.asc):

Code (ags) Select
void SayFont(Character* cSpeaker, String message, FontType speechFont)
{
  // The content of the function...
}

And move the function declaration from the global script header to the new script header (Convenience.ash). At the same time, let's add a bit of documentation:

Code (ags) Select
/// Displays the message as a line spoken by cSpeaker, using speechFont
import void SayFont(Character* cSpeaker, String message, FontType speechFont);

When you have a comment with three slashes on the line above the declaration, AGS will use it as the help-documentation for the function, and it will automatically pop up in the editor the way help for built-in functions does. This can be very helpful once you have a bunch of different functions. (You might have to save and rebuild your game, and sometimes even close and reopen the script files, before the auto-popup starts working.)

Test that calling the function from the global script and the room scripts still works.

6. OK, now let's finally make it an extender function instead of just a plain old function!

This isn't strictly necessary, but it makes the code easier to read, and just... nicer. Writing it as an extender function is essentially saying that this function is an action that happens TO, or is performed BY, one of the arguments (which has to be an instance of one of AGS's built-in struct types: Character*, Object*, DynamicSprite*, etc.; or a user-defined managed struct). In this case, it's cSpeaker that is Saying something, and cSpeaker is a Character*, so we want the function to be a Character* extender function. We just change it slightly:

Code (ags) Select
void SayFont(this Character*, String message, FontType speechFont)
{
  FontType oldSpeechFont = Game.SpeechFont;
  Game.SpeechFont = speechFont;
  this.Say(message);
  Game.SpeechFont = oldSpeechFont; 
}

Instead of cSpeaker, we declare the first argument as a special variable called "this" (and with the order reversed). That's it! Of course, we also have to change the definition in the header to match:

Code (ags) Select
/// Displays the message as a line spoken by this Character, using speechFont
import void SayFont(this Character*, String message, FontType speechFont);

Now we get to the point of doing this! Having an extender function changes how we call it. Instead of SayFont(cLuigi, "blah blah", eFontCloisterBlack); we now write:

Code (ags) Select
cLuigi.SayFont("blah blah", eFontCloisterBlack);
See how this is looks just like how you'd call the built-in Character.Say() function: "cLuigi.Say("blah blah");"? It's as if there really was a Character.SayFont() function built into AGS. That's the power of extender functions!

7. We might actually be happy with what we have so far and leave it at this point. However, it's a bit annoying that we have to specify the font every time we call the SayFont() function, if for each character it's always (or almost always) going to be the same every time. (Edit: And more importantly, if you change your mind about which font to use, you don't want to have to go back and change a thousand different cLuigi.SayFont() lines!) The function knows which character is speaking, so it should just figure out which font to use based on that, right? Well, that's what the remaining bit of the code I gave you before does, but the explanation is a little complicated. So you can read on, if you want to:

There are actually a couple of different approaches to solving this problem, each with its pros and cons. I'll just explain the way I used before, since it demonstrates a useful AGS feature: What we want is to have a SpeechFont property for each character which specifies which font to use for their speech; something like cLuigi.SpeechFont. There isn't a property like that built into AGS, but we can use custom properties to add something very similar. Let's add a custom property called "SpeechFont". How to do this is explained in the manual under "Other Features | Custom Properties". Make the type Number (we'll use it to refer to the font number) and set the default to 1 (in AGS, font number 0 is the default normal text font and font number 1 is the default speech font).

Now in the editor, set the value of cLuigi's SpeechFont property to CloisterBlack's font number, and similarly for other characters with the fonts you want them to use.

Now we can change our function to use the value of this property instead of taking the font as an argument:

Code (ags) Select
void SayFont(this Character*, String message)
{
  FontType oldSpeechFont = Game.SpeechFont;
  int speechFont = this.GetProperty("SpeechFont");    // This is the key line that's changed
  Game.SpeechFont = speechFont;
  this.Say(message);
  Game.SpeechFont = oldSpeechFont; 
}

Also change the header to match, of course, and remove the font argument from the places where you call the function. Test. Does it work? Notice how apart from backing up oldSpeechFont, this is exactly the code I gave you before. Hopefully it makes sense this time around!

You may have noticed that before we were using a FontType variable to set the speech font, but now we're using an int. Well, the reason for this is that FontType is a built-int enum (short for "enumerated type": see the manual under "built-in enumerated types"). An enum is essentially a list of options: for example, a Direction enum might have the options: eUp, eDown, eLeft, eRight, eForward, eBackward. But secretly, enums are just numbers, with the each option translated by AGS into its number in the list. So we can always use an int instead of one of the enum values (and in this case we have to, since custom properties can't be enums)... However, if we give a number that isn't in the list, things are going to break!

That's the drawback of this solution: if you put in a number that isn't in the list of fonts as the SpeechFont value for one of the characters, it's going to crash when you run it. Also, since you're just going by font number and not font name, if you remove a font or reorder the fonts, the numbers aren't going to match any more, and suddenly all characters will use the wrong font. And it's a bit inconvenient to enter the font number instead of the font name in the SpeechFont property, particularly if you have a lot of fonts, or if you can't remember whether to count from 0 or from 1. Finally, custom properties can only be set in the editor, you can't change them at run-time, so you're stuck with the value you set. (Edit: This is no longer true in current AGS versions.) That's why personally I'd probably use a different solution to simulate a SpeechFont property, but this will do for now.

8. OK, there is one final improvement you can make. The current version will always use the character's SpeechFont value. But what if we only want to use that value most of the time, and sometimes a different font? In that case, what we want is an argument with a default value. (Usually known as an "optional argument.")

Let's go back to the previous version of the code:

Code (ags) Select
void SayFont(this Character*, String message, FontType speechFont)
{
  // Function body...
}

And the declaration:

Code (ags) Select
/// Displays the message as a line spoken by cSpeaker, using speechFont
import void SayFont(this Character*, String message, FontType speechFont);

We'll change that declaration to look like this:

Code (ags) Select
/// Displays the message as a line spoken by cSpeaker, using speechFont (if provided)
import void SayFont(this Character*, String message, FontType speechFont = -1);

Important! Only change the declaration in the header, not the actual function definition in the script body!
That "= -1" part means that if we call the function without a speechFont specified, it will use -1 as the default. So now the second argument is optional—we can write either:

Code (ags) Select
  cLuigi.SayFont("blah blah", eFontCloisterBlack); // Will use CloisterBlack
... or:

Code (ags) Select
  cLuigi.SayFont("blah blah"); // Will use font -1 (???)
So what the hell is font -1? Well, it's not a valid font number, obviously. Which is the point: we'll use it as a special value to let the function know not to use it, but to go with the SpeechFont property value instead. Change the function to look like this:

Code (ags) Select
void SayFont(this Character*, String message, FontType speechFont)
{
  FontType oldSpeechFont = Game.SpeechFont;
  if(speechFont == -1)  // If the caller didn't specify a (valid) font, use this character's SpeechFont property
    speechFont = this.GetProperty("SpeechFont");
  Game.SpeechFont = speechFont;
  this.Say(message);
  Game.SpeechFont = oldSpeechFont; 
}

And now if we call cLuigi.SayFont("blah blah"); without a font specified, it will use cLuigi's SpeechFont property, but we can overrule it any time we like.

Do you follow? Test it out!

More than likely, there are some bugs somewhere in this code, which I haven't tested myself. Let me know if anything breaks.
Title: Re: Removing mouse modes, walking with arrow keys, adding images to dialogue boxes
Post by: LuminescentJester on Fri 10/04/2015 07:37:46
Quote from: Snarky on Tue 07/04/2015 15:40:23
Do you follow? Test it out!

More than likely, there are some bugs somewhere in this code, which I haven't tested myself. Let me know if anything breaks.

Woah. This is a lot of text. O_O *takes a few days to catch up on college work before trying to implement everything*

Okay. I followed all the steps. I almost got tripped up by the instruction to change the speech font property to cloisterblack (before I realized you were just asking me to change the number "1" to "3"), and then I got pretty tripped up by the end when you used lowercase "s" in the "speechview" thing.

But at long last we have a beautiful set of codes and whatnot that do exactly as you have envisioned. I just have one problem with this.

The default font is white with a black outline. That's ingenious because if you change the white to another color, the black stays, so its always legible. But all other fonts I import don't do that. (I'm honestly surprised I can import fonts intended for word documents into a gamemaker at all).

The logical thing to do is add back the SierraWithBackground but white looks kinda awful on these backgrounds. If I could change the color of the default background with a line of code that would basically fix this, but I don't seem to see a way for that to happen.

I could write a Gui, and that changes the background color... but it also overwrites the text color, and I can't find any lines to code to change that so that it varies from character to character. I have tried numerous things to change that, including trying to straight up change it midroom with lines like
Code (ags) Select
BlockyGui.TextColor =1024;, to lines trying to get it to remember character text is different from normal text like
Code (ags) Select
cLuigi.SpeechColor =1024; to breaking open the huge script we just wrote and trying to get it to add in a variable for speechcolor. (before remembering that even if I succeeded there, it would just be setting Luigi's color again, not the Gui's).

And now its 2:33am and I'm basically out of ideas.
Title: Re: Removing mouse modes, walking with arrow keys, adding images to dialogue boxes
Post by: Snarky on Fri 10/04/2015 11:00:40
I'd have to actually play around with these settings to see exactly how they work in AGS. However, fonts do have a property you can use to set an auto-outline, which might help you out in the short term. (Though this effect doesn't always work well on TTF fonts, depending on the style and size of the letters.)
Title: Re: Removing mouse modes, walking with arrow keys, adding images to dialogue boxes
Post by: Cassiebsg on Fri 10/04/2015 19:10:54
This has turned out in a proper lesson, good job Snarky. someone should add this (or the link to this post) to the manual. ;)
Had no idea about the ///, that'll be handy! :-D