I don't know what I'm doing wrong but I can't get my bgt script to run. It is tell me that there is a problem with a function that doesn't look like it could be wrong in any way. It doesn't seem to like some of the if statements I use and I have no idea why. The errors I seem to get seem to say Unexpected token 'if'. The function is posted below.
void view_in(int point)
{
int v;
v = 50;
if (point == left && player_x > 0)
{
for (int i = 1; i <= v; i++)
{
if (player_x-i < 0)
{
return;
}
else
{
if (map[player_x-i][player_y] == "pit")
{
wait(5);
sounds.play_stationary_extended("sounds/short_sound1.wav", false, 0, 0, 90, 100, true);}
wait(5);
}
if (map[player_x-i][player_y] != "nothing")
{
speech.speak(map[player_x-i][player_y]);
while(speech.speaking)
{
wait(5);
}
return;
}
else
{
sounds.play_stationary_extended("sounds/short_sound1.wav", false, 0, 0, 90, 200, true);
wait(2);
}
}
}
}
if (point == right && player_x < x_boundary)
{
for (int i = 1; i <= v; i++)
{
if (player_x+i > x_boundary)
{
return;
}
else
{
if (map[player_x+i][player_y] == "pit")
{
wait(5);
sounds.play_stationary_extended("sounds/short_sound1.wav", false, 0, 0, 90, 100, true);
wait(5);
}
if (map[player_x+i][player_y] != "nothing")
{
speech.speak(map[player_x+i][player_y]);
while(speech.speaking)
{
wait(5);
}
return;
}
else
{
sounds.play_stationary_extended("sounds/short_sound1.wav", false, 0, 0, 90, 200, true);
wait(2);
}
}
}
}
if (point == forward && player_y < y_boundary)
{
for (int i = 1; i <= v; i++)
{
if (player_y+i > y_boundary)
{
return;
}
else
{
if (map[player_x][player_y+i] == "pit")
{
wait(5);
sounds.play_stationary_extended("sounds/short_sound1.wav", false, 0, 0, 90, 100, true);
wait(5);
}
if (map[player_x][player_y+i] != "nothing")
{
speech.speak(map[player_x][player_y+i]);
while(speech.speaking)
{
wait(5);
}
return;
}
else
{
sounds.play_stationary_extended("sounds/short_sound1.wav", false, 0, 0, 90, 200, true);}
wait(2);
}
}
}
if (point == back && player_y > 0)
{
for (int i = 1; i <= v; i++)
{
if (player_y-i < 0)
{
return;
}
else
{
if (map[player_x][player_y-i] == "pit")
{
wait(5);
sounds.play_stationary_extended("sounds/short_sound1.wav", false, 0, 0, 90, 100, true);
wait(5);
}
if (map[player_x][player_y-i] != "nothing")
{
speech.speak(map[player_x][player_y-i]);
while(speech.speaking)
{
wait(5);
}
return;
}
else
{
sounds.play_stationary_extended("sounds/short_sound1.wav", false, 0, 0, 90, 200, true);}
wait(2);
}
}
}
if (point == forwardright)
{
if (player_x < x_boundary && player_y < y_boundary)
{
for (int i = 1; i <= v; i++)
{
if (player_x+i > x_boundary && player_y+i > y_boundary)
{
return;
}
else
{
if (map[player_x+i][player_y+i] == "pit")
{
wait(5);
sounds.play_stationary_extended("sounds/short_sound1.wav", false, 0, 0, 90, 100, true);
wait(5);
}
if (map[player_x+i][player_y+i] != "nothing")
{
speech.speak(map[player_x+i][player_y+i]);
while(speech.speaking)
wait(5);
}
return;
}
else
{
sounds.play_stationary_extended("sounds/short_sound1.wav", false, 0, 0, 90, 200, true);
wait(2);
}
}
}
if (point == forwardleft)
{
if (player_x > 0 && player_y < y_boundary)
{
for (int i = 1; i <= v; i++)
{
if (player_x-i < 0 && player_y+i > y_boundary)
{
return;
}
else
{
if (map[player_x-i][player_y+i] == "pit")
{
wait(5);
sounds.play_stationary_extended("sounds/short_sound1.wav", false, 0, 0, 90, 100, true);
wait(5);
}
}
if (map[player_x-i][player_y+i] != "nothing")
{
speech.speak(map[player_x-i][player_y+i]);
while(speech.speaking)
{
wait(5);
}
return;
}
else
{
sounds.play_stationary_extended("sounds/short_sound1.wav", false, 0, 0, 90, 200, true);
wait(2);
}
}
}
if (point == backleft)
{
if (player_x > 0 && player_y > 0)
{
for (int i = 1; i <= v; i++)
{
if (player_x-i < 0 && player_y-i < 0)
{
return;
}
else
{
if (map[player_x-i][player_y-i] == "pit")
{
wait(5);
sounds.play_stationary_extended("sounds/short_sound1.wav", false, 0, 0, 90, 100, true);
wait(5);
}
if (map[player_x-i][player_y-i] != "nothing")
{
speech.speak(map[player_x-i][player_y-i]);
while(speech.speaking)
{
wait(5);
}
return;
}
else
{
sounds.play_stationary_extended("sounds/short_sound1.wav", false, 0, 0, 90, 200, true);
wait(2);
}
}
}
}
}
if (point == backright)
{
if (player_x < x_boundary && player_y > 0)
{
for (int i = 1; i <= v; i++)
{
if (player_x+i > x_boundary && player_y-i < 0)
{
return;
}
else
{
if (map[player_x+i][player_y-i] == "pit")
{
wait(5);
sounds.play_stationary_extended("sounds/short_sound1.wav", false, 0, 0, 90, 100, true);
wait(5);
}
if (map[player_x+i][player_y-i] != "nothing")
{
speech.speak(map[player_x+i][player_y-i]);
while(speech.speaking)
{
wait(5);
}
return;
}
else
{
sounds.play_stationary_extended("sounds/short_sound1.wav", false, 0, 0, 90, 200, true);
wait(2);
}
}
}
}
}
}
}
DropBox Referral