Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: keeping changes throughout rooms? (ids?)  (Read 1543 times)

0 Members and 1 Guest are viewing this topic.
keeping changes throughout rooms? (ids?)
« on: October 07, 2007, 07:01:57 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 57
Ok I'm having this problem with chests. The chests that Link opens and gets items from. Right now I'm only using one item for the chest, placing it in the room, and then using a script that checks the id to know what item to give link.

The problem is when I go to the next room and come back the chest is unopened. I'm not sure how to keep them opened because it seems like I need a global variable to stay in play during the room switches, but it also seems like I need a local variable because each chest is independent from one another.

How would I be able to have the chests that Link has opened stay opened when he leaves and returns to a room? Keep in mind that right now the chest object is just one object.
« Last Edit: October 07, 2007, 07:20:57 pm by ClamyD »
Logged
Re: keeping changes throughout rooms? (ids?)
« Reply #1 on: October 07, 2007, 07:37:34 pm »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Posts: 728
Will marking the object persistent help?
Logged
  • Pyxosoft
Re: keeping changes throughout rooms? (ids?)
« Reply #2 on: October 07, 2007, 07:51:42 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 57
I tried that and when other rooms were loaded the chests were appearing in those rooms.
Logged
Re: keeping changes throughout rooms? (ids?)
« Reply #3 on: October 07, 2007, 08:03:44 pm »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Posts: 728
Looks like global variables are neccessary. One for every chest. This is standard is it not?
You'd check the global (Most likely a boolean value) in the create event, then set the graphic and behavior accordingly.
« Last Edit: October 07, 2007, 08:06:00 pm by Xfixium »
Logged
  • Pyxosoft
Re: keeping changes throughout rooms? (ids?)
« Reply #4 on: October 07, 2007, 08:08:09 pm »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6629
If you can generate a unique ID for each chest (dunno about GM, but you could have one as a string in this format - map_name+"-"+chest_x+"-"+chest_y) this is pretty easy to do. Once you've generated a unique ID all you need to do is create a global list somewhere then when you open one you place the unique ID into the list. When you create the chest all you then need to do is check if its unique ID is in the list, if it is you set the chest to open.

Thats may be overcomplicating things in GM, I don't know how GM deals with this kind of thing.
Logged
Re: keeping changes throughout rooms? (ids?)
« Reply #5 on: October 07, 2007, 08:23:20 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1141
Use an global array variable for that.
Like:

global.chest_is_opened[25]=true;

Use true for opened and false for closed.
Then you must have a number (25 in the example) to represent the "ID" of the chest. But note that GM also have an "ID" for all the instances of the game.
So in the create event of the chest you have something like this:

if(id==1000135)chest_id=0;
if(id==1000222)chest_id=1;
if(id==1000168)chest_id=2;
if(id==1000521)chest_id=3;
(...)

You can view the ID of each instance by passing the mouse over it in the room where the instance is.

Well, and then, when you enter the room, you use this code:

if(global.chest_is_opened[chest_id]) //because you've already defined chest_id in the create event of the instance
{
 //OPEN CHEST
}
Logged
Re: keeping changes throughout rooms? (ids?)
« Reply #6 on: October 07, 2007, 09:15:01 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 57

So in the create event of the chest you have something like this:

if(id==1000135)chest_id=0;
if(id==1000222)chest_id=1;
if(id==1000168)chest_id=2;
if(id==1000521)chest_id=3;
(...)




Could I possibly control + right click the instances in the room editor and define the chest_id variable in their creation code instead for this step?
Logged
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.312 seconds with 52 queries.

anything