Workaround for SetHotspotName ??

Started by TheMagician, Sat 12/03/2005 17:37:57

Previous topic - Next topic

TheMagician

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?

strazer

You'd have to set the label text yourself in rep_ex to do this.

Try this:

Code: ags

// 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

  //...
}


Code: ags

// main script header

import char mouseoverdescription[200];


Code: ags

// 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 and Hotspot.SetName are badly needed.

Pumaman

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.

strazer

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.

TheMagician

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.

strazer

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.

SMF spam blocked by CleanTalk