Script Problem

Started by , Fri 11/07/2003 23:16:01

Previous topic - Next topic

Plog

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);

scotch

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.

Minimi

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!

scotch

What are they supposed to do?
(Other than break it)

Minimi

they bind the 2 if's to eachother

Scorpiorus

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

TerranRich

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. :)
Status: Trying to come up with some ideas...

SMF spam blocked by CleanTalk