Author Topic: Logic Help: Logic calls  (Read 2301 times)

0 Members and 1 Guest are viewing this topic.

Offline Jelle

Logic Help: Logic calls
« on: August 22, 2002, 05:55:03 AM »
Hello,
My name is Jelle and I'm working on an AGI-game. Until now everything went just fine, but I want my code to be well-structured. I wanted some birds to fly around in allmost every room, so I put the birds in one logic file (no=110) and I put a logic call in every other room ( call(110); ). This is my code:


Code: [Select]

//Logic 110: code for the birds
#include "defines.txt"
#define bird_1 o10
#define bird_2 o11
#define bird_3 o12

if(isset(new_room)){
 load.view(44);
 set.view(bird_1,44);
 set.view(bird_2,44);
 set.view(bird_3,44);
 animate.obj(bird_1);
 animate.obj(bird_2);
 animate.obj(bird_3);
 ignore.horizon(bird_1);
 ignore.horizon(bird_2);
 ignore.horizon(bird_3);
 random(0,80,v100);
 random(0,30,v101);
 position.v(bird_1,v100,v101);
 random(80,160,v100);
 random(0,30,v101);
 position.v(bird_2,v100,v101);
 random(40,120,v100);
 random(0,30,v101);
 position.v(bird_3,v100,v101);
 draw(bird_1);
 draw(bird_2);
 draw(bird_3);
 wander(bird_1);
 wander(bird_2);
 wander(bird_3);
}
return();



Code: [Select]

//Other rooms
#include "defines.txt"

if (new_room) {
 load.pic(room_no);
 draw.pic(room_no);
 discard.pic(room_no);
 set.horizon(68);

 // blablabla

 call(110);

 draw(ego);
 show.pic();
}

//blabla

/*if (v2==1) {new.ro__blabla
blabla
blabla
blabla__om(7);}*/

return();


When I play my game, everything goes wrong! The rooms are ALL GREEN AND IT'S JUST ONE MESS!!! Nothing works (I can't even quit my game.) But when I put the code from logic 110 in every room, there's no problem at all...

- I looked at the code of Space Quest II (logics: 13,14 & 15 for the rooms and logics 107 & 108 for the 'animal-animation-code'). -

Does anybody know what I am doing wrong?
Thanks

(sorry for my bad English)


Politics is supposed to be the second-oldest profession. I have come to realize that it bears a very close resemblance to the first.

Joey

  • Guest
Re:Logic Help: Logic calls
« Reply #1 on: August 22, 2002, 07:13:45 AM »
I had the same problem. When you cant even quit, I believe it is a memory issue. I had the same thing happen, and I still havent fixed it. You may want to fix the wander code. That will make them go all over the place, even on the ground and stuff. (Unless you put a priority line up in the sky and positioned the birds up there.) I dont know what would be wrong. If you cant quit, you may have too many things loaded.

Offline Jelle

Re:Logic Help: Logic calls
« Reply #2 on: August 22, 2002, 09:59:08 AM »
I don't think it's a memory issue, I rather think it's one of those non-ending-loops or something... The wander-around-stuff works fine, no problem with that... When I put all of this junk into one Logic it works just fine, but it may be easyer to put the birds in a different logic. Then I just have to put a 'call(no);' in all the logics of the rooms I want those birds in.
Politics is supposed to be the second-oldest profession. I have come to realize that it bears a very close resemblance to the first.

Offline Nick Sonneveld

Re:Logic Help: Logic calls
« Reply #3 on: August 22, 2002, 10:15:15 AM »
You say the rooms are all green..  is this before or after you put call(110) in your code?  are you saying the background is green but the birds look ok?

have you tried with just one bird?

- Nick
Nick Sonneveld  |  AGI Dev  |  NAGI

Offline Cosmic R

Re:Logic Help: Logic calls
« Reply #4 on: August 22, 2002, 10:18:19 AM »
Not sure if this is the problem, but try putting call(110) after the line show.pic().

Offline Nick Sonneveld

Re:Logic Help: Logic calls
« Reply #5 on: August 22, 2002, 10:26:31 AM »
I thought it might be that.. but all it does it just make the picture buffer visible..  the views should still be added to the  picture buffer even if it's not visible.

If you show the picture after, you prevent all the sprites "popping up"

- Nick
Nick Sonneveld  |  AGI Dev  |  NAGI

Offline Jelle

Re:Logic Help: Logic calls
« Reply #6 on: August 22, 2002, 10:52:15 AM »
I've found the error: before I call logic 110, I need to load every view used in logic 110... Something like this:

Code: [Select]

if(isset(new_room)){
 load.pic(room_no);
 draw.pic(room_no);
 discard.pic(room_no);
 set.horizon(68);

 load.view(44);   // <---- I added this line and everything works fine now
 call(110);

 draw(ego);
 show.pic();
}



Thanks anyway


BTW: How does the attach-stuff work on this board? Is there a hidden upload-button or something? The only button I see is Browse.
Politics is supposed to be the second-oldest profession. I have come to realize that it bears a very close resemblance to the first.

Offline Nick Sonneveld

Re:Logic Help: Logic calls
« Reply #7 on: August 22, 2002, 11:05:50 AM »
ohh.. of course.. that makes sense.  I should have noticed it.

- Nick

Nick Sonneveld  |  AGI Dev  |  NAGI

Offline Jelle

Re:Logic Help: Logic calls
« Reply #8 on: August 22, 2002, 11:11:50 AM »
Could you explain me why it makes sense? Because I found that out by mistake... Why should I load the views in the rooms, why can't I load them in logic 110?
Politics is supposed to be the second-oldest profession. I have come to realize that it bears a very close resemblance to the first.

Offline Nick Sonneveld

Re:Logic Help: Logic calls
« Reply #9 on: August 22, 2002, 11:27:35 AM »
ah.. it gets complicated.  Basically, everything gets loaded onto a stack, and when you discard something, everything on top get's discarded as well.

ie, the memory would be something like this:

LOGIC0 -> EGO -> LOGICX -> LOGIC110 -> VIEW44

this is in your old code, just after you load view44.  LogicX is the other logic code.

when you return back to logicX, it just discards logic110.. but this means view44 is also discarded.. but it still hangs around in memory.  

LOGIC0 -> EGO -> LOGICX -> <gap> VIEW44

this actually works since it's still in memory UNTIL you load something else in logicX, then it will overwrite view44 and your view will get corrupted.

so say you had:

 call(110);
 load.view(10);
 load.sound(50);
 draw(ego);
 show.pic();

the memory would be:

LOGIC0 -> EGO -> LOGICX -> VIEW10 -> SOUND50

but your animated objects will still think view44 is in memory and trying to point to it.  however view44 has been overwritten.

so anyway.. if you load view44 beforehand, when you discard logic110, view44 will still be in memory

LOGIC0 -> EGO -> LOGICX -> VIEW44

I hope that makes sense.

- Nick
Nick Sonneveld  |  AGI Dev  |  NAGI

Offline Nick Sonneveld

Re:Logic Help: Logic calls
« Reply #10 on: August 22, 2002, 11:30:27 AM »
Another solution, so you can load your views in a separate logic, is to manually load the logic before you call it.  That way the logic still hangs around in memory afterwards.

The default with call() is to load and discard the logic if it isn't in memory already.

- Nick
Nick Sonneveld  |  AGI Dev  |  NAGI

Offline Jelle

Re:Logic Help: Logic calls
« Reply #11 on: August 22, 2002, 12:16:20 PM »
Thanks a lot! I know the stack-stuff, but I hadn't thought of it at all. When I look at the real sierra games, they actualy do load the logics before calling them,... like you said.

The only problem I'm dealing with at the moment, is that the fix.loop doesn't seem to work in the sub-routines (like my 110), but there's probably a minor bug that ruins everything. I'll look for it myself.


THANKS FOR YOUR HELP
Politics is supposed to be the second-oldest profession. I have come to realize that it bears a very close resemblance to the first.


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

Page created in 0.047 seconds with 18 queries.