Can't get text to display -quite- high enough

Started by , Wed 29/05/2013 19:47:52

Previous topic - Next topic

TeitakuCoubri


Greetings, all!

I am a new poster here, so I hope this is the right place and all. I did read most of the "read this before posting" message, and I think my question is legitimate, because I didn't find answer to it from AGS forums, google searches or the manual.

My problem is as follows:

I am trying to get the character's speech to always display in the uppermost part of the screen, like in Maniac Mansion. I don't mind doing the formatting of the text manually, and all that tinkering.

I have found out about the "character.SayAt" (or "player.SayAt", really, because I am using the 9-Verbs GUI, trying to create something more Maniac Mansion-like) command, but even when I put the coordinates to be 0 and 0 respectively, the text appears a little bit too low.

It used to also appear a bit too much to the right, but I accidentally solved that by adding to the string length (the screen is 320 pixels wide, but if I put 384 as it's length, it appears near enough the left edge for my purposes - seems like a bit of a hack, but whatever works).

Here you can see what it looks like:

http://oi39.tinypic.com/33vow8z.jpg

I have censored part of the picture, because I want the public to see the game only after it's ready. I don't want to spoil anything, you see. But everyone should be able to see the problem from this picture.

The code I am using is this:

player.SayAt(0, 2, 384, "These heavy oak doors are (etc)");

And I tried the coordinates 0,0, I even tried negative coordinates, but none of it works. The negative coordinates just put the text RIGHT above the character, as if no coordinates are set at all.

My questions are:

1) Is it possbile to get the text to appear in the ACTUAL 0,0-coordinates, or in the uppermost black area that you can see in the picture (like in Maniac Mansion)? In other words, is it possible to get that text moved a bit more, or enough upwards, that it would be in the uppermost possible place, and look good for the game? (as you can see, now the word "shut" is even blocking an object, and that looks ugly)

2) If so, how?

Sorry if this has been covered, I did try to search for the answer with various search words and reading multiple posts and messages, and the only solution that I found was offered, was the

game.dialog_options_x = 1;
game.dialog_options_y = 1;

And I have that implemented within the main doors "AnyClick" function, I even tried putting that right before the "player.SayAt"-command, but it makes no difference whatsoever, might just as well not have it anywhere.

I hope this is an appropriate question, and I hope I am not breaking any rules for posting, I honestly, really did try to seek for the answer elsewhere, but I am not very good at that, it seems, and I get confused easily, so this is my last hope of finding out the answer, if there is one.

Thank you in advance for any answers, even if they prove out not to solve the problem.

Thank you anyway for reading this.

Sincerely,

TeitakuCoubri




geork

Hello TeitakuCoubri, welcome to the forums :)

I don't know if this is the cause of the problem, but in the manual entry for SayAt it states:
QuoteNOTE: This function does not support Whole-Screen speech.

Two solutions spring to mind, and they are both quite similar. One is to write a custom speaking function where the character talking animation plays and a GUI with the text is displayed at the top, the other is exactly the same but with an Overlay instead of a GUI. My preference is overlay.

You could create a custom function using Overlays in GlobalScript.asc, something like:
Code: AGS
void Comment(this Character*, String Text){ //by having (this Character*) as a parameter, you are making it an extender function for characters
                                                      //this means you can call the function by typing: player.Comment("blah")
  this.StopMoving(); //so the character won't keep moving. [this] is a keyword which refers to the specific character calling this function
  Overlay* bgs = Overlay.CreatTextual(0, 2, 384, Game.SpeechFont, this.SpeechColor, Text); //Here you create a textual overlay.
                                                                                           //it's worth looking up in the manual to see what
                                                                                           //all the parameters are.
  this.LockView(this.SpeechView); //locks the character view into it's speaking view
  this.Animate(this.Loop, this.AnimationSpeed, eRepeat, eNoBlock, eForwards); //animates the character using it's speaking view
                                                                              //make sure it is repeating and not blocking!
  WaitMouseKey((m.Length/Game.TextReadingSpeed + 1) * GetGameSpeed()); //WaitMouseKey means wait until the user clicks or presses a key or time runs out.
                                                                       //The stuff inside the parameter is the official AGS maths for how long spoken
                                                                       //text usually appears on screen...I think...
  if (bgs != null && bgs.Valid) bgs.Remove(); //remove the overlay if it still exists
  this.UnlockView(); //unlock the character's view, making it go back to normal.
}//ends the function


