View not changing on region when eblock is used.

Started by RetroJay, Thu 03/06/2010 23:00:58

Previous topic - Next topic

RetroJay

Hi Good peeps.
Hope you are all well.

I am still using AGS 2.72 (for this project)

Ok. I have a room where half is pitch black and half is light.
Now I have covered the dark side with a region and created the script for when the character walks onto this region.
What happens is the character view changes to just a pair of eyes in the darkness and then when he walks off the region the view changes to his normal view.
This works beautifully.

Now for the problem.
In your inventory you have a flashlight which you use on the dark side of the room. I wish for the character to walk into the darkness and use the light.
However. If I set coords for him to walk to using 'eblock' his view does not change on the dark region.
I want him to automaticaly walk into the darkness and use the light cos it looks wierd if he uses the light on the light side of the room.

If I could just get this to work then the section of game I am working on would be complete.
Many thanks.

Jay.

Khris

In repeatedly_execute_always, check for the region at the player's feet and switch the view manually.

RetroJay

Hi Khris.

Thank you for your reply.

Sorry to be a pain in the arse.
How do I check for the region at the players feet? :-[

I have been buggering about for ages now and have got nowhere. ::)
This is something new you may be able to explain to me!!

Thanks.

Jay.


Khris

You aren't a pain in the arse, people ask much worse questions here ;)

You need to use
  if (Region.GetAtRoomXY(player.x, player.y) == region[1])

RetroJay

Hi Khris.

Sorry I have been a while replying.
I tried the script you gave me but all it did was make the player character
move like grease lightening across the screen when he walked onto the region.

Here is the script I have so far which works well.

Code: ags

  // script for Region 3: Player walks onto region
if(player.View == 2){
  character[SHADOW].ChangeView(14);
  character[EGO].ChangeView(29);
  character[EGO].SpeechView = 19;
  character[EGO].BlinkView = 23; 
}

else{
  character[SHADOW].ChangeView(14);
  character[EGO].ChangeView(3);
  character[EGO].SpeechView = 19;
  character[EGO].BlinkView = 23; 
}


  // script for Region 3: Player walks off region
if(player.View == 29){
  character[SHADOW].ChangeView(13);
  character[EGO].ChangeView(2);
  character[EGO].SpeechView = 30;
  character[EGO].BlinkView = 31; 
}

else{
  character[SHADOW].ChangeView(13);
  character[EGO].ChangeView(1);
  character[EGO].SpeechView = 22;
  character[EGO].BlinkView = 24; 
} 


This is the code for the 'darkness' hotspot.
Code: ags

  // script for Hotspot 1: Use inventory on hotspot
if(player.ActiveInventory==inventory[13]){
  character[EGO].Walk(160, 194);
}
}


The problem is as I said in my first post. I would like to use for the 'darkness' hotspot 'eBlock' like so...

Code: ags

  // script for Hotspot 1: Use inventory on hotspot
if(player.ActiveInventory==inventory[13]){
  character[EGO].Walk(160, 194, eBlock);
}
}

Whenever I do though the region script is ignored and the player character doesn't change view.
What am I doing wrong?

Many thanks.
Jay.

Creator

Whenever eBlock is used, it blocks every other scripts (except those is repeatedly_execute_always) until that line of code is finished. In this case, the region codes will not run until the character reaches their destination.

What exactly happened when you used Khris's code, and where did you put it?

RetroJay

Hi Creator.

I made the 'Function Repeatedly_execute_always' at the bottom of my room script and put Khris's code there.
I then, as you can see above, changed views manually.
However. All that happens is once the character walks onto the region he gets stuck on the 1st frame of view and travels to the destinatin coords
at great speed.

Without knowing why it was doing this I had to, finally, abandon this and re-think my room.

I have now managed to get things to work.
Not quite how I wanted them to but hey...it works.

Thank you both for your help.
Jay.

P.s. If you can see an obvious error on my part then please let me know.

SMF spam blocked by CleanTalk