Objects and messages

Started by , Mon 13/11/2006 12:27:47

Previous topic - Next topic

darkmaster79

Hi, i'm from Italy and i apologize for my bad english..Ã,  :-[ I'm tryng to do an adventure game but i have found several difficulties..
I would like that positioning the mouse cursor upon an object will display a message, but not the "sierra style" message inside a box.. How to do? I tried but doesn't work..
???
ThanksÃ,  :D

Gilbert

Checking the "Always display text as speech" box in the lower right corner of the "General settings" screen maybe?

Ashen

Quote
I tried but doesn't work

What have you tried? And how do you want it to display?
I know what you're thinking ... Don't think that.

darkmaster79

I want that when i put the mouse cursor upon an object i can see its name down in the screen.. something similar to lucas adventures..

Example: Mouse on key ---> "A key"

thanks :)

Ashen

Try a forum search, this has been asked before and is really quite easy. Basically, a GUI Label with it's text set to '@OVERHOTSPOT@'. Beyond that you can make it as simple or as complicated as you want.
(Example.) And, as mentioned in that thread, there's even a couple of modules that do the coding for you, such as SSH's Description module.
I know what you're thinking ... Don't think that.

darkmaster79

Ok.. thanks now it seems to work..  ;D but how can i display the hotspot message in a particular point x,y  of the screen?  ??? for example down in the middle...

It follows the module that i'm using.. What i must modify? ::)

// Main script for module 'OverHot'

// OverHot script module - Automatic mouse over hotspot description
// Version 1.11
// 2005-11-01 by Gilbert Cheung
// 2005-11-05 cleanup by strazer
// 2006-01-18 quick fix to support AGS V2.71

//****************************************************************************************************
// VARIABLES
//****************************************************************************************************

int OverHot_Mode; // 0 = disabled, 1 = enabled

Overlay* OverHot_Overlay;

int OverHot_XOff, OverHot_YOff;
int OverHot_Width, OverHot_Font, OverHot_Colour;
int OverHot_BoundX1, OverHot_BoundX2, OverHot_BoundY1, OverHot_BoundY2;

//****************************************************************************************************
// INTERNAL FUNCTIONS
//****************************************************************************************************

//----------------------------------------------------------------------------------------------------

function OverHot_Start() {

   if (OverHot_Overlay != null) if (OverHot_Overlay.Valid) OverHot_Overlay.Remove();
   OverHot_Overlay = Overlay.CreateTextual(mouse.x + OverHot_XOff, mouse.y + OverHot_YOff, OverHot_Width, OverHot_Font, OverHot_Colour, "");
   if (OverHot_Overlay != null) if (OverHot_Overlay.Valid) return true;
   return false;

}

//----------------------------------------------------------------------------------------------------

//****************************************************************************************************
// USER FUNCTIONS
//****************************************************************************************************

//----------------------------------------------------------------------------------------------------

static bool OverHot::Enable() {
   /*
   Description:      Turn on the over hotspot feature, default is true (on)
   Parameters:   (none)
   Return value:   1 (true) if successful, 0 (false) if failed (mostly because reached Overlay limit)
   Example:         OverHot.Enable();
   */

   if (OverHot_Start()) {
      OverHot_Mode = 1;
      return false;
   }
   else {
      OverHot_Mode = 0;
      return true;
   }

//   OverHot_Mode = 0;
}

//----------------------------------------------------------------------------------------------------

static function OverHot::Disable() {
   /*
   Description:      Turn off the over hotspot feature
   Parameters:   (none)
   Return value:   (none)
   Example:         OverHot.Disable();
   */

   if (OverHot_Overlay != null) {
      if (OverHot_Overlay.Valid) OverHot_Overlay.Remove();
   }
   OverHot_Mode = 0;

}

//----------------------------------------------------------------------------------------------------

static bool OverHot::IsAvailable() {
   /*
   Description:      Checks whether there's currently a OverHot overlay onscreen
   Parameters:   (none)
   Return value:   1 (true) if available, 0 (false) if not available
   Example:         if (IsOverHotAvailable()) Display("The overlay is on!");
   */

   if (OverHot_Overlay != null) {
      if (OverHot_Overlay.Valid) return true;
      else return false;
   }
   else return false;

}

//----------------------------------------------------------------------------------------------------

static function OverHot::SetOffset(int x, int y) {
   /*
   Description:      Sets the offset of the overlay from the cursor hotspot
   Parameters:   int x - X offset from cursor hotspot
                     int y - Y offset from cursor hotspot
   Return value:   (none)
   Example:         OverHot.SetOffset(10, 10);
   */

   OverHot_XOff = x;
   OverHot_YOff = y;

}

//----------------------------------------------------------------------------------------------------

static function OverHot::SetWidth(int newwidth) {
   /*
   Description:      Sets the width of the overlay
   Parameters:   int newwidth - width for the text overlay
   Return value:   (none)
   Example:         OverHot.SetWidth(100);
   */

   OverHot_Width = newwidth;

}

//----------------------------------------------------------------------------------------------------

static function OverHot::SetStyle(int font, int colour) {
   /*
   Description:      Sets the font and colour of the overlay text
   Parameters:   int font - font number to use
                     int colour - colour of the text
   Return value:   (none)
   Example:         OverHot.SetStyle(1, 15);
   */

  OverHot_Font = font;
  OverHot_Colour = colour;

}

//----------------------------------------------------------------------------------------------------

static bool OverHot::SetBounds(int x1, int x2, int y1, int y2) {
   /*
   Description:      Sets the bounding box for the overlay (so they won't go offscreen or under a GUI)
   Parameters:   int x1 - minimum x-coordinate for overlay
                     int x2 - maximum x-coordinate for overlay
                     int y1 - minimum y-coordinate for overlay
                     int y2 - maximum y-coordinate for overlay
   Return value:   1 (true) if there are problems with parameters, 0 (false) if successful
   Example:         OverHot.SetBounds(50, 270, 50, 190);
   */

   if (x1 > x2 || y1 > y2) return true;
   else {
      OverHot_BoundX1 = x1;
      OverHot_BoundX2 = x2;
      OverHot_BoundY1 = y1;
      OverHot_BoundY2 = y2;
      return false;
   }

}

//----------------------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------------------
// LEGACY FUNCTIONS
//----------------------------------------------------------------------------------------------------
static bool OverHot::TurnOverHot(bool para) { if (para) return OverHot.Enable(); else OverHot.Disable(); }
//----------------------------------------------------------------------------------------------------
static bool OverHot::IsOverHotAvailable() { return OverHot.IsAvailable(); }
//----------------------------------------------------------------------------------------------------
static bool OverHot::SetBound(int x1, int x2, int y1, int y2) { return OverHot.SetBounds(x1, x2, y1, y2); }
//----------------------------------------------------------------------------------------------------

//****************************************************************************************************
// EVENT HANDLER FUNCTIONS
//****************************************************************************************************

//----------------------------------------------------------------------------------------------------

function game_start() {

   // Set defaults:
   OverHot.SetOffset(-25, -18);
   OverHot.SetWidth(100);
   OverHot.SetStyle(1, 15); 
   OverHot.SetBounds(0, system.viewport_width, 0, system.viewport_height);
   OverHot.Enable();

}

//----------------------------------------------------------------------------------------------------

function repeatedly_execute_always() {

   if (OverHot_Mode && OverHot.IsAvailable()) {
    #ifndef AGS_NEW_STRINGS
      string overhot_text;      
      GetLocationName(mouse.x, mouse.y, overhot_text);
      #endif
      #ifdef AGS_NEW_STRINGS
      String overhot_text = Game.GetLocationName(mouse.x, mouse.y);
      #endif
      OverHot_Overlay.SetText(OverHot_Width, OverHot_Font, OverHot_Colour, overhot_text);

      int overhotmp = mouse.x + OverHot_XOff;
      if ((overhotmp + GetTextWidth(overhot_text, OverHot_Font)) > OverHot_BoundX2) overhotmp = OverHot_BoundX2 - GetTextWidth(overhot_text, OverHot_Font);
      if (overhotmp < OverHot_BoundX1) overhotmp = OverHot_BoundX1;
      OverHot_Overlay.X = overhotmp; // so the position of the overlay will be adjusted every game loop

      overhotmp = mouse.y + OverHot_YOff;
      if ((overhotmp + GetTextHeight(overhot_text, OverHot_Font, OverHot_Width)) > OverHot_BoundY2) overhotmp = OverHot_BoundY2 - GetTextHeight(overhot_text, OverHot_Font, OverHot_Width);
      if (overhotmp < OverHot_BoundY1) overhotmp = OverHot_BoundY1;
      OverHot_Overlay.Y = overhotmp;

   }

}

//----------------------------------------------------------------------------------------------------

function on_event (EventType event, int data) {

   if (event == eEventEnterRoomBeforeFadein) {

      if (OverHot_Mode) OverHot_Start();

   }
   else if (event == eEventLeaveRoom) {

      if (OverHot.IsAvailable()) OverHot_Overlay.Remove(); // required whenever a room change occurs

   }

}

//----------------------------------------------------------------------------------------------------


Candle

This module can do lots of things!

Want a FoA-style statusline? Description can do it!
Want a hotspot description that follows the cursor? Description can do it!
Want the description on an Overlay or a GUI? Description can do it!
Want the text to stay still while you're over the same hotspot? Description can do it!

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=26306.0

monkey0506

As Candle, erm, failed to say (::)), SSH's Description module has replaced the OverHot module. So you'll probably need to use that instead (as the function they serve is relatively easy to script I've never actually looked at them myself, so don't take this for granted, I could be wrong. However the modules are nice for simplifying the process for those new to AGS (and/or programming)).

Candle

Thanks monkey for adding that. sometimes I forget to add info.

Khris

Quote from: darkmaster79 on Sun 19/11/2006 22:03:54Ok.. thanks now it seems to work..  ;D but how can i display the hotspot message in a particular point x,y  of the screen?  ??? for example down in the middle...

Quote from: codestatic bool OverHot::SetBounds(int x1, int x2, int y1, int y2) {
   /*
   Description:      Sets the bounding box for the overlay (so they won't go offscreen or under a GUI)
   Parameters:   int x1 - minimum x-coordinate for overlay
                     int x2 - maximum x-coordinate for overlay
                     int y1 - minimum y-coordinate for overlay
                     int y2 - maximum y-coordinate for overlay

Ashen

Do you mean you want it to ALWAYS be in the SAME place on screen? If so, why not just use a GUI and skip the module.
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk