I'm trying to find the boolean custom property value of a hotspot/object in the on_mouse_click function in the global script.
Something like:
if GetProperty("UsesText") == true do something first;
else do something else;
ProcessClick(mouse.x, mouse.y, mouse.Mode );
The manual gives this example:
if (hotspot[1].GetProperty("Value") > 200)
Display("Hotspot 1's value is over 200!");
But how do I find the [1] then?
thanks
I think you need something like this (untested)
Hotspot* mouseoverhotspot = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
Object* mouseoverobject = Object.GetAtScreenXY(mouse.x, mouse.y);
if (mouseoverhotspot != null)
{
if (mouseoverhotspot.GetProperty("UsesText") == 1)
{
// do something first
}
else
{
// do something else
}
ProcessClick(mouse.x, mouse.y, Mouse.Mode);
}
else if (mouseoverobject != null)
{
if (mouseoverobject.GetProperty("UsesText") == 1)
{
// do something first
}
else
{
// do something else
}
ProcessClick(mouse.x, mouse.y, Mouse.Mode);
}
I hope that helps.
Small correction: the area outside hotspots is hotspot[0] so it should be:
if (mouseoverhotspot != hotspot[0]) ...
It might be better to check for objects first because if the mouse is over an object that's itself over a hotspot, Hotspot.GetAtScreenXY() should still return the hotspot and thus the player clicks through the object.
I'd do:
int mx = mouse.x, my = mouse.y;
int lt = GetLocationType(mx, my);
if (lt == eLocationHotspot) {
Hotspot*h = Hotspot.GetAtScreenXY(mx, my);
if (h.GetProperty("UsesText")) ...
Got it!
Thanks again.