Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: lafouine88 on Sat 18/07/2020 21:40:06

Title: changing the mousecursor after useinventory(DELETE)
Post by: lafouine88 on Sat 18/07/2020 21:40:06
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) Select

{
....
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) Select
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.
Title: Re: changing the mousecursor after useinventory
Post by: Cassiebsg on Sat 18/07/2020 23:28:03
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?
Title: Re: changing the mousecursor after useinventory
Post by: eri0o on Sun 19/07/2020 00:07:12
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.
Title: Re: changing the mousecursor after useinventory
Post by: lafouine88 on Sun 19/07/2020 08:24:28
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