agi noob

Magnus Lee Hello, I'm new to the whole agi thing.. I've been trying to make a game but I'm haveing a problem with my intro... I'm trying to animate a view on the screen once to were it stops on the last cel and stays on the screen.. if anyone would be so kind as to help me out or give me a little advice i would be very greatful, thanks.
sonneveld What kind of code have you got going at the moment? can you paste some of the code for that room?

- Nick
Sami_Tervo So you want view to stop cycling once the last cel is reached eh..Well there's few ways to do this (though one is enough and best, I just want to expand your knowledge! :)):

1:

Use current.cel();-command in order to find out which cel is going and set up an if-ambush!

current.cel(o1,v40);
if(v40 == lastcel){stop.cycling(o1);}

2:

Or the boring common way by using end.of.loop(oA,fB);-command:

end.of.loop(o1,f255);

Note: Unlike current.cel, end.of.loop should be put into if(newroom)-part of the code.

Good luck! ;D
Joel Just to make sure it's clear that this thing isn't constrained and almost useless, end.of.loop doesn't have to appear in the new room section. It just needs to appear inside an if-statement that will execute once and only once instead of every interpreter cycle. For example, this code is from Jen's Quest:


if (said("open", "door"))
{
if (posn(ego,
JENS_ROOM_DOOR_RANGE_X1, JENS_ROOM_DOOR_RANGE_Y1,
JENS_ROOM_DOOR_RANGE_X2, JENS_ROOM_DOOR_RANGE_Y2))
{
// attempting to open the door to Jennifer's room
stop.motion(ego);
program.control();
prevent.input();
nCurrentDoor = JENS_ROOM_DOOR;
end.of.loop(oJensRoomDoor, bDoorDoneOpening);
}
else
{
print(MSG_NOT_CLOSE_ENOUGH);
}
}


Sorry if there's weird indenting. This code isn't actually a direct copy and paste. Sort of a pieced together job.
Magnus Lee Hey, well this is what I have been working with so far but I'm not too sure what I'm doing yet I've been looking at the way other people have made their games and trying to work with it

load.view(2);
animate.obj(o1);
set.view(o1,2);
set.loop(o1,1);
set.cel(o1,2);
cycle.time(o1,v254);
start.cycling(o1);
ignore.objs(o1);
position(o1,57,109);
draw(o1);


by the way thanks very much for all your advice so far guys i'm going to try out some things you guys said and maybe i'll get a better idea.
Magnus Lee ok guys i'm haveing a problem with this still

animate.obj(star);
load.view(2);
set.view(star,2);
set.loop(star,0);
ignore.objs(star);
position(star,31,137);
draw(star);
end.of.loop(star,f255)

i try it out and it doesint animate the view its just on the last cel and doesint move.... i'm guessing its something to do with the flag..i'm not sure how to set a flag so can someone help me out with understanding how to set this f255 flag so it will animate and stop on this last cel
thx for any help or advice you can give me
Kon-Tiki Just add this to the code:

if (isset(f255)) {
stop.cycling(star);
reset(f255);
}

If this doesn't work, it's because the command's stop.cycle then.
Magnus Lee ok i've tryed that but i must have done something wrong in it somewhere... this is what i have exactly so far....

if (new_room) {
load.pic(room_no);
draw.pic(room_no);
discard.pic(room_no);
set.horizon(37);
status.line.off();
prevent.input();
program.control();
show.pic();

animate.obj(star);
load.view(2);
set.view(star,2);
set.loop(star,0);
ignore.objs(star);
position(star,31,137);
draw(star);
end.of.loop(star,f255);
}

if (isset(f255)) {
stop.cycling(star);
reset(f255);
}


ok i did this code and the view loads on the screen and its just on the last cel still and doesint animate so the only thing i could think of was useing set(f255); afrer the end.of.loop but if i do this it will load the view on the screen but it will be on the first cell instead of the last and still doesint animate... so maybe i used the set(f255) in the wrong place? i've no clue can someone help me out please.
rwfromxenon Try this.

if (new_room) {
load.pic(room_no);
draw.pic(room_no);
discard.pic(room_no);
set.horizon(37);
status.line.off();
prevent.input();
program.control();
show.pic();

animate.obj(star);
load.view(2);
set.view(star,2);
set.loop(star,0);
ignore.objs(star);
position(star,31,137);
draw(star);
start.cycling(star);
end.of.loop(star,f255);
}

if (isset(f255)) {
stop.cycling(star);
reset(f255);
}
Joel The following complete logic source file works fine for me:


#include defines.txt

if (new_room)
{
v255 = 3;
load.pic(v255);
draw.pic(v255);
discard.pic(v255);

status.line.off();
prevent.input();
program.control();

set.horizon(37);

show.pic();

animate.obj(o1);
load.view(2);
set.view(o1, 2);
set.loop(o1, 0);
ignore.objs(o1);
position(o1, 31, 137);
draw(o1);
end.of.loop(o1, f255);
}

if (f255)
{
reset(f255);
print("loop done");
status.line.on();
accept.input();
player.control();
}

return ();


It's not necessary to issue a stop.cycling command when the loop is done. And it's not necessary to issue a start.cycling command to get it started. Also, the call to end.of.loop should reset f255 immediately and then set it when the loop is done. If you want to be sure, you can try reset(f255) before calling end.of.loop, but I don't think it's necessary, because I tried both setting and resetting f255 before the call and it didn't make any difference to whether the code worked or not.

Have you tried putting this in a logic by itself? It seems likely to me that there is something else in your code that is causing the problem.
Magnus Lee joel did you mean to add that whole logic as my intro in logic.001?
Joel I mean create a completely new logic and put only the code for doing the end of loop thing in there. Then see if that works (use the debug command "tp" to go to the room). If it does work, then there's probably something in your other logic interfering with the end.of.loop.
Magnus Lee whew, i finally found my problem guys.. just wanted to thank you for your help everyone

are there any commands for timers? like useing the display command to make text come up and make it stay there for just so much time before the other text pops up?
Oliver v11 = 0;



}
if(v11 == 3){
print("bla bla bla");

}
if(v11 == 5){
print("another bla bla bla");


that's how you do it ;)
Joel depends on what you're trying to time. In general, no there are no timers. There is a way to leave windows on the screen for a specific length of time, though. From the AGI Studio help files on the print function:

Description

Message A is displayed in a window. If f15 is not set, then the window remains for 1/2 * v21 seconds (provided v21 is greater than 0) or until a key is pressed. If f15 is set, then the window remains until a close.window command is issued.


f15 is windows_remain and v21 is window_close_time in the template game's defines.txt.

I guess that means all you need to do is set window_close_time to the number of half-seconds that you want the window to remain on the screen.

(edit: Oliver posted while I was writing my response -- I guess there is a timer you can use if you don't mind messing with the AGI system clock, but for the print windows, the way I mentioned is probably the best one, if it works)
Magnus Lee are there any commands to clear the screen?
i'm useing the display command to make some text come up on the screen and after so much it plays a view but i'm wanting to make the text and the view go away now to add a diff view and more text.. any good advice or commands to go about doing this without just useing a diff logic...?
Eigen To erase object from screen use erase(objectNum);

To clear screen from displayed texts use clear.lines(1, 24, 0); It ereases all text from the line 1 to 24 with black color



-Eigen