Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Grim on Sun 10/02/2008 13:52:38

Title: Cursor says:label4obj0 when not pointed at objects.SOLVED
Post by: Grim on Sun 10/02/2008 13:52:38
Hello again

I've upgraded my version ags to 2.72 from 2.61 and the game I'm working on upgraded itself( I didn't know I could do that!). Anyway, the problem is that wherever I point cursor this text is displayed next to it : label4obj0. When cursor is over objects or hotspots it displays the name of  that hotspot or object, but everywhere else I get that silly message. Is it something to do with GUI or cursor settings? Please, help!:)
Title: Re: Cursor says:label4obj0 when not pointed at objects or hotspots.
Post by: Khris on Sun 10/02/2008 14:36:57
Please show us the contents of your repeatedly_execute and tell us if you're using any modules.
Title: Re: Cursor says:label4obj0 when not pointed at objects or hotspots.
Post by: Grim on Sun 10/02/2008 15:42:04
This is code from global script:

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

 
if ((IsGUIOn(1) == 0) || (character[GetPlayerCharacter()].room !=0))  {
    SetNormalFont(4);
    }

 
 
  if (IsTimerExpired(1) == 1) {
  timeexp ++;
   string strmin; 
    StrFormat(strmin,"Playing Time %d minutes",timeexp);
  //  SetLabelText(6,0,strmin);
  //Display("%d minutes of game play",timeexp);
 
  SetGlobalInt(143,timeexp);

  SetTimer(1,2400);
  }

 

 
GetLocationName(mouse.x,mouse.y,location_name);
if (location_name == "") {
  StrCopy(location_name,"Label4 Obj0");
  }
 
get_gui = GetGUIAt(mouse.x,mouse.y);
got_inv = character[GetPlayerCharacter()].activeinv;

// PART 1 - determina cursor quando em cima de GUI

if (get_gui != -1) { // se estiver no GUI

  if (got_inv != -1) { // se cursor for invmode
     SetCursorMode(4);
     }
     else {
     SetCursorMode(MODE_USE);
     SetMouseCursor(2);
     } 
}
else if ((GetLocationType(mouse.x,mouse.y) > 0) && (got_inv == -1)) { // se nao estiver no GUI nem tiver cursor como objecto
    SetMouseCursor(2);
    }
    else if (got_inv != -1) {
      SetCursorMode(4);
      }
      else { // neste caso, estara em nada, e será "Walk"
     SetMouseCursor(0);
           }
       
         
// fim de PART 1

// PART 2 GUI 4 é um pequeno gui usado apenas como label (0) para texto respectivo ao objecto


if (mouse.y < 223) {
  // if(mouse.y > 20 {
  SetGUIPosition(4,mouse.x,mouse.y+7);
  //SetGUIPosition(4,mouse.x,mouse.y-14);
  //SetGUIPosition(4,270,10);
}

else {
   SetGUIPosition(4,mouse.x,mouse.y-14);
   //SetGUIPosition(4,270,10);
   }

  SetLabelText(4,0,location_name);
// fim de PART 2

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

..........................................

I'm using Broken Sword GUI.
Title: Re: Cursor says:label4obj0 when not pointed at objects or hotspots.
Post by: Matti on Sun 10/02/2008 16:53:45
I'm very sure it has to do with your SetLabelText(4,0,location_name) line at the end of your script. The message "label4obj0" would at least fit.

I don't know the version 2.61 but in the 2.72-help it says the SetLabelText-function is obsolete and is now called: lblStatus.Text = Game.GetLocationName(mouse.x, mouse.y);
You should look it up in the help file.


And by the way use the (code)...(/code)  for your script, it's smaller and easier to read... you have to change the "(" to "["
Title: Re: Cursor says:label4obj0 when not pointed at objects or hotspots.
Post by: Pumaman on Sun 10/02/2008 18:54:57
You have this code:


GetLocationName(mouse.x,mouse.y,location_name);
if (location_name == "") {
  StrCopy(location_name,"Label4 Obj0");
  }


Which is setting it to display "Label 4 Obj 0" as the default text. The difference is probably that the == operator can be used to compare strings in 2.72, whereas in 2.61 that "if" statement would always have failed.
Title: Re: Cursor says:label4obj0 when not pointed at objects or hotspots.
Post by: Grim on Sun 10/02/2008 19:55:53
Should I just remove this line completely:

GetLocationName(mouse.x,mouse.y,location_name);
if (location_name == "") {
  StrCopy(location_name,"Label4 Obj0");
  }

?
Or should I replace with something else?
Title: Re: Cursor says:label4obj0 when not pointed at objects or hotspots.
Post by: .M.M. on Mon 11/02/2008 19:27:16
Easier is to create label, and replace text "new label" with @OVERHOTSPOT@.
Title: Re: Cursor says:label4obj0 when not pointed at objects or hotspots.
Post by: Khris on Mon 11/02/2008 22:31:23
How did the code end in there in the first place?
It doesn't make much sense, not even for debugging purposes.
Leave the "GetLocationName" line, but ditch the rest.
Title: Re: Cursor says:label4obj0 when not pointed at objects or hotspots.
Post by: Grim on Sat 16/02/2008 06:22:24
Thanks guys!
After a couple of tests I found that leaving "" empty inside does the job.
SOLVED