Objects globally... and more (suggestion)

Started by Ishmael, Fri 05/03/2004 16:29:36

Previous topic - Next topic

Ishmael

I was thinking... There is sometimes need to turn on or off an object in another room. So, I was thinking if it would be possible to implement a new global variable, like room[ROOM].object[OBJ] which would set the specified room's specifed object off or on, depending on if this varable is zero or not.

Also, the room struct could include other vars, like room name, edge cordinates, hotspot's on or off, etc. If possible to implement, and found usefull.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

RickJ

#1
You can do that already using structs.  

[edit]
Here is an example of what I mean.  I am at work so I can't test/debug for you.

Global Script
   // Define your own data type using struct
   struct  ROOM_DEF {
      int object[15];
      int hotspot[15];
   }

   // Define the Room variable
   ROOM_DEF Room[300];

   // Make it available globally
   export Room;


Script Header
   // Make it available globally
   import Room;


Room Script

   // Any function you wish
   funcion any() {
      int var;

      // Example usage of Room struct
      Room[1].object[2]=1;
      var = Room[1].object[2];
   } 

Pumaman

The problem is there's no way to for AGS to know things like whether object 2 in room 57 is initially turned on or off, until it actually loads the room.

So what you ask would be possible, but it would mean AGS would have to scan through every room file at startup, which would be very slow.

Ishmael

Hmmm... yeah, I never thought about that...  well, this could automatizise (sp) the GlobalInt using thingy, right? So instead of checking the globalints or whatever variables you use, and turning objects on or off by script, AGS would do it automatically. Like, when you enter room 13, AGS checks if the object definatios in room[13] are on or off, and if the objects exist in the room, AGS turns them on or off regarding the variable state... Just a thought...
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Pumaman

Yeah, it'd be possible to have some sort of SetObjectOn(Room, Object) to force it on, but it wouldn't be possible to have a GetObjectOn(Room, Object) feature.

Kweepa

You could extend RickJ's idea by adding EnteredRoom() to the before fade in of every room you have. EnteredRoom() would check the struct looking for objects to turn on and off. SetObjectOn(int room, int object) would also set a flag in the struct to indicate a change (or the struct could be a stack of changes). Similarly for hotspots, walkable areas, etc.
Still waiting for Purity of the Surf II

a-v-o

If you implement a SetObjectOn (Room, Object), then you will probably write this information into a global 2-dimensional array of boolean values.

For GetObjectOn (Room, Object) the problem are the values at game start. This could be handled in runtime at game start or at compile time where code for initialization of the (above mentioned) array is created.

On the other hand "global objects" (objects which can be picked up in one room and dropped in any other room) which were wanted in an other thread would also be a solution because they should also be managed independent from rooms. OOP might be an answer: objects are handled like characters.

Just some cents from a programmer who needn't program these ideas  ;D

SMF spam blocked by CleanTalk