Then import it in GlobalScript.ash:
Code: AGS
import void Comment(this Character*, String Text);


Then you can call it in your code, like:
Code: AGS
player.Comment("These heavy oak doors are (etc)");


Hopefully Overlays won't cause the same problem... It should work though. Note, however, that voice acting won't be supported in the same way using this method...you'll have to play the sound files manually.

Hope this helps!

TeitakuCoubri

#2
Quote
Hello TeitakuCoubri, welcome to the forums

Hi, Geork, and thank you!

Thank you also for your swift and information-packed reply! I really appreciate it.

Quote
I don't know if this is the cause of the problem, but in the manual entry for SayAt it states:
QuoteNOTE: This function does not support Whole-Screen speech.

*Blush*. Well, this is embarrassing. I thought I already researched the SayAt and all, I actually read that part a few times - but somehow that bit escaped my view! Sorry about that. I guess my brain didn't register 'Whole-Screen speech' as 'relevant to text positioning' somehow.

Quote
Two solutions spring to mind, and they are both quite similar. One is to write a custom speaking function where the character talking animation plays and a GUI with the text is displayed at the top, the other is exactly the same but with an Overlay instead of a GUI. My preference is overlay.

Wow, this sounds quite complicated. I am not even sure I completely understand what that means in practice. You mean, introduce another GUI to the game? It's not going to mess up the 9-Verb-GUI that I got painstakingly customized to resemble the Maniac Mansion's old first SCUMM engine as well as I possibly could, is it?

What's the difference between the Overlay and the GUI solutions, and why do you prefer the Overlay? Sorry, at the moment, this is a bit over my head, so I am simply trying to grasp all this.

So much trouble over such a small amount of pixels, somehow I really understand people who say "So close, yet so far"..


Hmm.. I would never want to stop the character from moving, if I knew how to implement the Maniac Mansion-style speech, where the character can be walking -and- still his head will animate to speak! So I guess the sensible solution is to rather stop the character.

Quote
Hopefully Overlays won't cause the same problem... It should work though.

Thanks for all the help and the code! You went through a lot of trouble just to help me with this small problem, I am very grateful for that.

I guess I just need to learn a lot more before I can even begin to understand what you told me, and the code.. but now I have definitely something to think about, and possibilities to ponder. I thought it would be something much easier, like somehow being able to implement those negative coordinates after all, or that there would be some kind of basic "zero point" to define for those functions and commands, which would then make it possible.

But I don't even really know what an 'overlay' is in AGS, nor do I quite get how to add or operate another GUI.

EDIT: Now that I have glanced it over a bit, it doesn't seem that mystical anymore, and I am starting to understand how it works. Perhaps I could implement your code by tomorrow or so! Or at least get frustrated trying (:

I plan to test your code and see if it works, and perhaps I could then report to you how it all went.

Thank you again for your incredible helpfulness, kindness and intelligent information and code that must have taken you awhile to put together, I truly appreciate it!

