for rein I created a dynamic cursor that changes the mouse.Mode depending on what's underneath it. To add a check weather or not an item is at the mouse position I used this... variable?
InventoryItem*item=InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
in this function
function repeatedly_execute()
{
if (invlength != 0){
invx = invlength*20;
}
invpos=320-invx;
Inventory.X = invpos; //don't mind this, its juts part of my inventory display
InventoryItem*item=InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
if (GetLocationType(mouse.x,mouse.y) == eLocationCharacter && cValery.ActiveInventory == null){
mouse.Mode = eModeTalkto;
}
if (GetLocationType(mouse.x,mouse.y) == eLocationHotspot && cValery.ActiveInventory == null){
mouse.Mode = eModeInteract;
}
if (GetLocationType(mouse.x,mouse.y) == eLocationObject && cValery.ActiveInventory == null){
mouse.Mode = eModeInteract;
}
if (GetLocationType(mouse.x,mouse.y) == eLocationNothing && cValery.ActiveInventory == null){
if (item == null) {
mouse.Mode = eModeWalkto;
}
else {
mouse.Mode = eModeInteract;
}
}
}
I think it returns the script name of the item and in case there is none, it returns 'null' so I used it to check if there was "some item" under the mouse.
It's some kind of variable and I've seen similar types like GUI in the scumm verbcoin script:
Object*obj=Object.GetAtScreenXY(mouse.x, mouse.y);
Hotspot*htspt=Hotspot.GetAtScreenXY(mouse.x, mouse.y);
Character*chr=Character.GetAtScreenXY(mouse.x, mouse.y);
InventoryItem*item=InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
InventoryItem *item2; //(special check)
GUIControl *control = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
GUI *guixy = GUI.GetAtScreenXY(mouse.x, mouse.y);
I'm curios to know what they are and how I could use them for something other than what I've used it for thus far. It really doesn't feel right using code i don't fully understand.
It's called "pointer". It's a variable, but unless like e.g. int or float, it doesn't hold a number but an InventoryItem.
Once you've assigned an InventoryItem to it, you can call all the available functions on it or access its members, much like it were an actual item.
You have to make sure it's pointing at something though, otherwise you'll get the famous "null pointer error".
Thanks Khris.
Now that's a load off my mind.