:P
This may have been answered soom were but i cant find it (By the way i'm a new person to AGS)
i'm making a sci-fi game and i want to push a button in the engine and make a "force field" turn of in another room
how do i do it???
Thankz Cpt Ezz
Your character needs to interact with a hotspot. The forcefield could be an object/variable that is turned off after interacting..
But you really should read the tutorial before we can help you..
Search for the OtherRoom module or use variables.
Other room thread count is now at 234'326.
Sorry, I didn't realize that your problem was accessing another room.
Like KhrisMUC said, you can use variables (if you don't want to use the module).
You can declare a variable in the main script header (like bool button=false) and export it to the two rooms, then import it in the two rooms. When the button is pressed, set the variable to true. Then, in the second room in the before_fadein-section check if the variable is set to true and have the forcefield disappear..
thanks but could you you show me in script?(it would make more sense)
With the other room module:
OtherRoom.ObjectOff(3, 0);
This will make the forcefield (object 0) in room 3 turn off (considering your forcefield is and object and not a hotspot).
To use variables you could try:
SetGlobalInt(1, 1); //Turn forcefield off
and then in the room where the hotspot is (in player enters room before fadein):
if (GetGlobalInt(1) > 0) {
oForcefield.Visible = false; //oForcefield is your object acting as a forcefield
}
For more on GlobalInts look in the manual.
thank you a heaps guys
i wrote it in and it says
Parse error unexpected 'if'
here i my code for it
room were object in
// room script file
function room_LeaveBottom()
{
player.ChangeRoom(2, 216, 8);
}
if (GetGlobalInt(1) > 0) {
oforcefield.Visible = false;
code were hotspot(button) is on
function hbutton_Interact()
{
SetGlobalInt(1, 1);
}
what have i done wrong?
You'll need to check your braces, and for future reference you can enclose your code in the
[code][/code] tags.
// room script file
function room_LeaveBottom()
{
player.ChangeRoom(2, 216, 8);
// REMOVED BRACE CLOSING FUNCTION
if (GetGlobalInt(1) > 0) {
oforcefield.Visible = false;
} // ADDED BRACE CLOSING CONDITIONAL
} // ADDED BRACE CLOSING FUNCTION
The corrected code (in the code tags):
function room_LeaveBotom()
{
player.ChangeRoom(2, 216, 8);
if (GetGlobalInt(1) > 0) {
oforcefield.Visible = false;
}
}
You should always be sure that your braces line up, and learning about indentation is a good way to do that. Also the editor does have a match-brace feature.
And your "If (GetGlobalInt(1) > 0) {}" has to be in the room_before_fadein-section of your room 2 like creator said.
Right, because following the logic behind the solution, the force field is supposed to turn (in)visible as soon as the player enters the room, but before the room is displayed.
"Captain" Ezz, please do the tutorial and also read the rest of the manual before asking trivial things having been asked and answered ten thousand times before.