making a door with interruption

Started by Mikey, Wed 22/04/2009 21:18:06

Previous topic - Next topic

Hudders

It's because you haven't defined

Code: ags
int door;


in the global script.

thezombiecow

Define door as a global int in the GlobalVariables section in the right panel...

Trent R

Not global script, he's talking about the Global Variables pane that can be found in the Tree on the right (or left) of the editor.

But I'm wondering why you're being told to even do that. Do you use door in any other room? If not, just keep it at the top of your room script.

~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

thezombiecow

QuoteBut I'm wondering why you're being told to even do that. Do you use door in any other room? If not, just keep it at the top of your room script.

I was only really suggesting it as a quck test to see if setting it at the top of the room script is somehow continually resetting it to 0...

I'm not in front of AGS, so I can't test this end. I wasn't expecting it to turn into a big thing. ;)

Trent R

IIRC, defining at the top outside of any function should make it that value and keep it that way. Such a thing might come up if the room# was above 300 (ie. won't save the state of the room).

PS-Didn't mean to bash you, I understand what you're saying now. :) Friends?

~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune


Mikey

#26
lol only just realised there was a page 2. ye i defined it as int door in the global variales but that still didn't affect it. COME ON GUYS PUT YOUR HEADS TOGETHER  :P

what is happening so far is the character walks to the door and just stands on the set coordinates and doesn't open it. I would upload a rar of it if you guys are up for messin' around to see what is wrong.

Trent R

Assuming your code is still the same as this post... You have two problems.

1) You're checking the wrong coordinates, Hudders already mentioned this.

2) door variable doesn't equal 1, thezombiecow mentioned this.


So what's the problem?

~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Sephiroth

#28
Hi,

Maybe you could use something like this:

If there's some kind of Player.IsStandingOnHotspot(hotspot_id) then replace the if statement with it. Or you'll have to use "top, left, bottom, right" with room coords to create a hotpsot.

Code: ags


function door_interact()
{
 if(Player.x >= left  && Player.x <= right && Player.y >= top && player.y <= bottom) 
 { 
   Door1.visible = false;
   Door2.visible = true;
   Wait(10);
   Player.ChangeRoom(7);
 }
 else
 {
  Player.Walk(X,Y,eNoBlock); //X and Y are room coords inside the hotspot
 }
}



This way the player will start walking to the door and will only open it when he uses interact while standing on the hotspot.The only problem is that you'll have to click one time to get to it and once more to open it. Or just one time if you're already standing there.

Mikey

Quote from: Trent R on Sat 25/04/2009 03:08:48
Assuming your code is still the same as this post... You have two problems.

1) You're checking the wrong coordinates, Hudders already mentioned this.

2) door variable doesn't equal 1, thezombiecow mentioned this.


So what's the problem?

~Trent

yeah i replied to both those posts saying yes i already have changed them to the correct script like i already changed the x and y around and what about the door not equaling 1? the variable default is set to 0 at start and is supposed to be changed when clicked interact on the door and changed back to 0 when i click elsewhere.

The problem is i want the character to be able to select interact with the door without the eblock causing the mouse to disappear and the character not to be able to cancel the interact with door action while walking towards it. Now the character just walks towards it stands on the coordinates and doesn't do anything.
Quote
Hi,

Maybe you could use something like this:

If there's some kind of Player.IsStandingOnHotspot(hotspot_id) then replace the if statement with it. Or you'll have to use "top, left, bottom, right" with room coords to create a hotpsot.

Code:
Code: ags


function door_interact()
{
 if(Player.x >= left  && Player.x <= right && Player.y >= top && player.y <= bottom) 
 { 
   Door1.visible = false;
   Door2.visible = true;
   Wait(10);
   Player.ChangeRoom(7);
 }
 else
 {
  Player.Walk(X,Y,eNoBlock); //X and Y are room coords inside the hotspot
 }
}


This way the player will start walking to the door and will only open it when he uses interact while standing on the hotspot.The only problem is that you'll have to click one time to get to it and once more to open it. Or just one time if you're already standing there.

Hi
That would be almost as lame as the mouse disappearing with the eblock. Thanks anyway though. I think i am going to just make my game normally with the eblock and hopefully someone makes a module for the verbcoin gui later on *cough* khris ;)
But yeah don't worry about it because it looks like as thingymebob said it would be crazy as the code would get really big and messy.Thanks anyway people.

Trent R

I haven't looked at Khris's code, but it'd definitely be the best solution.

Another idea, but would create some quirky behaviour, is to add something to the on_mouse_click like
Code: ags
if (player.Moving) player.StopMoving();


But, that would probably create more confusion for the player than it would solve.



~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

SMF spam blocked by CleanTalk