Author Topic: agi noob  (Read 4602 times)

0 Members and 1 Guest are viewing this topic.

Offline Magnus Lee

agi noob
« on: November 23, 2003, 11:23:11 PM »
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.



Offline Nick Sonneveld

Re:agi noob
« Reply #1 on: November 24, 2003, 01:40:09 AM »
What kind of code have you got going at the moment?  can you paste some of the code for that room?

- Nick
Nick Sonneveld  |  AGI Dev  |  NAGI

Offline Sami Tervo

Re:agi noob
« Reply #2 on: November 24, 2003, 01:57:02 AM »
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
Apocalyptic Quest [ http://apocalypticquest.cjb.net ] No Mutants Allowed [ http://www.nma-fallout.com ] Batmud [ http://www.bat.org ]

Offline Joel

Re:agi noob
« Reply #3 on: November 24, 2003, 07:00:37 AM »
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:

Code: [Select]
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.
« Last Edit: November 24, 2003, 07:02:49 AM by Joel »

Offline Magnus Lee

Re:agi noob
« Reply #4 on: November 25, 2003, 03:16:03 AM »
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.

Offline Magnus Lee

Re:agi noob
« Reply #5 on: December 02, 2003, 03:25:38 PM »
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

  • Guest
Re:agi noob
« Reply #6 on: December 02, 2003, 04:32:25 PM »
Just add this to the code:
Code: [Select]
if (isset(f255)) {
  stop.cycling(star);
  reset(f255);
}
If this doesn't work, it's because the command's stop.cycle then.

Offline Magnus Lee

Re:agi noob
« Reply #7 on: December 02, 2003, 10:40:12 PM »
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.

Offline Allen

Re:agi noob
« Reply #8 on: December 03, 2003, 02:31:38 AM »
Try this.
Code: [Select]
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);
}
http://www.mizpro.co.uk
The new home of Mizar Productions.

It is a sign!

Offline Joel

Re:agi noob
« Reply #9 on: December 04, 2003, 04:40:57 AM »
The following complete logic source file works fine for me:

Code: [Select]
#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);
  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.
« Last Edit: December 04, 2003, 04:43:11 AM by Joel »

Offline Magnus Lee

Re:agi noob
« Reply #10 on: December 04, 2003, 11:28:56 PM »
joel did you mean to add that whole logic as my intro in logic.001?

Offline Joel

Re:agi noob
« Reply #11 on: December 06, 2003, 09:44:10 AM »
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.

Offline Magnus Lee

Re:agi noob
« Reply #12 on: December 07, 2003, 03:55:06 AM »
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?

Offline Oliver

Re:agi noob
« Reply #13 on: December 07, 2003, 06:45:54 AM »
v11 = 0;



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

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


that's how you do it ;)
You got it!
The New website of Extime is ready!
http://www.hot.ee/extime
Also, there is a message-board at:
http://www.zone.ee/eostuff/forum/index.php

Offline Joel

Re:agi noob
« Reply #14 on: December 07, 2003, 06:50:39 AM »
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:
Quote
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)
« Last Edit: December 07, 2003, 07:11:13 AM by Joel »


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.068 seconds with 22 queries.