Going back to a room you have allready visited [SOLVED]

Started by Bhup, Wed 05/01/2005 17:26:58

Previous topic - Next topic

Bhup

I am probably going to be told that this explanation allready exists but I have tried and I have a limited budget...err can't be online to long.

Problem: As title suggests How do I go back to a room that I have allready been to? I am in room 3 and want to go 'back' to room 1.  I have created a hotspot in room 3 just before the exit back to room1.
I used ther following command : Player - Go to a different room(1,100,100).

But when I ran the game the character went through to room 3 from room1 and went right back out again back to room1 .

I can see why this happened so I tried using:
if (!(HasPlayerBeenInRoom(1))){
   NewRoomEX(1,100,100);
}

This allows the character to go into room 2 but does not allow it to go back to room 1.

Again I can see why but I am wandering wheterh I am missing the obvious.

Could someone please help.
Bhup

jrl2222

Only a guess here but you may have the player character going to room 3 and starting out on the hotspot? That would be the obvious thing.

What do you have as the script for your room 1 exit?

Bhup

#2
To jrl2222,
Quote
What do you have as the script for your room 1 exit?Ã, 

The code I have for the hotspot which exits to room 3Ã,  is not a script command.Ã,  It is simply the option chosen from the the hotspot interaction menu. It is: Player - Go to a different room (at specified coordinates)(3,232,168).

Quote
Only a guess here but you may have the player character going to room 3 and starting out on the hotspot? That would be the obvious thing.

Could you please expand on this...I'm not quite sure what you mean.

Oh yes one more thing.Ã,  In rooms 1,2 and 3 the inventory window seems ok and displays the items properly so that they all show but in room 4 my inventory window spans across the from left to right so much that you can't see any of the items on either end as they are only half showing.Ã,  How can make my inventory window display all the items I want to display so that they all show properly.

ThanksÃ,  Ã, :)

Bhup

Gilbert

Try using:
if (HasPlayerBeenInRoom(1)==0){
Ã,  Ã, NewRoomEX(1,100,100);
}

instead.
As far as I remember CJ was too lazy to make the scripting engine completely on par with the C implementation, so the if (!variable)... part may not work (well don't know if this had been fixed or not though).

Bhup

To Gilbot,
Thanks for the reply. Ã, I tried what you said and used :

Code: ags

if (HasPlayerBeenInRoom(1)==0){
 Ã,  NewRoomEx(1,100,100);
}


This is on the hotspot in room 3 which is on the entrance of room 3. I can go into room 3 but still cannot go back to room 1 from room 3. Ã, Basically whatever room I am in I would like to go back to the room I came from. Ã, Is this possible???

Also would you or anyone be able to answer some more stuff..stuff that I mentioned previously:

Quote
Oh yes one more thing. Ã, In rooms 1,2 and 3 the inventory window seems ok and displays the items properly so that they all show but in room 4 my inventory window spans across the from left to right so much that you can't see any of the items on either end as they are only half showing. Ã, How can make my inventory window display all the items I want to display so that they all show properl???.

from Bhup Ã, :)



Ashen

First off, I have no idea about the inventory thing, sorry.

Secondly, I don't know if I fully understand your other problem, but:
1) The code you've got now would only send the character to room 1 if they'd never been there ( if (HasPlayerBeenInRoom(1)==0)) which would never be the case if they've come from room 1 in the first place, which is probably why it doesn't work.

2)
QuoteBasically whatever room I am in I would like to go back to the room I came from.
Is the character[CHARID].prevroom variable what you're after? It stores the last room the character was in, so:
Code: ags

NewRoomEx (character[EGO].prevroom, 100, 100);

would send them to room 1 if that was where they came from, to room 2 if that was, to room 27 if that was, etc.
I know what you're thinking ... Don't think that.

Bhup

To Ashen,
A million thanks!!!!!!!!! You have given me exactly what I was looking for:
Code: ags

NewRoomEx (character[EGO].prevroom, 100, 100);



Shame you or anyone else can't answer my inventory problem.  (She says, as if you haven't allready helped me out allready.)   ;D

When I run the game and display my inventory window by the time I have reached room 4.  The  items in the inventory at each end, go off the screen. What can I do to avoid this?

Any takers???
Bhup


Bhup

