SayAt in room script.

Started by Mr_Threepwood, Thu 13/07/2006 00:50:39

Previous topic - Next topic

Mr_Threepwood

OK, maybe I'm going about this the wrong way but here's what I want to do.  I'm trying to make a simple cutscene where the character is not on screen but he talks at a certain x y coordinate.  In the room script I put character
[EGO].SayAt(100,100,100,"Hi");

This doesn't compile however, so I'm wondering do room scripts work differently from the global scripts?
I am a mighty pirate

Kweepa

Firstly, I assume you wrote the following (all on one line).
Code: ags

character[EGO].SayAt(100, 100, 100, "Hi");


What was the error message? Post it here.

Where in the room script did you put this line of code? Was it inside a function? If you're still having problems, post the code around the error.

Do you still have a character called EGO? Perhaps you renamed the player character? Try:
Code: ags

player.SayAt(100, 100, 100, "Hi");

If you definitely have an EGO character, try:
Code: ags

cEgo.SayAt(100, 100, 100, "Hi");

The editor should autocomplete cEgo for you.
Still waiting for Purity of the Surf II

Mr_Threepwood

The error message I get is:

"Parse error: unexpected 'character' "

Yes I did have it all in one, I must have accidently hit space when I made that post.Ã,  That line is the only thing existing in my room script, I'm new and am just trying to figure out how the room scripts work.Ã,  I've made my lucasarts style GUI which seems to work, so I figured that the room scripts probably work exactly like the global script in terms of the functions that you can do, am I wrong here?

I also tried cEgo.SayAt and that didn't work, and yes my characters script name is EGO.
I am a mighty pirate

Khris

You need to put the line inside a function.
When do you want EGO to say that?
Double-click the appropriate interaction (e.g. click the button labeled "i" in Room -> Settings for a list of available room interactions), choose "RunScript" from the drop down-box, click on "Edit Script" and insert the line in the window that opens.

Then close the two windows and click the {}-button to see how AGS implemented the command in the room script.

Mr_Threepwood

Thank you that works, it was a very dumb reason I'll admit but I couldnt figure it out since I am so new to using AGS.

So is this how it works, you create an interaction to run a script, which then puts a new script labeled room_ and a letter into the main room script.  Then when the interaction is triggered it runs the function it's set for in the room script.
I am a mighty pirate

Khris

#5
Yep, exactly. They work just like the global script. The only real difference is that the functions inside are all room-specific, while the global script contains those which aren't.

Mr_Threepwood

One more thing, for some reason whenever I put in x y coordinate for my 320x240 room they never seem to be where they should be.  I'll look at the room editor and see the spot 120,100 for example, but when I print to those coordinates it doesnt print there, it prints in a close spot but not the right one.  Why is this and how can I fix it?
I am a mighty pirate

monkey0506

Hmm...according to the manual:

Quote from: Character.SayAt[/url]SayAt

(Formerly known as DisplaySpeechAt, which is now obsolete)

SayAt(int x, int y, int width, string message)

Similar to Say, except that the text is displayed with its top left corner at (X,Y), in an area WIDTH wide.

So...are you sure that the top-left corner isn't displayed at (X, Y)? Perhaps the font has whitespace at the top and/or left side(s) that is calculated into the positioning??

Mr_Threepwood

no the top left corner is definitly not being shown in the right place.  Does AGS really favor 320x200 resolution and mess up placement with anything else?  I think that might be the cause of my problems.
I am a mighty pirate

monkey0506

Okay...could you perhaps post an example of where it should display and where it does display? You mentioned using (120, 100), but never said where it actually displayed at.

Mr_Threepwood

Ok well here's what it looks like, I make my character SayAt (120,100), but the upper left hand corner of where it actually displays looks more like (120,60).  By this I mean I checked the coordinates on the room image to choose (120,100) so I could position it under the stuff in the image, however it is displaying higher then it should be for some reason.

When I make my games resolution 320x200 however, it displays in the correct spot.
I am a mighty pirate

Mr_Threepwood

Sorry to be a bit of a pain, but could anyone verify this problem or is it just me (in which case I'm doing something wrong)?

I read somewhere on the forums or on the AGS help something about relative screen position and how the resolution affects it or somethimg, but can't seem to get a definitive answer as to why I might be having this problem with placing items at x,y coordinates.  It's not like it's a syntax error or anything since it does it, but in the room editor I look at where I told it to go, but when I run the game it's off by a bit for some reason.
I am a mighty pirate

Mr_Threepwood

#12
In the AGS manual it says SayAt displays text with its top left corner at (X,Y).Ã,  I'm getting it to be that the bottom left corner is at X,Y.Ã,  Is the manual wrong here or is this just some weird thing I'm experiencing and no one else is?

Edit:  Something is definitly weird with the SayAt command, I did DisplayAt and it works perfectly whereas SayAt seems to scew the text from where it should be.  It has something to do with setting the width of a SayAt command.  Is this just how it is supposed to be, or is it a bug?
I am a mighty pirate

Ashen

What speech-style do you use?
By default, Lucasarts style is centered - in this case it'd be centered in an area 100 pixels wide starting from x = 100 (from the code in your first post). Since "Hi" is less than 100 pixels wide, it would be noticably further over. If you set a width less than the text needs to display properly, this might cause the 'skewing' you've noticed.
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk