Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // main global script file
- // called when the game starts, before the first room is loaded
- function game_start()
- {
- }
- // called on every game cycle, except when the game is blocked
- function repeatedly_execute()
- {
- LabelInfo.Text = Game.GetLocationName(mouse.x, mouse.y) ;
- }
- // called on every game cycle, even when the game is blocked
- function repeatedly_execute_always()
- {
- }
- // called when a key is pressed
- function on_key_press(eKeyCode keycode)
- {
- if (IsGamePaused())
- {
- // game paused, so don't react to any keypresses
- keycode = 0;
- }
- else if (keycode == eKeyCtrlQ)
- {
- // Ctrl-Q will quit the game
- QuitGame(1);
- }
- else if (keycode == eKeyF9)
- {
- // F9 will restart the game
- RestartGame();
- }
- else if (keycode == eKeyF12)
- {
- // F12 will save a screenshot to the save game folder
- SaveScreenShot("screenshot.pcx");
- }
- else if (keycode == eKeyCtrlS)
- {
- // Ctrl-S will give the player all defined inventory items
- Debug(0, 0);
- }
- else if (keycode == eKeyCtrlV)
- {
- // Ctrl-V will show game engine version and build date
- Debug(1, 0);
- }
- else if (keycode == eKeyCtrlA)
- {
- // Ctrl-A will show walkable areas
- Debug(2, 0);
- }
- else if (keycode == eKeyCtrlX)
- {
- // Ctrl-X will let the player teleport to any room
- Debug(3, 0);
- }
- }
- function do_room_action(MouseButton button)
- {
- if (button == eMouseRight && player.ActiveInventory != null) {
- player.ActiveInventory = null;
- mouse.Mode = eModePointer;
- }
- else if (GetLocationType(mouse.x, mouse.y) != eLocationNothing)
- {
- // clicked on something
- if (player.ActiveInventory == null)
- {
- if (button == eMouseLeft) {
- Room.ProcessClick(mouse.x, mouse.y, eModeInteract);
- }
- else {
- Room.ProcessClick(mouse.x, mouse.y, eModeLookat);
- }
- }
- else
- {
- if (button == eMouseLeft)
- {
- // left click to use inventory on target
- Room.ProcessClick(mouse.x, mouse.y, eModeUseinv);
- }
- else
- {
- // right click to deselect inventory item
- player.ActiveInventory = null;
- Mouse.Mode = eModePointer;
- }
- }
- }
- else
- {
- // click on nothing
- if (player.ActiveInventory == null)
- {
- // left click to walk
- Room.ProcessClick(mouse.x, mouse.y, eModeWalkto);
- }
- else
- {
- // right click to deselect inventory item
- player.ActiveInventory = null;
- Mouse.Mode = eModePointer;
- }
- }
- }
- function do_inventory_action(MouseButton button, InventoryItem* item)
- {
- if (button == eMouseLeftInv)
- {
- if (player.ActiveInventory == null)
- {
- // left click to set active inventory item
- player.ActiveInventory = item;
- }
- else if (item.ID != player.ActiveInventory.ID)
- {
- // left click to use active inventory on another item
- item.RunInteraction(eModeUseinv);
- }
- else
- {
- // left click item on itself to deselect it
- player.ActiveInventory = null;
- Mouse.Mode = eModePointer;
- }
- }
- else
- {
- if (player.ActiveInventory == null)
- {
- // right click to look at inventory item
- item.RunInteraction(eModeLookat);
- }
- else
- {
- // right click to deselect inventory item
- player.ActiveInventory = null;
- Mouse.Mode = eModePointer;
- }
- }
- }
- //----------------------------------------------------------------------------------------------------
- // on_mouse_click()
- //----------------------------------------------------------------------------------------------------
- function on_mouse_click(MouseButton button)
- {
- // when mouse is clicked, text label is cleared
- if (LabelInfo != null)
- {
- LabelInfo.Text = "";
- }
- if (!IsGamePaused() && (button == eMouseLeft || button == eMouseRight))
- {
- do_room_action(button);
- }
- else if (button == eMouseLeftInv || button == eMouseRightInv)
- {
- // InventoryItem.GetAtScreenXY could return null here
- // so using game.inv_activated instead is a safer option
- do_inventory_action(button, inventory[game.inv_activated]);
- }
- }
- function dialog_request(int param) {
- }
- function ButtonSave_OnClick(GUIControl *control, MouseButton button)
- {
- Display("Game Saved.");
- SaveGameSlot(0, "Saved Game");
- }
- function ButtonLoad_OnClick(GUIControl *control, MouseButton button)
- {
- if (Game.GetSaveSlotDescription(0) != null) RestoreGameSlot(0);
- }
- function ButtonRestart_OnClick(GUIControl *control, MouseButton button)
- {
- RestartGame();
- }
- function ButtonQuit_OnClick(GUIControl *control, MouseButton button)
- {
- QuitGame(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment