changing the mousecursor after useinventory(DELETE)

Started by lafouine88, Sat 18/07/2020 21:40:06

Previous topic - Next topic

lafouine88

Hi again !

You know when you pick up an item, you like it to switch the mouse cursor to useinv of that item with a code like this :
Code: ags

{
....
player.AddInventory(item);
player.ActiveInventory(item);
Mouse.Mode==eModeUseinv;
}


This makes the item you picked more visual, more concrete.
But I can't find how to do the same when you need an interaction with another item you already have(call it item2). Because that function calls for (item2) to be the active inventory so it makes the game crash.
This is the kind of code that I use (and doesn't work)

Code: ags
function obox_UseInv()
{

if(player.ActiveInventory==item2)
{
player.AddInventory(item);
player.ActiveInventory(item);
Mouse.Mode==eModeUseinv;
}

  else
player.Say("Doesn't work.");
}



I can see where the problem is here but I can't find the way to avoid it. Any function in mind ?

Thanks a lot again and have a good sunday.

Cassiebsg

I'm not exactly seeing why the game crashes (maybe someone with more experience can though). Can you post the exact crash message?

Also is this code a copy/paste of the exact code or did you just typed it in as an example?
There are those who believe that life here began out there...

eri0o

#2
Active Inventory usage is wrong, should be like this:

player.ActiveInventory = iKey;

https://adventuregamestudio.github.io/ags-manual/Character.html#characteractiveinventory

Still the compiler should have produced an error instead of the game crashing.

What does "doesn't work" means? What's the observed behavior of the game? I would check that obox_UseInv is linked in the editor by checking the event tab for it there in the property explorer.

lafouine88

You're right eriOo...this was an old code and I didn't look at it again. There also is a problem with the mouse.mode wich should be "=eModeUseinv".It works perfectly now... Sorry about that.

->delete

SMF spam blocked by CleanTalk