Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: TheMagician on Sat 12/03/2005 17:37:57

Title: Workaround for SetHotspotName ??
Post by: TheMagician on Sat 12/03/2005 17:37:57
One more question:

As there is currently no "SetHotspotName" function ... do you have any ideas or suggestions how to work around that problem so that the @OVERHOTSPOT@ label in my GUI shows a different name for a hotspot?

Many thanks in advance,
Stefan


and something totally different ... if I type "mouse" or "button" in the script editor the auto-complete feature pops up and suggests for example "Mouse" and "mouse" (with and without a capital M) or "Button" and "button" (with and without a capital B).
My question: what is the difference between the two (capitalized and small) ? Which one should I use?
Title: Re: Workaround for SetHotspotName ??
Post by: strazer on Sat 12/03/2005 18:45:32
You'd have to set the label text yourself in rep_ex to do this.

Try this:


// main global script file

char mouseoverdescription[200];
export mouseoverdescription;

function repeatedly_execute_always() {
  //...

  if (StrComp(mouseoverdescription, "") == 0) // if string is empty
    GetLocationName(mouse.x, mouse.y, mouseoverdescription); // get name of entity under mouse cursor
  lblDescription.SetText(mouseoverdescription); // set label text
  StrCopy(mouseoverdescription, ""); // empty string

  //...
}



// main script header

import char mouseoverdescription[200];



// room script file

function repeatedly_execute_always() {

  if ((Hotspot.GetAtScreenXY(mouse.x, mouse.y) == hSomeHotspot) && (somecondition)) // somecondition = e.g. already examined?
    StrCopy(mouseoverdescription, "new name");

}


I agree Object.SetName (http://www.adventuregamestudio.co.uk/tracker.php?action=detail&id=219) and Hotspot.SetName (http://www.adventuregamestudio.co.uk/tracker.php?action=detail&id=218) are badly needed.
Title: Re: Workaround for SetHotspotName ??
Post by: Pumaman on Sat 12/03/2005 19:06:54
Yeah, I appreciate that. It's just that the more stuff that AGS has to remember about each room, the more memory is used up and the bigger the save game files are.

But still, in this case I think it's worthwhile.
Title: Re: Workaround for SetHotspotName ??
Post by: strazer on Sat 12/03/2005 19:17:33
QuoteWhat is the difference between the two (capitalized and small) ? Which one should I use?

The capitalized versions are the names of the structs from which entities are derived:

managed struct Object {
  // a lot of properties and functions, among other things:
  import static Object* GetAtScreenXY(int x, int y);    // $AUTOCOMPLETESTATICONLY$
  import attribute int  X;
};

All room objects are instances of this struct, so you can do:

oSomeobject.X = 100;

The lowercase versions are arrays with which you can access entities by their number instead of their script o-name:

object[1].X = 100;

structs can also have static member functions. GetAtScreenXY is a static member function, in effect a global function that returns an Object:

Object *myobject = Object.GetAtScreenXY(mouse.x, mouse.y);
myobject.X = 100;


It's kinda hard to explain, I hope this makes it a bit more clear.
Title: Re: Workaround for SetHotspotName ??
Post by: TheMagician on Sat 12/03/2005 22:03:17
QuoteBut still, in this case I think it's worthwhile.

After reading strazer's workaround script I definitely second that!

By the way, strazer ... where do you pull out all these scripts?  ;)

I'll read through it another three times (as well as through your explanation of structs and entities  :o ). I'm sure I'll have learned something before I go to bed today!

Good night everybody
and thanks again.
Title: Re: Workaround for SetHotspotName ??
Post by: strazer on Sun 13/03/2005 00:28:31
QuoteBy the way, strazer ... where do you pull out all these scripts?

I write most of them off the top of my head, but for the more complicated stuff, I have collected a lot of workarounds and ideas in text files when I read through all of the Beginner's and Technical boards a year ago.
I will eventually put the most common ones on my website.