AGS refuses to hide player after script change (SOLVED)

Started by hedgefield, Mon 10/01/2005 17:31:03

Previous topic - Next topic

hedgefield

I have a really really stupid problem. :-

I thought I'd give the keyboard walking script from http://www.adventuregamestudio.co.uk/yabb/index.php?topic=8303.20 a try, and now AGS refuses to hide the player character in the intro.

Specifically, I used the script from http://www.adventuregamestudio.co.uk/yabb/index.php?topic=8303.msg202188#msg202188
But since I already had a script for my mouse cursor text overlay in the repeatedly_execute area, it said 'unexpected if'. So I removed it, and suddenly the player character won't hide during the intro sequence, even though I reverted the global script to EXACTLY the way it was before I changed it.

Any thought? ???

strazer

Quoteand now AGS refuses to hide the player character in the intro.

How do you hide the character?

QuoteBut since I already had a script for my mouse cursor text overlay in the repeatedly_execute area

If you have multiple code parts, even if they are unrelated, you have to put both in the same function, don't add the same function twice or something.

Quoteit said 'unexpected if'

This usually happens if you put code outside of any functions or forgot a closing brace or semicolon.
Try the "match braces" function of the script editor to see if there are any braces missing or placed incorrectly.

If it's not too much text, please post the relevant parts of your script here so we can see what may be wrong (please use the [ code ] tag).

hedgefield

I tick the 'hide player' box in the intro room settings. It always worked perfectly before, but for some reason now it shows the player whether I tick the box or not.

This is how I input it:
Code: ags
// main global script file
// ------ keyboard control ------
#define DIR_DISTANCE 10000
#define DIR_DOWN_LEFT 1
#define DIR_DOWN 2
#define DIR_DOWN_RIGHT 3
#define DIR_LEFT 4
#define DIR_STOP 5
#define DIR_RIGHT 6
#define DIR_UP_LEFT 7
#define DIR_UP 8
#define DIR_UP_RIGHT 9
int PrevDirection;

#sectionstart game_startÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function game_start() {
Ã,  // called when the game starts, before the first room is loaded
// ------ keyboard control ------
PrevDirection = DIR_STOP;
}
#sectionend game_startÃ,  // DO NOT EDIT OR REMOVE THIS LINE

int Over;string Name;
#sectionstart repeatedly_executeÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
Ã,  // put anything you want to happen every game cycle here 

Ã,  Ã,  Ã,  if (IsOverlayValid(Over))
Ã,  GetLocationName(mouse.x,mouse.y,Name);
Ã,  SetTextOverlay(Over,mouse.x-25,mouse.y-18,100,1,15,Name);}
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  //mouse.x/mouse.y=position, 100=width, 1=?font?, 15=color 

