FadeIn (int speed)Fades in from a black screen to the current palette. This is used to restore the screen after a FadeOut call. SPEED is from 1 (slowest) to 64 (fastest).
NOTE: This is a blocking function.
Example:
FadeOut(30); Wait(40); FadeIn(10);will fade the screen to black, wait 1 sec (40 game cycles) and then fade in again.
See Also: CyclePalette, FadeOut
FadeOut (int speed)Fades the screen out to black. SPEED is the speed of the fade, from 1 (slowest) to 64 (instant). You can restore the screen with FadeIn.
NOTE: This is a blocking function.
Example:
FadeOut(30); Wait(40); FadeIn(10);will fade the screen to black, wait 1 sec (40 game cycles) and then fade in again.
See Also: CyclePalette, FadeIn
FlipScreen (int way)Flips the screen round either the horizontal or vertical axis, or both. This function is for special effects only - all co-ordinates remain the same and it doesn't effect any other script functions.
The value of WAY selects:
0 normal 1 horizontal-flip (upside-down) 2 vertical-flip (left-to-right) 3 both (upside-down and backwards)NOTE: This function is still a bit buggy - black parts of the screen may show up wrong, and and pop-up messages will flip the screen back to normal.
Example:
FlipScreen(1);will flip the screen upsode down.
GetBackgroundFrame()Returns the number of the current background being displayed. In a room without animating backgrounds, this will always return 0. Otherwise, the current frame number is returned from 0 to 4.
Example:
if (GetBackgroundFrame()==4) ObjectOn(2);will turn on object 2 if the background frame of the room is frame 4.
See Also: SetBackgroundFrame
GetViewportX ()Returns the X-offset of the current viewport in a scrolling room. This allows you to find out what part of the room the player is looking at. The co-ordinate returned is the left edge of the screen, and so it can have a value between 0 and (ROOM WIDTH - 320).
If the room is a non-scrolling room, returns 0.
See the SetViewport function description for more information.
Example:
if (GetViewportX()>100)
ObjectOn(2);
will turn object 2 on if the player has scrolled the room by 100 pixels to the right.See Also: GetViewportY, SetViewport
GetViewportY ()Returns the Y-offset of the current viewport in a scrolling room. This allows you to find out what part of the room the player is looking at. The co-ordinate returned is the top edge of the screen, and so it can have a value between 0 and (ROOM HEIGHT - 200).
If the room is a non-scrolling room, returns 0.
Example:
if (GetViewportY()>20)
ObjectOn(2);
will turn object 2 on if the player has scrolled the room by 20 pixels to the bottom.See Also: GetViewportX, SetViewport
GetWalkableAreaAt (int x, int y)Returns the number of the walkable area at SCREEN co-ordinates (X,Y). If there is no walkable area there, or if invalid co-ordinates are specified, returns 0.
NOTE: The co-ordinates are SCREEN co-ordinates, NOT ROOM co-ordinates. This means that with a scrolling room, the co-ordinates you pass are relative to the screen's current position, and NOT absolute room co-ordinates. This means that this function is suitable for use with the mouse cursor position variables.
Example:
if (GetWalkableAreaAt(mouse.x,mouse.y) == 0)
Display ("You can't walk there.");
See Also: GetHotspotAt
MoveToWalkableArea (CHARID)Places character CHARID in the nearest walkable area to its current location. If the character is already on a walkable area, nothing happens. Otherwise it is placed in the nearest available area.
This is useful for placing for example in the Player Enters Screen event of a screen, to make sure the character can move if a NewRoomEx has been issued to get there. You could also use this in on_event for ENTER_ROOM to use whenever a player enters a room.
Example:
character[EGO].x=Random(320); character[EGO].y=Random(200); MoveToWalkableArea(EGO);will move character EGO to a random position but make sure that he is on a walkable area.
NewRoom (int room_number)Changes the room the player is in. This command unloads the current room from memory and loads instead ROOMx.CRM, where X is room_number.
IMPORTANT: This command does not change the room immediately; instead, it will perform the actual room change once your script function has finished (This is to avoid problems with unloading the script while it is still running). This means that you should not use any other commands which rely on the new room (object positionings, and so on) after this command within the same function.
Example:
NewRoom (4);will move the player character to room 4.
See Also: NewRoomEx
NewRoomEx (int room_number, int x, int y)Identical to NewRoom, except that the player character is placed at co-ordinates (X,Y) in the new room.
Example:
NewRoomEx(4,100,50);will move the player character to room 4 and also place him at coordinates 100,50.
See Also: NewRoom
RawClearScreen (int colour)The family of "raw" functions allow you direct access to the screen to do whatever you want with it. However, anything you do with these functions is permanent on the screen until the player leaves the room. They are most useful for things like a character stats screen where you want to print information directly to the screen. This function clears the screen to the specified COLOUR. (this is a number you can find in the Game, Palette mode of the editor). Whatever is currently on the background will be wiped.
NOTE: any GUIs you have will still appear on top of the screen, so if you want complete control you'll need to turn the GUIs off too.
Example:
RawClearScreen(31);will clear the screen to a blue color.
See Also: RawSetColor
RawDrawCircle (int x, int y, int radius)Draws a filled circle of radius RADIUS with its centre at (X,Y) in the current raw drawing colour.
Example:
RawDrawCircle(160,100,50);will draw a circle in the centre of the screen, of 50 pixels radius.
See Also: RawDrawLine, RawSetColor
RawDrawImage (int x, int y, int slot)Draws image SLOT from the sprite manager onto the screen at location (X,Y).
Example:
RawDrawImage(100,100,134);will draw the image that’s stored in sprite manager’s slot 134 at the coordinates 100,100.
See Also: RawPrint, RawDrawLine
RawDrawLine (int from_x, int from_y, int to_x, int to_y)Draws a line from (FROM_X, FROM_Y) to (TO_X, TO_Y) in the current raw drawing colour.
Example:
RawDrawLine(0,0,160,100);will draw a line from the left top of the screen (0,0) to the middle of the screen (160,100);
See Also: RawDrawCircle, RawDrawTriangle, RawSetColor
RawDrawTriangle (int x1, int y1, int x2, int y2, int x3, int y3)Draws a filled triangle in the current colour with corners at the points (x1,y1), (x2,y2) and (x3,y3).
Well, don't look at me, you might find it useful for something :-)
Example:
RawDrawTriangle(0,0,160,100,0,200);will draw a triangle with corners at the points (0,0),(160,100),(0,200).
See Also: RawDrawImage, RawDrawLine
RawPrint (int x, int y, string text, ...)This function prints the specified TEXT to screen location (X,Y). It accepts Display-style "%d" and "%s" arguments to display variable values. The text will be printed using the normal font and the current raw colour.
Example:
int power; RawPrint (10,10,"Power:%d",power);will display the string Power: and the value of the integer power at 10,10. Useful for making stats screens.
See Also: RawPrintMessageWrapped, RawSetColor, SetNormalFont
RawPrintMessageWrapped (int x, int y, int width, int font, int message_number)This function prints the message MESSAGE_NUMBER (which can be a global message or room message) directly to the screen at (X,Y), using the specified FONT.
WIDTH is the width of the virtual textbox enclosing the text, and is the point that the text will wrap at. This function is designed for writing a long message to the screen with it wrapping normally like a standard textbox.
The text will be printed using the current raw colour.
Example:
RawPrintMessageWrapped (80, 40, 160, 1, 10);will display room message 10 in the centre of the screen, starting from Y = 40.
See Also: RawPrint, RawSetColor
RawRestoreScreen ()Restores the screen from the backup image created with RawSaveScreen. Use this when you want to get back what was there before you started drawing.
Example:
RawSaveScreen(); RawDrawTriangle(0,0,160,100,0,200); Wait(80); RawRestoreScreen();will save the screen draw a triangle wait for a while and then restore the original screen.
See Also: RawSaveScreen
RawSaveScreen ()Makes a backup of the current background screen, in order that it can be restored later. This could be useful to back up the original image before writing over it, or to save a certain state of your drawing to restore later. Only one raw backup image can exist at a time, so this overwrites any previous saves you made.
NOTE: The backup image is lost when the player leaves the screen, or if they load a saved game position. Therefore, this is best only for short-term effects.
Example:
RawSaveScreen(); RawDrawTriangle(0,0,160,100,0,200); Wait(80); RawRestoreScreen();will save the screen draw a triangle wait for a while and then restore the original screen.
See Also: RawRestoreScreen
RawSetColor (int colour)Sets the colour to be used for future raw drawing routines to COLOUR. This is a number you can obtain from the Game, Palette mode in the editor.
Example:
RawSetColor(1984);will set the drawing color to green.
See Also: RawClearScreen, RawDrawLine, RawPrint
ReleaseViewport ()Releases the lock on the screen viewport, allowing it to automatically scroll around following the player character as normal.
Example:
int x;
while (x<100)
{SetViewPort(x,0);
x++;
Wait(1); }
SetViewPort(0,0);
ReleaseViewPort();
will scroll the room 100 pixels to the right and then return the screen to its original position and unlock the screen viewport.See Also: SetViewport
RemoveWalkableArea (int areanum)Removes the walkable areas in colour AREANUM from the current room. You can put the area back with RestoreWalkableArea.
NOTE: When the player leaves the screen, all the walkable areas are reset. Therefore, if you want an area to remain off when they leave the screen, you will need to set a flag, then run the RemoveWalkableArea command in the "Player enters screen" event when they return.
Example:
RemoveWalkableArea(5);will make the walking area 5 unwalkable.
See Also: RestoreWalkableArea
ResetRoom (int room_number)Discards all the data that the engine has in memory about when the player last visited ROOM_NUMBER, and resets it as if they'd never been there. The next time the player goes to that room, all the objects and scripts will be in their initial state (as set up in the editor), and not how they were when the player left the room. The "First time enters screen" event will be run when they enter this room again.
This function is useful if you want to have a "View intro" option to allow the player to watch an intro again - this function can reset all the objects in the intro rooms to their starting positions.
NOTE: You cannot reset the current room (ie. the room that the player is in).
Example:
ResetRoom(0);will reset the intro room so it can be played again if the player wants to.
RestoreWalkableArea (int areanum)Makes the area AREANUM walkable again.
Example:
RestoreWalkableArea(4);will make the walking area 4 walkable again.
See Also: RemoveWalkableArea
SetAreaLightLevel (int area, int level)Changes walkable area number AREA to have light level LEVEL. This does the same thing as the Light Level textbox in the editor, but allows you to change it at run-time.
AREA is from 1 to 15 (the walkable area number), and LEVEL is from -100 to 100. (0 is the defualt non-lit level).
NOTE: The light level will be reset when the player leaves the room, so you need to use it in Player Enters Screen if you want a permanent change.
Example:
if (GetGlobalInt(10)==1)
SetAreaLightLevel(2,100);
will set the area’s 2 level light to 100 if the Global Integer 10 is 1.
SetBackgroundFrame (int frame)Locks the background to frame number FRAME of an animating-background screen. (Values for FRAME are from 0 to 4). This allows you to use the animating backgrounds feature for another purpose - you can have two frames of the background, one for example with a spaceship crashed on it. Then, once the right event has happened, call SetBackgroundFrame in the Player Enters Screen event to set the background before the screen fades in.
Call SetBackgroundFrame(-1) to set the default animating frames.
The frame lock is released when the game changes rooms.
Example:
if (GetGlobalInt(20)==1)
SetBackgroundFrame(4);
will change the current room’s background frame to 4 if the global integer 20 is 1.See Also: GetBackgroundFrame
SetScreenTransition (int trans_type)Changes the default screen transition. trans_type can be one of the following:
TRANSITION_FADE TRANSITION_INSTANT TRANSITION_DISSOLVEAll future transitions will be done as specified until you call this function again.
Example:
SetScreenTransition (TRANSITION_FADE);will change the room transitions to Fade.
SetViewport (int x, int y)Locks the screen viewport to having the top-left hand corner at (X,Y) in a scrolling room. This allows you to manually pan across a scrolling room or to have the screen follow a non-player character.
The lock is released when you either call ReleaseViewport or the player changes rooms.
NOTE: The co-ordinates supplied are 320x200-scale co-ordinates, and will be automatically multiplied up by the engine.
NOTE: This function has no effect if the current room isn't a scrolling room.
Example:
SetViewport (character[MAN].x - 160, character[MAN].y - 110);will scroll around and follow character MAN in a specific room, ( you must put this in the room's repeatedly execute event)
See Also: GetViewportX, GetViewportY, ReleaseViewport
SetWalkBehindBase (int area, int baseline)Changes the walk-behind AREA to have new BASELINE. This effectively allows you to turn walk-behinds on and off, although you can do other tricks with it as well. BASELINE is from 1 to the height of the room (normally 200) and moves the line which you set originally in the editor.
Passing BASELINE as 0 disables the walk-behind area, so that the player will always walk in front of it.
Basically, if the character's feet are below BASELINE, he will be drawn in front of it, otherwise he will be drawn behind it.
Example:
SetWalkBehindBase (3,0);will disable the walkbehind area number 3.
See Also: SetObjectBaseline
ShakeScreen (int amount)Shakes the screen to simulate, for example, an earthquake. AMOUNT is how much the screen shakes: 1 is hardly anything, and 25 is a lot.
Example:
ShakeScreen(5);will shake the screen a little.
TintScreen (int red, int green, int blue)Tints the screen with the specified RGB values. RED, GREEN and BLUE range from 1 to 100.
Pass (0, 0, 0) to turn off the tinting and go back to how the screen normally looks.
NOTE: This command is currently experimental, since it causes a massive slowdown in the engine, especially at high resolutions. If you use it, you should provide an option for the player to turn it off.
NOTE: This feature only works in hi-colour games.
Example:
TintScreen (100, 50, 50);will tint a heavy dose of red.