Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: hiram on Sat 05/02/2005 00:16:55

Title: A non-blocking MoveCHaracter function
Post by: hiram on Sat 05/02/2005 00:16:55
Now that the lamp is working I can't figure out why the objects and characters
stop being animated when the player moves to pick up something or use
something.

For example, I set up an interaction with a lamp and a MoveCharacter before so
that the player has to actually walk over to the lamp, but while he is walking
everything else stops animating.

I checked in the manual for various versions of the MoveCharacter function
but they all seem to be blocking and when they run they stop all the
other scripts.

How does one retain the animating characters in the background?
Title: Re: A non-blocking MoveCHaracter function
Post by: Goot on Sat 05/02/2005 00:26:11
MoveCharacter(CHARID,int x,int y) isn't blocking, but it won't wait for the move to stop. The blocking is what makes it do that. While a blocking function is running, the repeatedly execute scripts will not run, but the repeatedly execute always scripts will. If something is already animating, it should continue animating unless the game is paused, or there's something in repeatedly execute which makes it keep animating.

It sounds like you either have to:

a.) put the script for keeping whatever it is animating in repeatedly execute always (you can't put blocking functions there).

or

b.) make it so you won't need repeatedly execute to run at that time. There's a parameter for repeat in AnimateCharacter, or AnimateObject or whatever, so you can have it keep repeating in the same loop.
Title: Re: A non-blocking MoveCHaracter function
Post by: hiram on Sat 05/02/2005 00:51:29
I didn't manage to find any reference to a repeatedly execute always function.

As for the other solution, I tried putting AnimateChatacter at the end of the
room script but when compiling I got an error "Parse error: Unexpected SetCharacterView"

The code looks like this:

// room script file
int LightOn = 0;



#sectionstart object1_a  // DO NOT EDIT OR REMOVE THIS LINE
function object1_a() {
  // script for object1: Use inventory on object
AddInventory(2); 
}
#sectionend object1_a  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart hotspot1_a  // DO NOT EDIT OR REMOVE THIS LINE
function hotspot1_a() {
  // script for hotspot1: Interact hotspot

if (LightOn == 1) { // if light is turned on
  LightOn = 0; // turn light off
  SetBackgroundFrame(0); // display unlit room background
}
else { // if light is turned off
  LightOn = 1; // turn light on
  SetBackgroundFrame(1); // display lit room background
}
}
#sectionend hotspot1_a  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart room_b  // DO NOT EDIT OR REMOVE THIS LINE
function room_b() {
  // script for room: Player enters screen (before fadein)
if (LightOn == 1) // if light is turned on
  SetBackgroundFrame(1); // display lit room background
else // if light is turned off
  SetBackgroundFrame(0); // display unlit room background 
}
#sectionend room_b  // DO NOT EDIT OR REMOVE THIS LINE

SetCharacterView(TICA, 2);
AnimateCharacter(TICA, 0, 0, 1);
Title: Re: A non-blocking MoveCHaracter function
Post by: Candle on Sat 05/02/2005 02:05:44
hiram, I think you need to resize your sig . they told me that over 50 high is to big .
Title: Re: A non-blocking MoveCHaracter function
Post by: on Sat 05/02/2005 02:35:57
hiram, the reason it said "Unexpected SetCharacterView" is because

SetCharacterView(TICA, 2);
AnimateCharacter(TICA, 0, 0, 1);


isn't contained inside of a function.  All of your code has to be contained inside of some function for it to compile correctly except things like variable declaration (i.e., int buffer;).  You have to contain other things like variable definition (i.e., buffer = 67 % 5;) inside of functions.  I hope you can make some sense of my babbling.  I do this a lot. :=
Title: Re: A non-blocking MoveCHaracter function
Post by: Goot on Sat 05/02/2005 18:14:08
You want to put the script for animating the character inside player enters screen before fade in. function repeatedly_execute_always is a function only available in 2.62.
Title: Re: A non-blocking MoveCHaracter function
Post by: TerranRich on Tue 08/02/2005 02:53:23
Remember, all code has its place. Otherwise, the game has no idea WHEN to run it. Should AGS run it before any other code? After certain actions? Don't answer those; just keep them in mind when coding. Same goes for all of ya! :P
Title: Re: A non-blocking MoveCHaracter function
Post by: hiram on Tue 08/02/2005 08:55:17
First of all, sorry about the big pic in my sig, I took care of that.

Second, thanks for all the tips, I managed to figure out with your help
how to properly animate my characters and objects without stopping
the animation.  ;D

I was wondering, I saw somewhere in a tutorial or on this site that AGS's
scripting language is a C-style scripting language.  So I did a google search
and found a "c script" that is used in another game making engine.

Is AGS's scripting language similar to C/C++? Would I benefit if I studied
some books on C/C++?

Because there aren't a lot of tutorials on AGS scripting, I found just a few, and
I would like to go in depth of its syntax and rules, I'm very interested.
Title: Re: A non-blocking MoveCHaracter function
Post by: hiram on Tue 08/02/2005 10:24:21
I just found this:
http://csl.sourceforge.net/

So is this C scripting language the same as AGS's
scripting language? Or are they 2 completely different
things?
Title: Re: A non-blocking MoveCHaracter function
Post by: TerranRich on Tue 08/02/2005 14:33:59
Until the new Beta versions of AGS came out very recently, AGS had only been slightly similar to C. However, now that AGS will support structs and is more object-oriented in its coding design, it is more similar to C/C++ than ever before. So, yes. :)