Template for scrolling with out player .

Started by Candle, Tue 05/07/2005 23:44:32

Previous topic - Next topic

Candle

I added it to that part and got this error now were it work before in the room code ?
---------------------------
Compile Error
---------------------------
There was an error compiling your script. The problem was in 'Global script':



Error (line 66): Expected value after '='



Do you want to fix the script now? (Your game has not been saved).
Code: ags

#define SCROLL_SPEED 3
#define SCROLL_EDGE_LEFT 5
#define SCROLL_EDGE_RIGHT 5
#define SCROLL_EDGE_TOP 20
#define SCROLL_EDGE_BOTTOM 5
////////////////////////////

string text;
int index;

function Save() {
  SetMouseCursor(6);
  SetTextBoxText(SAVE,1,"");		// Clear Text box
  ListBoxSaveGameList(SAVE,3);		// Fill List Box with saved games
  index = ListBoxGetNumItems(SAVE,3);	// Count how many saved games there are           
  if (index > 19) 			// If saved games 20 (maximum) 
    DisplayMessage(990); 		// Display warning 
  index = 0;
  InterfaceOn(SAVE);			// Bring Save interface on     
}

function Load() {
 SetMouseCursor(6);
 ListBoxSaveGameList(LOAD,0);		// Fill List box with saved games  
 InterfaceOn(LOAD); 			// Bring restore Interface on 
}

function show_inventory_window () {
  if(game.num_inv_items > 0) {		// ** 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);
    GUIOff(ICONBAR);
  }
  else DisplayMessage(996);
}

// THE REST

#sectionstart game_start  // DO NOT EDIT OR REMOVE THIS LINE
function game_start() {
  // called when the game starts, before the first room is loaded
  CentreGUI(LOAD);
  CentreGUI(SAVE);
  CentreGUI(INVENTORY);
  }
#sectionend game_start  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
  // put anything you want to happen every game cycle here
}
//////////////////////////////////////////////////
int newvpx = GetViewportX(); // get current viewport x-position
  int newvpy = GetViewportY(); // get current viewport y-position
  if (mouse.x > (system.viewport_width - SCROLL_EDGE_RIGHT)) newvpx += SCROLL_SPEED; // if mouse is over right scrolling edge, move new viewport x position right
  else if (mouse.x < SCROLL_EDGE_LEFT) newvpx -= SCROLL_SPEED; // if mouse is over left scrolling edge, move new viewport x position left
  if (mouse.y > (system.viewport_height - SCROLL_EDGE_BOTTOM)) newvpy += SCROLL_SPEED; // if mouse is over bottom scrolling edge, move new viewport y position down
  else if (mouse.y < SCROLL_EDGE_TOP) newvpy -= SCROLL_SPEED; // if mouse is over top scrolling edge, move new viewport y position up
  SetViewport(newvpx, newvpy); // set viewport to (new) position
///////////////////////////////////////////////////////////////
#sectionend repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE

Line 66 ->  int newvpx = GetViewportX(); // get current viewport x-position

strazer

function repeatedly_execute() {
  // put anything you want to happen every game cycle here
}
//////////////////////////////////////////////////
int newvpx = GetViewportX(); // get current viewport x-position
//...

The code has to be pasted between these two braces. It's not enough to paste the code between the sectionstart and sectionend lines.
The way you have it now the code is outside of any function which cannot be done.

Candle


Candle

Thank you for the code help strazer ...


monkey0506

Quote from: strazer on Thu 07/07/2005 03:17:36
function repeatedly_execute() {
Ã,  // put anything you want to happen every game cycle here
}
//////////////////////////////////////////////////
int newvpx = GetViewportX(); // get current viewport x-position
//...

The code has to be pasted between these two braces. It's not enough to paste the code between the sectionstart and sectionend lines.
The way you have it now the code is outside of any function which cannot be done.

Just a thought, you may want to declare it outside of rep_ex (unless it's only called within rep_ex) (the int newvpx; part) and then just set its value in rep_ex.  Otherwise it only exists inside of rep_ex.  Also, the reason "[putting] the code...outside of any function...cannot be done" is that function calls aren't processed outside of other functions (so the function call isn't replaced by the return value).  So as long as it was inside a function it would work.  Which in this case rep_ex is the function needed...

SMF spam blocked by CleanTalk