Removing mouse modes, walking with arrow keys, adding images to dialogue boxes

Started by LuminescentJester, Wed 01/04/2015 03:46:27

Previous topic - Next topic

LuminescentJester

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.

Monsieur OUXX

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, 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.
 

LuminescentJester

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, 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, which would be amazingly useful if any of those links worked for me. :-\

Snarky

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.

HandsFree

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

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?

LuminescentJester

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
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
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...

Monsieur OUXX

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.
 

LuminescentJester

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. 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.

Snarky

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: "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).

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()" (which only implicitly lets you know that this is one of the game settings in the editor) and "Character.SpeechView".

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



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



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

Ghost

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:

Code: ags

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".

LuminescentJester

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: "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).

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()" (which only implicitly lets you know that this is one of the game settings in the editor) and "Character.SpeechView".

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



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



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?

Snarky

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.

Cassiebsg

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. ;)
There are those who believe that life here began out there...

LuminescentJester

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).

Snarky

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, 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
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.

LuminescentJester

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, 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
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
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)

LuminescentJester

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.

Snarky

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
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.

LuminescentJester

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
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.

Snarky

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
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
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.

SMF spam blocked by CleanTalk