SOLVED Help with: How to restore walkable areas while in other room

Started by beenf, Mon 04/04/2011 17:12:25

Previous topic - Next topic

beenf

So I wanna do an event where I use an item on an hotspot and walkable area restores in another room where the hotspot doesnt exist.

I tried a code like this
Code: ags

function hexample_UseInv()
if (player.ActiveInventory==iItem) {
  RestoreWalkableArea(2);
}

I see that it would restore the walkable are number 2 in the same room. But what code should I use so I could restore walkable area number 2 in room number 5 for example.
I hope someone can help

Sephiroth

Hello,

If you can't access the other rooms walkable areas then you may want to use a switch, basically it is just a global variable, you could use it like this:

-Create the global variable from the right panel in the editor, name it MySwitch -> INT -> default value 0
-When the player triggers the "restore area" event, you can put this:

Code: ags

if(MySwitch == 0)
 MySwitch = 1;


Now inside the target room "enters_room_before_fadein", the one where you have to restore the walkable area, put this:

Code: ags

 if(MySwitch == 1)
 {
   RestoreWalkableArea(2);
   MySwitch = 2;
 }


The walkable area should be restored next time you enter the room, and everything will only be triggered once. Hope it helps.


beenf

Ooops. I noticed that the rooms walkable area is also walkable when I havent triggered the switch.
What do i do?

Sephiroth

Inside the same "enters_room_before_fadein" you could put that instead:

Code: ags

 if(MySwitch == 0)
 {
   RemoveWalkableArea(2);
 }
 else if(MySwitch == 1)
 {
   RestoreWalkableArea(2);
   MySwitch = 2;
 }


Also you can edit your post with the modify button to avoid double-posting :)

This should do the trick, hopefully.

beenf

Yay, I got it working !
Thnx

But I'm also having problems with my cutscene.
I wan't it so when the game would start different pictures would come one after another.

this is what I did so far.
Code: ags

function load_AfterFadeIn()

{
  StartCutscene(eSkipAnyKey);
  Mouse.Visible=false;
  Wait (40);
  Mouse.Visible=true;
  player.ChangeRoom(9, 111110000, 1111111);

  EndCutscene();
    }

did it by following a tutorial

Sephiroth

I'm sure this subject has been covered many times, anyways you could create a GUI that is exactly the size of the screen, import the differents pictures as sprites, make player start in empty room with the gui ON, then use something like :

Code: ags

 MyGui.BackgroundGraphic = imported_sprite_number_1;
 WaitKey(40*10); //10 seconds with GameSpeed=40
 MyGui.BackgroundGraphic = imported_sprite_number_2;
 WaitKey(40*10);
 MyGui.BackgroundGraphic = imported_sprite_number_3;
//and so on
 MyGui.Visible = false;
 player.ChangeRoom(2, 300, 100);


player.ChangeRoom() needs valid X,Y coordinates, I highly doubt "111110000, 1111111" are valid. This is just one way to do it.

beenf

Code: ags

// room script file



function room_AfterFadeIn()
{
gGui1.BackgroundGraphic = 41;
 WaitKey(40*10); //10 seconds with GameSpeed=40
 gGui2.BackgroundGraphic = 42;
 WaitKey(40*10);
 
 gGui3.BackgroundGraphic = 43;
 
//and so on
  gGui1.Visible= false;
 gGui2.Visible = false;
 gGui3.Visible = false;
 player.ChangeRoom(1, 160, 160);
}


I did this and when I tested the game it would start as a black window, waited a second and last gui (the picture) showed up. And nothing happened from that forward. It didn't go to the next room or anything

Sephiroth

I think you misunderstood something, the gui that displays the pictures is always the same, so you only need one gGui1, then reuse :

gGui1.BackgroundGraphic = 42;
gGui1.BackgroundGraphic = 43;

You may want to check that the created gui is visible by default, or that you used gGui1.Visible = true; before.

Are you sure player should be transported to Room 1 after that? Maybe wrong number?

Khris


beenf

Thnx it worked now

Edit: Ohh I have a silly problem now. How can I create the game now so I could share it to my friends and they could play it without having ags?
I didn't found any tutorial teaching me that

Sephiroth

I think if you needed AGS to play AGS games CJ would be flooded with complaints/requests :p

+1 for the use of modify button!

Khris

There aren't tutorials for everything because many things are already explained in the manual, if you can believe that.
http://www.adventuregamestudio.co.uk/manual/DistGame.htm

Also, I'd still like the link to the tutorial that tought you to use player.ChangeRoom(9, 111110000, 1111111);

And please, take a deep breath now and stop posting about every single little thing you get stuck with. It's obvious that you are the kind of ambitious, probably young, impatient, "can't be bothered to figure things out by themselves" guy we've already seen so many come and go here.
Check the resources and do basic programming tutorials for Java or C++; AGS isn't Game Maker, you'll need a few weeks at least to get the hang of it.

beenf


SMF spam blocked by CleanTalk