As a sidenote, sometimes I think AGS intentionally tries to prevent anyone from creating a Maniac Mansion-style game, heh. So much work has to be done just to get the basic functionality to resemble the C64-version of the Maniac Mansion, and so many unexpected obstacles must be somehow conquered. Still, I am determined to create this small few-room-game, so I can hopefully lure in some talented people to help me with the Big Game (would basically be the same thing - I mean, Maniac Mansion-style GUI and all -  except that it would have way more rooms and a better plot) (:

Quote
Note, however, that voice acting won't be supported in the same way using this method...you'll have to play the sound files manually.

Thanks, but I don't need to note that.

(A small rant about how much I hate voice acting begins)

I am not planning to use voice acting - I hated it even in DOTT, because in my head the voices were so much better than in the game, and although they were skilled, they didn't really always realistically take the exact situation into account in their intonations, emotions and reactions. Like emphasizing "over" in "How did you get over there" instead of "there", which would have been more logical in my opinion. And I find that voice acting detracts from the gameplay and immersion - instead of just being able to dwell deeply into the game with your own thoughts in harmony, your concentration is constantly interrupted by some nasal-voiced actor who tries to sound like a specific idea of someone, when you could otherwise hold many different ideas on how that individual is supposed to sound. Also, have you ever bumped into a problem, which forces you to try the same thing a lot? Listening to the same exact voice clip or sample gets annoying really quickly. But text never does.

In my opinion, text is more user-friendly - it's faster to read than listen to someone speak perhaps quite slowly, you can read it at your own pace - fast or slow, you can't accidentally "not read" a word (ahem.. forget what happened earlier in this post (: ) and need it repeated, or if you need to repeat something, you can just read the relevant part, instead of having to listen to someone all over again, etc.

Test is handy, visual, painless, etc. Sound either creates or breaks the mood, but with pure text you can really provoke the imagination deeper than with any other way. Of course certain visuals (used right) can lend a hand in that.

(A small rant about how much I hate voice acting ends)

But this is probably enough 'philosophy' for now, so I will end it here - I just meant to say that I hate voice acting in games so much, that it's not going to be a problem if I can't use it (:

Quote
Hope this helps!

Well, I hope to know soon, all I need is to gather my courage and just attempt to implement your pretty neat-seeming overlay solution, I hope to keep you posted!

Thank you again for your help, I hope to attempt to implement the code somehow relatively soon..



TeitakuCoubri

Update:

I didn't implement your full code yet, Geork, but I just implemented the overlay test from the manual. At first I couldn't get it to work, because the manual mentioned that it should operate outside functions, but when I realized to put it inside a function, it worked.

But! It's weird, but the problem is still not quite solved. The overlay does put the text a bit higher up (yay!), but not QUITE as high as I had hoped. About three lores pixels of text still appears on the general background area. The text doesn't go all the way up to the highest possible place. So it's much better now, but still not quite there, as you can see from this picture:

http://oi42.tinypic.com/de8n69.jpg

HOWEVER, if it's absolutely impossible to get the text higher, what's three pixel rows? I can sacrifice that much graphics easily. Though, I guess a fourth pixel row would also have to go because I don't want the text to 'touch' the 'graphics' (clearer that way).

Still, this is a good opportunity for me to learn to conquer my perfectionism that has been bothering me. Life is much better without everything having to be perfect.

So, thank you for your help - now that I look at your code and explanations (and excellent comments), I think I understand it pretty well (reading about the Overlay from the manual also helped), and shouldn't have that much trouble implementing it.

Thank you very very much for your help, you have been very kind, informative, friendly, helpful and basically solved my problem! I appreciate your help enormously.

You have also motivated me to continue working on the game, and if I ever get it ready, I hope to send it to you and another very kind and helpful AGS-genius before anyone else!

Truly, honestly, you made my day! I had a nice walk early in the morning (from about 02 am to about 04:45 am) and now I got my problem solved, too! Can a morning begin better than this? (:

Now I am off to edit some graphics..






abstauber

You can also use negative coordinates. So in case this has something to do with the font-height, just use coordinates like 0,-3 for the overlay in Geork's function (or your own overlay test)

TeitakuCoubri

Quote from: abstauber on Thu 30/05/2013 08:05:33
You can also use negative coordinates. So in case this has something to do with the font-height, just use coordinates like 0,-3 for the overlay in Geork's function (or your own overlay test)

Thanks. But I tried that already - I usually try negative coordinates if positive are not enough. It only put the text in the middle of the screen instead of putting it higher, but I have to admit I still haven't actually implemented Geork's code, but just took the simple Overlay-example from the manual to save some trouble in case it doesn't work. So maybe with Geork's code, the negative coordinates would work, but at least with the manual's example, they don't.

I got everything working now though - I simply edited the background graphics a bit, and now it looks good, the text always having a black background.

So this issue can be considered "Solved", as far as I am concerned.

Thank you, Geork, and thank you, Abstauber, for help and for being such intelligent, informative, and incredibly kind-hearted individuals!


TeitakuCoubri

#6
Hello again, Geork!

I tried to implement your code, but all I get is:

"Error (line 6): PE03: Parse error at 'cDale'"  and the file is "GlobalScript.ash".

I have no idea what's wrong, so any help would be appreciated. Oh, and "cDale" is of course the character I am using.

I am probably going to be away from the computer for many hours from now, but I hope to check back later and see if anyone figured it out - this problem is too much for my brain, it seems.

Khris

You use the function just like Character.Say().

From the error you got, it seems like not only did you try and use the command outside a function, you also put it in the header (*.ash).

Just like any other command, it needs to go in a function's event, in the room script or GlobalScript.asc.

TeitakuCoubri


Hello, Khris, and thanks for the reply!

Quote
You use the function just like Character.Say().

Yes, I know. That is how I used it. But, the error happens even if I am not using it at all (I commented it out and the error still happens). This is how I used it in the room script:

function hmainknobs_Look()
{
player.Comment("This is a test");
}

Quote
From the error you got, it seems like not only did you try and use the command outside a function, you also put it in the header (*.ash).

That is not true - I used it inside a function, and besides, even if I am not using it, I still get the error.

The only thing I put in *.ash is what was told to put there, the "import"-command;

import void Comment(cDale Character*,  String Text);

Does that need to be inside a function?

Quote
Just like any other command, it needs to go in a function's event, in the room script or GlobalScript.asc.

Yes, I know. But I still get the error even if it's inside a function, or even if it doesn't exist at all. I only did what I was told to do, and as far as I can tell, I did it exactly according to instructions. Here is what I wrote in the Globalscript.asc:

void Comment(cDale Character*, String Text){ //by having (this Character*) as a parameter, you are making it an extender function for characters
                                            //this means you can call the function by typing: player.Comment("blah")
cDale.StopMoving();
Overlay* bgs = Overlay.CreatTextual(2, 0, 384, Game.SpeechFont, cDale.SpeechColor, Text);
cDale.LockView(cDale.SpeechView);
cDale.Animate(cDale.Loop, cDale.AnimationSpeed, eRepeat, eNoBlock, eForwards);
WaitMouseKey((m.Length/Game.TextReadingSpeed + 1) * GetGameSpeed());
if (bgs != null && bgs.Valid) bgs.Remove();
cDale.UnlockView();
}

My room script you already know, because I wrote that earlier in this post - it's just that simple "player.Comment"-line inside the proper function (though to be technically accurate, I know I should rather have used the 'anyclick'-function with this 9-verb GUI, and not the "object.Look"-function).

So as far as I know, I am doing exactly as you say I should be doing, and exactly as Geork instructed me to do. Would it be possible for you to try out Geork's code and see if you get the same error (You can find it earlier in this thread)?

Thanks anyways for trying to help, I appreciate it!

Khris

Oh my.
Why would you go ahead and change the function like that, without understanding what you're doing? I get that you're new to this, but does it say anywhere that you're supposed to replace "this" with the name of the character...?
Also, didn't it make you pause that AGS would complain about the very thing you have changed? Or that even the forum makes "this" blue, indicating it's a dedicated keyword of AGSScript?

What you were provided with is a so-called extender function.
What this syntax:
Code: ags
void Comment(this Character*, String Text)

does is allow you to use cDale.Comment("text") in your code, as if it were a built-in function. When you do that, "this" in the code will point to "cDale", which will effectively replace every "this" in the code with "cDale" by default. It's the very purpose of using this. Because whenever the function is called, "this" will refer to the parent object, i.e. the Character*.

Even if what you did worked in theory, you'd have turned a generic function into one that will only work for one specific character, which is precisely NOT what you do in programming.

TeitakuCoubri

#10
Quote
Oh my.

Oh yours?

Quote
Why would you go ahead and change the function like that, without understanding what you're doing?

Well, this comment: "[this] is a keyword which refers to the specific character calling this function" is pretty much the reason. I figured that it needed the character's name instead of the word 'this', because Geork had no way of knowing what I might be calling him, so he needed to replace the actual name with a sort of variable, and used 'this'.

It's not otherwise very intuitive to use such a word in a scripting language, you know.

And as to WHY? Well, because I had a problem with the text, and that was the solution that was offered to me. What else was I supposed to do - learn the whole syntax of every command in AGS, and three years later implement the code with "understanding" (which is a word I don't want to use anyway)?

I wanted to honor the solution and try it out, instead of just ignoring it and going on my way for a long period of time.

Besides, it was such a 'small problem' in a way, I just wanted it fixed so I could complete the small game I am trying to make. I just had no idea the word "this" could really be part of a programming/scripting language syntax, it sounds like something a human would say.

The ultimate answer to your question "why" is "because I am making a game", that's why. And it seems that AGS has something against Maniac Mansion - it even says in the Tutorial that Lucasarts games have non-clickable characters, but this is not completely true - Maniac Mansion's characters are perfectly clickable, if you give them items, for example (how else could you transfer stuff between characters in the game?)

Quote
I get that you're new to this, but does it say anywhere that you're supposed to replace "this" with the name of the character...?

As we can see from your sentence, the word 'this' can mean so many things, and that comment really did say something to that effect, I can repeat it here:

"[this] is a keyword which refers to the specific character calling this function"

That is what Geork's comment said. How else was I supposed to interpret that?  The SPECIFIC CHARACTER is "oDale", and since the word "this" is even in brackets, it seems to imply that it's just a placeholder, and not THE ACTUAL WORD that needs to be there. I thought Geork was the one doing the referring, and that it meant that he is simply referring to the main player character that I need to put there instead of the odd word "this".

That comment seems to be saying that the word "this" is REFERRING to a SPECIFIC CHARACTER, so it means that because Geork couldn't possibly know the name of my SPECIFIC CHARACTER, I need to of course put it there instead of that keyword (being keyword because it's the only word that is just a placeholder, everything else about the code being literal).

Quote
Also, didn't it make you pause that AGS would complain about the very thing you have changed? Or that even the forum makes "this" blue, indicating it's a dedicated keyword of AGSScript?

I didn't see it as 'changing' things, I saw it as simply as doing as instructed, using the proper variable instead of just an english word "this" (which doesn't sound like programming/scripting language).

So, it needs to actually be "this" - I get it now, and am going to try it soon. But you could be a little more tolerant and understanding - we all make mistakes, we are only human. There is no need for "oh my". Did you never make a similar mistake?

And the forum doesn't make it blue for me, because I am using system colors in my browser - all text is black on green for me. And the annoying white background in AGS makes it hard for me to see colors anyway, because I am a little bit colorblind.

Any other ways for insulting my intelligence you want to use? Why couldn't you just simply say: "Easy mistake to make - you just need to replace cDale with the word 'this' and it will work" instead of your attitude, your "oh my"s and your "well, why didn't you realize this, are you dumb or something"-type of questions?

Someone said people here are friendly, and with Geork's and Abstauber's comments, I was ready to think this to be true, but with your comment, I realize this place is just like any other on this planet - filled with people with attitude and insulting questions towards beginners and those who make mistakes.

I also didn't see it as different color in AGS, because I never directly copypasted it into AGS - I edited it in notepad first, like I always do with copied text/code/whatever.

Quote
What you were provided with is a so-called extender function.
What this syntax:
Code: ags
void Comment(this Character*, String Text)

does is allow you to use cDale.Comment("text") in your code, as if it were a built-in function. When you do that, "this" in the code will point to "cDale", which will effectively replace every "this" in the code with "cDale" by default. It's the very purpose of using this. Because whenever the function is called, "this" will refer to the parent object, i.e. the Character*.

Okay, that makes sense, thanks for the explanation.

Quote
Even if what you did worked in theory, you'd have turned a generic function into one that will only work for one specific character, which is precisely NOT what you do in programming.

Yes, I did wonder about that (and this is not supposed to be 'programming' per se, but 'scripting' anyway), but I figured that since I am only going to be using one character, it's not going to be a problem, and that there's probably some kind of tweak that can be implemented, if more characters are needed.

Thanks for the help, but I really do not appreciate the attitude and insulting questions that came with it. I suggest learning to be more tolerant towards newcomers and beginners and for different kind of thinking if you want to keep helping people - and a little less "oh my"s and "why didn't you think of this, although it should be obvious"-kind of attitude-loaded questions.

This topic can be closed/marked solved/whatever you do, as far as I am concerned.

TeitakuCoubri

#11
By the way, there is a typo in Geork's code, which I figured would be a typo, but I pasted it faithfully anyway. It says "CreatTextual", when I did wonder about whether it should be "CreateTextual" instead. It seems that AGS says '.CreatTextual is not a public member.." etc.

I am just saying this in case someone else wants to use Geork's code, just so they know it contains a typo that needs to be fixed if it's to be used.

Oh, and the code still gives a "undefined symbol 'm'" because of the "WaitMouseKey" calculation, but that's of course easily replaced by a number. Though it would mean that text of any length would 'wait' just as long, it's not really a problem in my case, because there's such a small amount of text that fits in one row with those fonts anyway.

So, thanks, Geork - you could have perhaps tested your code before offering it, but I still appreciate it very much!

Thank you also, Khris - I don't appreciate your help as much because you laced it with attitude and insulting questions, but it's help nevertheless, and I still want to thank you for it, although part of me would like to do something completely different.

Just a last note: the code actually WORKS, when properly implemented - now the character speaks it just fine, and the text is displayed high enough, and my game can now continue.

Thank you all again!

Khris

Oh come ON!
This is the internet, not a pink couch with lots of cushions and teddy bears. Please get over yourself.
And I just love long defensive rants full of bad excuses and pedantry.

Also, last time I checked, every single word AGSScript uses is... English! It's like "if, void, Comment, StopMoving, Animate, WaitMouseKey, this...- wait a second, "this"? What the hell? Surely I need to replace that with something of my own choosing!" Sorry, no (wrong)

It didn't help that you think that "AGS has something against Maniac Mansion". I just can't stand people blaming their tools when it's clear that they themselves are at fault, which I'll freely admit influenced the tone of my previous reply.
And just so you know, there's a 1:1 Maniac Mansion remake made with AGS called Maniac Mansion Deluxe.

Also, everybody else here is much more friendly than me.

Edit after double-post:
Quote from: TeitakuCoubri on Sat 01/06/2013 18:45:10[...] and I still want to thank you for it, although part of me would like to do something completely different.
Please, by all means, speak your mind. I can take it. Feel free to add douchebaggery to unwarranted entitlement.

geork

Hello TeitakuCoubri!

Ooops! Errm, replace all instances of "m" with "Text" - For personal use I just use short, non-descriptive letters (I have similar code in the project I'm working on), but I wanted to make it clearer so I put "Text" instead, and forgot to change it for the calculation, my bad!

I realize I should have given more explanation perhaps, thus to avoid confusion. I feel like I threw you out into the deep end, which was a bit unfair of me... sorry about that :\

There's great sections in the manual for functions and extender functions which fleshes out what Khris said.

Hopefully that will help clarify things!


Ryan Timothy B

@TeitakuCoubri: Holy heck, you ramble a lot! Try to get the point without all that filler text. Even you asking for help or responding to someone is quite daunting and a chore to read.

Anyway, you simply misunderstood and screwed up. My advice for next time, just bite the bullet and simply say it as it was: "Sorry, I'm new to scripting and misunderstood. Thanks for the help, guys".

Also a side-note for future reference. When you post code, use the code format like so (that way we can see it in the color formatting and it's easier for us to help you):
[code=ags][/code]

Calin Leafshade

Could we... could we *get* a pink couch with cushions and teddy bears?

SMF spam blocked by CleanTalk