// --- keyboard control ---
int CharId, Direction, dx, dy;
// neue Richtung ermitteln
if ((IsKeyPressed (371) > 0) || (IsKeyPressed (55) > 0)) Direction = DIR_UP_LEFT; // 7 Home (numeric pad)
else if ((IsKeyPressed (372) > 0) || (IsKeyPressed (56) > 0)) Direction = DIR_UP; // 8 Up arrow
else if ((IsKeyPressed (373) > 0) || (IsKeyPressed (57) > 0)) Direction = DIR_UP_RIGHT; // 9 PgUp (numeric pad)
else if ((IsKeyPressed (375) > 0) || (IsKeyPressed (52) > 0)) Direction = DIR_LEFT; // 4 Left arrow
else if ((IsKeyPressed (376) > 0) || (IsKeyPressed (53) > 0)) Direction = DIR_STOP; // 5 Stop (numeric pad)
else if ((IsKeyPressed (377) > 0) || (IsKeyPressed (54) > 0)) Direction = DIR_RIGHT; // 6 Right arrow
else if ((IsKeyPressed (379) > 0) || (IsKeyPressed (49) > 0)) Direction = DIR_DOWN_LEFT; // 1 End (numeric pad)
else if ((IsKeyPressed (380) > 0) || (IsKeyPressed (50) > 0)) Direction = DIR_DOWN; // 2 Down arrow
else if ((IsKeyPressed (381) > 0) || (IsKeyPressed (51) > 0)) Direction = DIR_DOWN_RIGHT; // 3 PgDn (numeric pad)
else Direction = DIR_STOP;
// Vergleich mit aktueller Richtung
if (PrevDirection != Direction)
{
PrevDirection = Direction;
CharId = GetPlayerCharacter ();
if (Direction == DIR_STOP) { StopMoving (CharId); } // 5 Stop (numeric pad)
else
{
if (Direction == DIR_UP_LEFT) { dx = -DIR_DISTANCE; dy = -DIR_DISTANCE; } // 7 Home (numeric pad)
else if (Direction == DIR_UP) { dx = 0; dy = -DIR_DISTANCE; } // 8 Up arrow
else if (Direction == DIR_UP_RIGHT) { dx = DIR_DISTANCE; dy = -DIR_DISTANCE; } // 9 PgUp (numeric pad)
else if (Direction == DIR_LEFT) { dx = -DIR_DISTANCE; dy = 0; } // 4 Left arrow
else if (Direction == DIR_RIGHT) { dx = DIR_DISTANCE; dy = 0; } // 6 Right arrow
else if (Direction == DIR_DOWN_LEFT) { dx = -DIR_DISTANCE; dy = DIR_DISTANCE; } // 1 End (numeric pad)
else if (Direction == DIR_DOWN) { dx = 0; dy = DIR_DISTANCE; } // 2 Down arrow
else if (Direction == DIR_DOWN_RIGHT) { dx = DIR_DISTANCE; dy = DIR_DISTANCE; } // 3 PgDn (numeric pad)
MoveCharacterStraight (CharId, character [CharId].x + dx, character [CharId].y + dy);
}

//SCRIPT FOR CURSOR CHANGE OVER HOTSPOT DISABLED........
...blablabla....


I tried this for fun, so when it was giving me trouble I deleted the relevant code I got from  http://www.adventuregamestudio.co.uk/yabb/index.php?topic=8303.msg202188#msg202188. After that it was exactly like the script was before the change, but my player character wouldn't hide anymore.

strazer

      if (IsOverlayValid(Over)) {
  GetLocationName(mouse.x,mouse.y,Name);
  SetTextOverlay(Over,mouse.x-25,mouse.y-18,100,1,15,Name);}

Haven't checked the logic, only looked for braces. Without having the rest of the script, I can't say more than that.
Have you tried the "Match braces" function?

hedgefield

If I add that brace there, AGS prompts 'nested functions are not supported'Ã,  and it jumps to function show_inventory_window () {, which makes no sense at all.

Code: ags
#sectionstart repeatedly_executeÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
Ã,  // put anything you want to happen every game cycle here 

Ã,  Ã,  Ã,  if (IsOverlayValid(Over))
Ã,  GetLocationName(mouse.x,mouse.y,Name);
Ã,  SetTextOverlay(Over,mouse.x-25,mouse.y-18,100,1,15,Name);}
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  //mouse.x/mouse.y=position, 100=width, 1=?font?, 15=color 

//SCRIPT FOR CURSOR CHANGE OVER HOTSPOT DISABLED
Ã,  //GetLocationType(mouse.x,mouse.y);
Ã,  Ã,  Ã,  //if (GetLocationType(mouse.x,mouse.y)==3)
Ã,  Ã,  //SetCursorMode (MODE_USE);
Ã,  Ã,  //SetNextCursorMode ();
Ã,  Ã,  Ã,  //if (GetLocationType(mouse.x,mouse.y)==2)
Ã,  Ã,  //SetCursorMode (MODE_TALK);
Ã,  Ã,  Ã,  //SetNextCursorMode ();
Ã,  Ã,  Ã,  //SetNextCursorMode (MODE_USE);
Ã,  Ã,  Ã,  //if (GetLocationType(mouse.x,mouse.y)==1)
Ã,  Ã,  //SetCursorMode (MODE_LOOK);
Ã,  Ã,  //SetNextCursorMode ();
Ã,  Ã,  //SetNextCursorMode (MODE_TALK);
Ã,  Ã,  Ã,  //if (GetLocationType(mouse.x,mouse.y)==0)
Ã,  Ã,  //SetCursorMode (MODE_WALK);}}
Ã,  
#sectionend repeatedly_executeÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function show_inventory_window () {
Ã,  // This demonstrates both types of inventory window - the first part is how to
Ã,  // show the built-in inventory window, the second part uses the custom one.
Ã,  // Un-comment one section or the other below.
Ã,  
Ã,  // ** DEFAULT INVENTORY WINDOW
Ã,  // InventoryScreen();
 
Ã,  // ** CUSTOM INVENTORY WINDOW
Ã,  GUIOn (INVENTORY);Ã,  
Ã,  Ã, // switch to the Use cursor (to select items with)
Ã,  SetCursorMode (MODE_USE);
Ã,  // But, override the appearance to look like the arrow
Ã,  SetMouseCursor (6);
}


Sorry btw this piece was not included in the previous chunk of code. I originally had two versions of my global script in my previous post, but it only took the last one when I posted it.

strazer

You have to close the repeatedly_execute function too.

//...
//SetCursorMode (MODE_WALK);}} // <- This is the closing brace of rep_ex you have commented out

}

#sectionend repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE
//...

hedgefield


Pumaman

Did you also add the { to the IsOverlayValid line that strazer described in an earlier post?

If so, then go to this line:
function repeatedly_execute() {

place your cursor on the {, and choose Match Brace from the Edit menu. See where it highlights to.

hedgefield

#8
Oh right, I didn't include that one, thanks. When I highlight it now it selects the entire repeatedly_execute area, and the game works. But it also works without those two braces.
This doesn't really have much to do with my problem though...

[EDIT]Wait, I found the problem :-[: there was an unused character slot that started in the intro. Because it defaulted to the same sprite as my main character I thought there was something wrong with the actual main character, since I had been editing the game_start area of the global script. How stupid am I, Jesus...Ã,  ::)

I appreciate all the effort. :)

SMF spam blocked by CleanTalk