Hey all, I wonder if you could help me with this. I have trouble with properties. I think I understand the way they work and I can't find a mistake with the following code:
Quoteif (IsGUIOn(COIN)||IsGUIOn(INVCOIN))
{
if (GetGUIObjectAt(mouse.x, mouse.y)==0)
{
if (GetLocationType(xspot, yspot)==0)
GetInvPropertyText(GetInvAt(xspot, yspot), "look", ActiveA);
if (GetLocationType(xspot, yspot)==1)
GetHotspotPropertyText(GetHotspotAt(xspot,yspot), "look", ActiveA);
if (GetLocationType(xspot, yspot)==2)
GetCharacterPropertyText(GetCharacterAt(xspot,yspot), "look", ActiveA);
if (GetLocationType(xspot, yspot)==3)
GetObjectPropertyText(GetObjectAt(xspot,yspot), "look", ActiveA);
}
else if (GetGUIObjectAt(mouse.x, mouse.y)==1)
{
if (GetLocationType(xspot, yspot)==0)
GetInvPropertyText(GetInvAt(xspot, yspot), "action", ActiveA);
if (GetLocationType(xspot, yspot)==1)
GetHotspotPropertyText(GetHotspotAt(xspot,yspot), "action", ActiveA);
if (GetLocationType(xspot, yspot)==2)
GetCharacterPropertyText(GetCharacterAt(xspot,yspot), "action", ActiveA);
if (GetLocationType(xspot, yspot)==3)
GetObjectPropertyText(GetObjectAt(xspot,yspot), "action", ActiveA);
}
else if (GetGUIObjectAt(mouse.x, mouse.y)==2)
{
if (GetLocationType(xspot, yspot)==0)
GetInvPropertyText(GetInvAt(xspot, yspot), "talk", ActiveA);
if (GetLocationType(xspot, yspot)==1)
GetHotspotPropertyText(GetHotspotAt(xspot,yspot), "talk", ActiveA);
if (GetLocationType(xspot, yspot)==2)
GetCharacterPropertyText(GetCharacterAt(xspot,yspot), "talk", ActiveA);
if (GetLocationType(xspot, yspot)==3)
GetObjectPropertyText(GetObjectAt(xspot,yspot), "talk", ActiveA);
}
else StrCopy(ActiveA, "");
if (StrLen(ActiveA) > 0) StrCopy(ActiveS, " ");
else StrCopy(ActiveS, "");
StrCat(ActiveA, ActiveS);
StrCat(ActiveA, ActiveH2);
SetLabelText(STATUS, 0, ActiveA);
} else {
GetLocationName(mouse.x, mouse.y, ActiveH2);
SetLabelText(STATUS, 0, ActiveH2);
}
You see, I have a GUI which is non-clickable, called STATUS and has only a label on it. That label is supposed to show the correct action of an area, using the verb coin. For example, if the mouse is over the "look" icon of the coin, STATUS shows "Look at <name>". My problem is that it only shows the default properties of that area. Like, I have an object named "key" in the room and its "action" property is set to "Pick up". STATUS doesn't show "Pick up key" but it shows "Use key" instead ("Use" is the default propery for "action").
I hope you understand what I want to say. I'm sure it is my fault and maybe you can find it for me. Even though debugging is my love, this code looks like Greek to me; which means I completely understand it because Greek is my main language ;D. But still, I can't find what's wrong with it :(.
All variables you can see (xspot, yspot, ActiveH, ActiveH2, ActiveA etc) are already inited. COIN and INVCOIN are two almost identical GUIs, they just behave a bit different. COIN is for objects/hotspots/characters and INVCOIN is for nventory item. The only problem is that Get<type>PropertyText doesn't seem to find its custom property.
I hope I didn't put anything stupid in my code (most bugs I make are like using && instead of || etc). Any help is appreciated and if needed I could upload the game somewhere tomorrow. Note that it will be messed up because it's my AGS testing area. The game and template I'll finally make will be cleaner. I hope the above code is not too confusing
My initial thought would be that the verb coin GUI is covering up (xspot, yspot) and therefore GetLocationType is always returning zero.
You might try storing the result of GetLocationType when they click the mouse but before you turn on the GUI.
Yes, that was the problem, thank you! I created an integer variable called ActiveT and I put ActiveT = GetLocationType(...); before the coin is brought up.
Thank you again :)