Changing GUI text with certain hotspots and certain cursor modes.

Started by G, Mon 30/07/2007 22:43:08

Previous topic - Next topic

G

Hi there. I've been searching for this through the forums but I haven't found it, so if this has been solved already or there's already a topic about this somewhere, I'm sorry then.

I'm developing a game since a long time ago, and while interacting with certain hotspots, I would like my GUI to change.

I'll explain. My GUI show constantly the current cursor mode (Look at, Talk to, Walk to, Use, PIck up...) and when you place the mouse over the hotspot, the name of the hotspot is automatically added to the text of the GUI, so you see "Look at drunken".

But now the character goes through some hotpots when you "use" them, so my GUI says "Use train" when you want to get into the train, and I would like it to say "Pass through gap" when the player must enter somewhere through a gap (for example) while placing the cursor over certain hotspots with a certain cursor mode.

How can I achieve this?

Radiant

The easiest way is using each room's repeatedly_execute_always function. Insert some code that

Code: ags

function repeatedly_execute_always () {
  if (GetHotspotAt (mouse.x, mouse.y) == 4 && GetCursorMode () == 2) SetLabelText (SOME_GUI, 1, "This is a special action");
}


(obviously this needs some way of restoring the regular kind, too)

G

Sure thing it needs that way of restoring the usual kind, but I think I know the way.

Thanks for the help I'll try this for now..

Edit: I was wrong. I tried to use a while, but when the conditions fulfilled the game hung and crashed...

So I'm afraid I'll have to look for a more complicated way.

Gilbert

You probably ran into an infinite loop with while, thus the crash.

I think many people had archieved the similar effect using various ways, one method I can think of is to use custom properties.

Just add a property to your game (by clicking the "Properties..." button which appears in most panes of the editor):
1. name it something like usetext
2. add whatever description you want
3. set it to text type
4. set it's default value to "Use" (minus the quotes)
Then, for hotspot where you want alternate text, just set the property usetext for that stuff to something else.

Then in repeatedly_execute() of your game just do something like (refine it according to your needs):
Code: ags
if (Mouse.Mode==eModeUse&&GetHotspotAt (mouse.x, mouse.y)!=Null) SetlabelText(SOME_GUI, 1, String.Format("%s %s", GetHotspotAt (mouse.x, mouse.y).GetTextProperty("usetext"), GetHotspotAt (mouse.x, mouse.y).Name);

(You can repeat to add properties like this similarly if you want to do it for other cursor modes too and need some scripting changes if you want this to apply to character/objects/whever too.)

SMF spam blocked by CleanTalk