Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Fri 11/07/2003 23:16:01

Title: Script Problem
Post by: on Fri 11/07/2003 23:16:01
My script id going weird it is combining my two if statments why is this????

 // script for character2: Use inventory on character
MoveCharacterBlocking(CIRCUM,350,250,0);
Wait(5);
if (character[GetPlayerCharacter()].activeinv == 3)
DisplayMessage(18);
DisplayMessage(19);
RunDialog(2);

if (character[GetPlayerCharacter()].activeinv == 4)
DisplayMessage(22);
DisplayMessage(23);
LoseInventory (3);
LoseInventory (4);
NewRoomEx (6, 130, 140);
Title: Re:Script Problem
Post by: scotch on Fri 11/07/2003 23:18:15
I'm assuming you want those long blocks of code to run for each if, if that's right then it should be like this

// script for character2: Use inventory on character
MoveCharacterBlocking(CIRCUM,350,250,0);
Wait(5);
if (character[GetPlayerCharacter()].activeinv == 3) {
DisplayMessage(18);
DisplayMessage(19);
RunDialog(2); }

if (character[GetPlayerCharacter()].activeinv == 4) {
DisplayMessage(22);
DisplayMessage(23);
LoseInventory (3);
LoseInventory (4);
NewRoomEx (6, 130, 140); }


See those {} make the whole block of code run for the if, not just the next command.
Title: Re:Script Problem
Post by: Minimi on Fri 11/07/2003 23:33:05
scotch i think it should be like this! ;)

// script for character2: Use inventory on character
MoveCharacterBlocking(CIRCUM,350,250,0); { // also here!
Wait(5);
if (character[GetPlayerCharacter()].activeinv == 3) {
DisplayMessage(18);
DisplayMessage(19);
RunDialog(2); }

if (character[GetPlayerCharacter()].activeinv == 4) {
DisplayMessage(22);
DisplayMessage(23);
LoseInventory (3);
LoseInventory (4);
NewRoomEx (6, 130, 140); }
} // and here to end it all!
Title: Re:Script Problem
Post by: scotch on Fri 11/07/2003 23:48:06
What are they supposed to do?
(Other than break it)
Title: Re:Script Problem
Post by: Minimi on Sat 12/07/2003 00:04:37
they bind the 2 if's to eachother
Title: Re:Script Problem
Post by: Scorpiorus on Sat 12/07/2003 00:54:33
Quotethey bind the 2 if's to eachother
Although you can add these extra { } blocks they serve no real purpose unless there is an if or while statement before.

-Cheers
Title: Re:Script Problem
Post by: TerranRich on Sat 12/07/2003 05:17:12
Quite. The two external braces serve no purpose and aren't needed. HOWEVER, to do it properly, use if then else if and not just two if statements. It makes for better organization. :)