Can some one tell me how to attach/upload images with my the post/reply.  I want to show an image to describe my problem. I could not do it before as when I used Alt printscrn it just showed a black screen.  Anyway I have had to recreate the problem using photoshop. Now I have an example.  Can anyone help please?
Bhup


strazer

Use http://www.2dadventure.com/ags/upload/upload.html to upload your image (please use jpg or gif format) and then enter
Code: ags

[img]http://www.2dadventure.com/ags/yourfilename.jpg[/img]

when composing your message.

Bhup

Strazer ThanksÃ,  fot that.
1. Here is the inventory image:


(I know the animations are a bit lame but I can draw better on paper than the computer LOL anyway I'm still learning).
As you can hopefully see, the rope and the turkey are cut off. How can I shape the inventory so that it will show all the items without cutting anything off.

Also I wanted to add a slider to the inventory window but how do I make AGS register the changes.Ã,  I saved the game but the game did not acknowledge the changes.

2. Here is another problem:


The cup objects have been left on. The user is supposed to click on the parts where the
the cup objects are placed in the image above in an X formation using the rod and then he can cross the bridge.Ã,  So the user has to click from the top left cup, then, click on the the bottom right cup, then click on the top right cup and finally click on the bottom left cup.Ã,  The cup object below his left foot is just so that the animation can start there.

Strazer you said to use:Ã, 
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=13771


Which works but I don't see the problem with my code:

Code: ags

Ã,  // script for object2: Use inventory on object
if ((GetGlobalInt(1) == 0) && (GetGlobalInt(1) == 2) && (GetGlobalInt(3) == 0)) {
	Ã,  SetGlobalInt(0,1);
}Ã,  
else{
	SetObjectView(6,15);
	AnimateObjectEx(6,0,0,40,0,1);
	ObjectOff(6);
}



The GetGlobalInt values are, to me, like boolean values which AGS does not really have.Ã,  Each of those Global values will be set each time a cup object is clicked on.Ã,  I use SetGlobalInt to do it.Ã,  The code above will be pasted in the other interaction editors for each of the objects which are placed on the demons shoulder arm and legs.Ã,  Except they will each be testing other GlobalInts.Ã,  Can you tell me if this poses a problem??

The other thing is that I don't think the rod sees the objects because when I click on it nothing happens.
Are the GlobalInts not 0 by default or something.

Please someone put me out of my misery.
Bhup



strazer

#10
The first obvious thing is, as I've told you already, that you check GlobalInt 1 twice in your if-clause:

if ((GetGlobalInt(1) == 0) && (GetGlobalInt(1) == 2)

A global integer can't be two values at once. It's either 0 or 2. I guess the second part is supposed to read

(GetGlobalInt(2) == 2)

?

As for your inventory, you say it works in room 1, 2 and 3 but not in 4. How can that be if your inventory is on a fixed-size gui?
How large is your gui? How large is the inventory area?
The default size for inventory slots it 40x22 pixels, so your width should be a multiple of that: You want 4 inv items visible at a time? Make the inventory area 4*40 pixels wide. To set a custom size for inventory slots, use the SetInvDimensions function.

To see how to implement inventory scrolling, I recommend searching the forum, and checking out some templates (unfreezes January 9th) and game sources: Airbreak, Exile, Keptosh.

Bhup

#11
Strazer or anyone else,
QuoteThe first obvious thing is, as I've told you already, that you check GlobalInt 1 twice in your if-clause:

if ((GetGlobalInt(1) == 0) && (GetGlobalInt(1) == 2)

A global integer can't be two values at once. It's either 0 or 2. I guess the second part is supposed to read

(GetGlobalInt(2) == 2)

?
Yes I see your point.Ã,  Dumb mistake.Ã,  I guess I'm trying to rush this game I have so
much work to do I'm not paying much attention to the obvious.

Anyway, I corrected the code and put a display statement in and commented everything out temporarily, I then, moved the demon(pictured in past reply if your new) out of the way. And sure enough after correcting the scriptÃ,  the object interaction displayed the message. But when I put the demon object back it did not work.Ã,  My question is, do object interactions not work if there placed on top of other interactions?Ã,  Look at past diagram.
If so how can I put a hotspot on my demon object.Ã, 
Quote
As for your inventory, you say it works in room 1, 2 and 3 but not in 4. How can that be if your inventory is on a fixed-size gui?
Thats what I thought if your talking about the width and height there all the same in the Gui properties -> settings and values.
Quote
How large is your gui?
Gui..err.what do you mean? Yes I know GUI means graphical use interface.Ã,  But what do you meanÃ,  by Gui size?? Could you be more specific?
Quote
How large is the inventory area?
All I know is what I can tell you from viewing the Gui option.Ã,  Height = 130 width = 220
If I am looking in the wrong area then let me know.
Quote
The default size for inventory slots it 40x22 pixels, so your width should be a multiple of that: You want 4 inv items visible at a time? Make the inventory area 4*40 pixels wide. To set a custom size for inventory slots, use the SetInvDimensions function.
Hold on slow down..40 X 22..pixel..I can't see anywhere that I can change the pixels except the width and height of the inventory window and other buttons e.t.c in the GUI. BTY I am using AGS 2.61 if that makes any difference.
Quote
To see how to implement inventory scrolling, I recommend searching the forum, and checking out some templates (unfreezes January 9th) and game sources.
I'm looking into this except my other problem is that when I make a change in the GUI option and add for example a slider then it does not seem to register the changes. Yes, I don't know what I am doing wrong.
Bhup

Bhup

Ref:Demon (above):
I have tried very hard to see if I am doing something wrong  maybe not clicking in right place but I have come to the conclusion that if you put an object on top of another object , it hides the top object.  I have decided to chop up my character and make parts of his body seperate objects.  Anyway if anyone has any comments on this it would be nice to hear it. Also I still have problems with inventory window (look above for details). Thanks in advance.
Bhup

strazer

Quoteif you put an object on top of another object , it hides the top object.

It's all in the baselines. The default baseline of an object is its bottom-left corner.
So if the bottom-left corner of one object is further down than the bottom left corner of the other one, the former one gets drawn on top.
You can set object baselines manually in the room editor. Just set the baseline of the object that should be drawn on top higher (down) than the baseline of the one that should be drawn beneath.

Do you have pixel-perfect click detection enabled? If not, transparent parts of an object will obscure any objects beneath, hence not triggering their interactions where obscured.

Bhup

#14
Strazer,
Yeah thanks again. But I'll try that next time since I've allready chopped up the character and written the code.Ã,   :)

Has anybody any ideas on the inventory window problem?? (Look at postings above).
Bhup

Pumaman

Are you using the built-in inventory window or a custom one?

From your screenshot, it looks like your inventory images are simply too big for the built-in inventory screen. Normally, inventory items measure about 32x32 pixels.

If you need to have such large inventory items, you'll have to create a custom inventory window.

Bhup

Pumaman big thanks for the reply,  :)

Your right my images are bigger than 32 X 32.  But if I reduce the images you can't see them. So I guess I'll have to create a customary inventory screen.

What I'm about to say may sound a little confusing.   :P

1. In the GUI section of Ags, it allows you to increase the size of the inventory screen, add a slider and add new buttons e.t.c.  But when I save the changes they don't register in the game.  Where is my game getting its inventory display from and how can I change it e.g add slider e.t.c? (I have got Ags 2.61).

2. The GUI contains a STATUSLINE, ICONBAR and INVENTORY. (I'm not shouting thats the way they are written.)  Are these for customising a new inventory screen and if so how do you register the changes because when I save the game and play it, the changes do not register.

3. I know there is a createNewGUI button but when I click the button e.g. Add GUI button it does not do anything  ???

I hope I haven't repeated myself..totally confused.
Bhup



strazer

AGS has a built-in inventory GUI that cannot be changed. This GUI is shown when you call the function InventoryScreen().
To show your customized GUI INVENTORY, call GUIOn(INVENTORY) instead.

Bhup

Strazer, Thanks again for the tip.  :)

But...if I may point out you don't appear to be very generous with your explanations :P
for example, :

1. Which script do I amend to add the command with GUIOn(INVENTORY) ? I looked in the GUI optionin Edit Script..is this the write script?

2. I presume INVENTORY in GUIOn(INVENTORY) is a number representing the GUI number as in GUI1?

3. This has nothing to do with inventory but I am curious about this manual that I hear about where can I see this or is the help in AGS?
8)
Bhup


strazer

1. Go to menu "Script" -> "interface_click" and replace
  show_inventory_window();
with
  GUIOn(INVENTORY);
2. where "INVENTORY" is either the name or the number of your custom inventory GUI.
3. Yes.

SMF spam blocked by CleanTalk