Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Hans on Fri 05/01/2007 21:58:12

Title: Turn character (SOLVED) (and about the reason for some things in AGS)
Post by: Hans on Fri 05/01/2007 21:58:12
Again I am going to ask a probably stupid question. But I just can't find the anwser. I can make characters face a location, but how do I make them look down.
(I wanted to make it look like he's talking to you.)
How do I do this?
Title: Re: Turn character
Post by: Akatosh on Sat 06/01/2007 11:37:18
cEgo.FaceLocation(player.x,player.y+1,eBlock);

This will make him face a point one pixel below his feet.
Title: Re: Turn character
Post by: strazer on Sat 06/01/2007 11:43:34
Surely you mean +1 ?
Title: Re: Turn character
Post by: Hans on Sat 06/01/2007 14:21:15
Quote from: Akatosh on Sat 06/01/2007 11:37:18
cEgo.FaceLocation(player.x,player.y-1,eBlock);

This will make him face a point one pixel below his feet.

Thank you very much. I just couldn't find it.

Quote from: strazer on Sat 06/01/2007 11:43:34
Surely you mean +1 ?


I wouldn't know, but I will try.
Thanks a lot.
Title: Re: Turn character
Post by: Ashen on Sat 06/01/2007 14:28:02
Don't double post.

Because AGS coordinates start from the top of the screen, it would indeed be '+1' to make the character look at the player. -1 would make them look up the screen (with their back to the player). You might have to use a larger number than 1, though - if it doesn't work try +10 and see if that's any better.
Title: Re: Turn character
Post by: Akatosh on Sat 06/01/2007 14:36:55
Whoops sorry  :-[
I tend to mess those two up...
Title: Re: Turn character
Post by: Hans on Sat 06/01/2007 19:04:03
 ??? I probably don't know where to place the code, because it doesn't seem to work.  ??? Don't I have to place it by "Interactions" and than "Run script" ?
Title: Re: Turn character
Post by: Ashen on Sat 06/01/2007 19:08:20
Yes, it goes in a 'Run Script' interaction. However, where exactly you'd put it, depends on when you want it to happen (Character interaction, Object interaction, etc).

Where have you got it at the moment, and when should it run?
Title: Re: Turn character
Post by: Akatosh on Sat 06/01/2007 19:10:04
If that's what you're aiming at... for example, a valid script would be the following:

  // script for Inventory item 1 (Cigar): Look at inventory item
player.Say("It's an unlit cigar.");
player.Say("Which is good, because inhaling its fumes would be bad for my health.");
player.FaceLocation(player.x,player.y+10); //character turns to face the player
player.Say("I hope you got the hint!");
Title: Re: Turn character
Post by: Hans on Sat 06/01/2007 19:15:18
I want to make my character look at you when you use "look at" on him.
He has to tun and say something. My characters scriptname is cEgo and I placed the exact code in "Run script" when you look at him. But nothing happens in the game.  :(
Where is the code supposed to stand?  ???
Title: Re: Turn character
Post by: Akatosh on Sat 06/01/2007 19:17:52
Did you really place it in the right point? Here's a help screen I originally made for another problem, but the same principle is true: http://i8.photobucket.com/albums/a23/FAMILIAR_QUEST/helpforsnail.png

Just choose "Look at" instead of "Talk to". Also, check whether cEgo is "clickable" (checkbox right above the interaction button).
Title: Re: Turn character
Post by: Ashen on Sat 06/01/2007 19:22:48
Akatosh's code should be fine. Are you using the right Character references in the code? (E.g. using (player.x,player.y+10) might not work right if cEgo isn't the player character.) If you're not using the default Roger graphics, have you got the Loops set up right?
Show us the actual code you're using, and where abouts it is - there might be something that fresh eyes can spot.
Title: Re: Turn character
Post by: Hans on Sat 06/01/2007 20:23:26
It's like this:

- The character Roger
- "Interaction..."
- Under "Look at character":
     - "Run Script":
                   // script for Character 0 (Roger): Look at character
                  cEgo.FaceLocation(player.x,player.y+10,eBlock);
     - "Game - Run dialog"

The problem now is that the character turns AFTER saying his tekst.

What wrong?
Title: Re: Turn character
Post by: Ashen on Sat 06/01/2007 21:03:08
I think it's because you're mixing Interation Editor commands ('Game - Run Dialog') and scripting - IIRR 'Run Script' interactions are always run AFTER any other Interaction Editor commands. Try starting the dialog from the Script, instead (Dialog.Start (http://www.adventuregamestudio.co.uk/manual/Dialog.Start.htm) or equivalent command).
Title: Re: Turn character
Post by: Ishmael on Sat 06/01/2007 21:10:10
The execution queue only applies within one script, I think. so adding Wait(1); right after the FaceLocation command should fix it.
Title: Re: Turn character
Post by: Hans on Sat 06/01/2007 21:17:47
Wait(1); doesn't do it. The character still turns after the dialog.

EDIT:
YES!!! That's it!!! It should be something in the script!
This does it:

  // script for Character 0 (Worm): Look at character
cEgo.FaceLocation(player.x,player.y+10,eBlock);
dTopic.Start();

Why isn't it just made to do it in the order I put it in?
Id really like to know the positive side of this.
Title: Re: Turn character (SOLVED)
Post by: Ishmael on Sat 06/01/2007 22:15:14
Oh, I misunderstood Ashen's post. Sorry, my bad.

Dialogs are always ran last in the script they are part of, but the interaction editor is a different deal.
Title: Re: Turn character (SOLVED)
Post by: Ashen on Sat 06/01/2007 22:27:05
Yea, just to clarify that:
'Run script' interactions are run after any other Interaction Editor commands ('Game - Run Dialog' in this case). However within a script, Dialog.Start() will be queued until after all other code has been run. (I can see the point of this with, for example, Character.ChangeRoom - but I'm not sure why it happens with Dialogs, or why 'Run script' interactions aren't just run in order.)
Title: Re: Turn character (SOLVED)
Post by: Hans on Sun 07/01/2007 14:28:44
Maybe there is no good reason and maybe it would be best to advise Chris about this. What do you think? :D
Title: Re: Turn character (SOLVED bot still hot)
Post by: Ishmael on Mon 08/01/2007 10:16:54
Dialog.Start runs last so the script block can finish before the engine starts parsing the dialog out, so it doesn't have to retain the old code suspended in the background when for example running dialog_requests, I believe.
Title: Re: Turn character (SOLVED bot still hot)
Post by: Hans on Mon 08/01/2007 11:06:43
Quote from: Ishmael on Mon 08/01/2007 10:16:54
Dialog.Start runs last so the script block can finish before the engine starts parsing the dialog out, so it doesn't have to retain the old code suspended in the background when for example running dialog_requests, I believe.

I think you're missing my point. "Dialog.Start" doesn't run last, when placed in "Run script". I am talking about that noob thing without any codes. If you have first "Run script", that makes the character turn and second "Run dialog", that starts a dialog, the script will be the last to be run. This makes the character turn after saying something.
Why is the "Run script" always the last to be run?

(Not important: Dialog.Start IN a "Run script" is not last. That one is done in the right order.)
Title: Re: Turn character (SOLVED bot still hot)
Post by: Ashen on Mon 08/01/2007 12:09:24
Kind of off-topis but:
Quote
Dialog.Start IN a "Run script" is not last. That one is done in the right order.

No. As both Ishmael and I have said Dialog.Start() will be queued to the end of the Run Script interaction - it's just that in your code, it's the last thing that should be run anyway so you don't notice. Try something like this and see:

MyDialog.Start(); // Replace with actual dialog name
Display("Hello!");


It should display "Hello!" before it starts the Dialog.

If,as Ishmael says, there's a valid reason for it to behave like that then OK. It's easy enough to have code that runs after the dialogue anyway (use two 'Run script's, and split them at Dialog.Start()). It's still a little strange that the 'Run script' commands are queued to after Interaction Editor commands, but I can't see that changing - Chris has said the Interaction Editor is VERY low priority to be fixed up as so few people actually use it in the long term. (And everyone on the forums will advise them to learn scripting anyway...)
Title: Re: Turn character (SOLVED bot still hot)
Post by: Hans on Mon 08/01/2007 16:43:05
Okay... I'm sorry. I mixed "first" and "last" up. You're right when you say that Dialogs are the last in scripts.
But that doesn't count for things like cEgo.Say("Hello"); .
That will be done in the right order.

So if you want a dialog to start and something to happen after that, you'll have to make a second "Run script". But why? What is the purpose of it?
The interaction editor may be for noobs, but when you want to make a good program, you also want that tot work good if it really isn't done by purpose. And it looks so unlogic. It looks like it has been done with a purpose, because else it would probably just run in the right order. Wouldn't it?
Is there anyone who knows why dialogs are run last in a script and why scripts are run last in the interaction editor?
Title: Re: Turn character (SOLVED but still hot)
Post by: Ishmael on Mon 08/01/2007 17:35:59
I already explained why dialogs are ran last in a script block.

I can't find the diagram right now, but it's somewhere in the manual. AGS handles three script threads, one is blocking, one is non-blocking and the third is IIRC always ran in the background, handling on_mouse_clicks and such. I might remember that wrong, tho. AGS can so only run one non-blocking user script at a time. I think the interaction editor functionality has to do with this; AGS parses the interactions out of the way and then takes on the script thread. Probably to prevent memory access conflicts and other causes of possible crashes.

None of this is certified information, I'm just guessing.
Title: Re: Turn character (SOLVED but still hot)
Post by: Hans on Tue 09/01/2007 18:03:48
I am sorry that I am going to post again, but there are no new reaction. Does this mean that nobody really knows the exact reason for all this?
Title: Re: Turn character (SOLVED bot still hot)
Post by: Khris on Tue 09/01/2007 20:44:03
Quote from: James Blast on Mon 08/01/2007 16:43:05It looks like it has been done with a purpose, because else it would probably just run in the right order. Wouldn't it?
Is there anyone who knows why dialogs are run last in a script and why scripts are run last in the interaction editor?
As Ishmael already explained, this behavior has probably internal reasons. I really doubt it's done on purpose to confuse noobs.
It is absolutely no problem to work around that "wrong" execution order, so why the hell is this so important to you?
Title: Re: Turn character (SOLVED bot still hot)
Post by: Hans on Wed 10/01/2007 11:44:03
I know that it doesn't seem relevant, but I am really fascinated by this. If it isn't done on purpose, why is it still there? You see, I think it is done on purpose, because it doesn't make sense to still have that sort of bugs in this version of AGS. So why is it like that? And you keep saying your own ideas, but nobody really does know the answer.
If it is a bug, it should be repaired. Yes, yes... It is not a big problem (for you), but if it is a bug, it is a bug! And bugs have to be repaired. And what about noobs? Isn't it a problem for them? Like this, it's almost impossible for them to avoid scripting.
If nobody knows the answer, the reason, the positive side of it... why not change it?
Title: Re: Turn character (SOLVED) and who knows the reason for some things in AGS?
Post by: Khris on Wed 10/01/2007 11:49:53
Ok, let me rephrase: It has internal reasons. It's certainly not a bug.
And newbies who avoid scripting won't even encounter this, unless they use the RunScript action, which they aren't, right?

It's like loving to eat cookies but complaining about them crumbling. Just deal with it ;)
Title: Re: Turn character (SOLVED) and who knows the reason for some things in AGS?
Post by: Hans on Wed 10/01/2007 12:07:35
You're right. Noobs don't even use Run script... Unless they want to do something that's not possible with the Interaction Editor, just something simple, like turning your character! And then they have to learn scripting...
*sigh*
I'll stop posting on this topic now (, but I am still wondering..).

Thanks a lot  for all your reactions!
Title: Re: Turn character (SOLVED) and who knows the reason for some things in AGS?
Post by: Khris on Wed 10/01/2007 19:50:54
If it really bothers you that much, why don't you write a PM to Pumaman?
Title: Re: Turn character (SOLVED) and who knows the reason for some things in AGS?
Post by: Hans on Wed 10/01/2007 20:46:37
Because I've never done that before and I don't know how.  ;D
Title: Re: Turn character (SOLVED) and who knows the reason for some things in AGS?
Post by: Khris on Thu 11/01/2007 05:07:05
Ah, ok :D

http://www.adventuregamestudio.co.uk/yabb/index.php?action=pm;sa=send;u=1
Title: Re: Turn character (SOLVED) and who knows the reason for some things in AGS?
Post by: Pumaman on Thu 11/01/2007 21:54:18
Quote from: James Blast on Wed 10/01/2007 11:44:03
If it isn't done on purpose, why is it still there? You see, I think it is done on purpose, because it doesn't make sense to still have that sort of bugs in this version of AGS. So why is it like that? And you keep saying your own ideas, but nobody really does know the answer.
If it is a bug, it should be repaired. Yes, yes... It is not a big problem (for you), but if it is a bug, it is a bug! And bugs have to be repaired. And what about noobs? Isn't it a problem for them? Like this, it's almost impossible for them to avoid scripting.
If nobody knows the answer, the reason, the positive side of it... why not change it?

You could think of it as a bug, yes. However, because of the fact that the interaction editor is only used by new people starting out, who will generally progress quickly onto scripting, the time it would take to fix the issue isn't worthwhile compared to the seriousness of it.

And KhrisMUC, please don't encourage people to PM me technical questions. If it needs an answer, please ask a moderator to move the thread to the main Technical Forum.
Title: Re: Turn character (SOLVED) (and about the reason for some things in AGS)
Post by: Ashen on Sat 13/01/2007 02:04:01
Indeed.

James, if you still need an answer, PM me (now that you know how), and I'll re-open the thread and move it to the Tech forum (the proper location for suggestions / discussions of the engine). Otherwise, can we FINALLY let this rest?