In my new game there will be three buttons, which activate the character´s special ability.
I wanted to solve this by handling the abilities as objects - as there won´t be a real inventory.
For example: Klick on Button2 - activate object oDogjump
Then, using the object on a hotspot would activate a script.
But somehow it doesn´t work. ???
My code looks like this:
function But2_OnClick(GUIControl *control, MouseButton button)
{
if (player.ID == cDog.ID) {
int x = mouse.x;
int y = mouse.y;
mouse.Mode = eModeUseinv; player.ActiveInventory = iDogjump.GetAtScreenXY(x, y);
}
}
I´d be glad if someone could help me with this.
This should work:
function But2_OnClick(GUIControl *control, MouseButton button)
{
if (player.ID == cDog.ID) {
// mouse.Mode = eModeUseinv; // this line shouldn't be necessary, afaik setting player.ActiveInventoryis enough
player.ActiveInventory = iDogjump;
}
}
.GetAtScreenXY is a static function; it can only be used like this:
InventoryItem*pointer_to_clicked_item = InventoryItem.GetAtScreenXY(x, y);
Works perfectly. Thanks a lot Khris. :)
Hey Khris, you're so predictable.
DrWhite asked me, if I know a solution. I said, if you post your question, Khris will answer you. ;D
Hehe, it didn't require a huge post, and I like those :)