Hello Guys!
In my game, I want a default message when you're using 1 inventory item on another. Something like (U can't use item 1 with item 2)
I read the help file & tried to put such a condition in the Unhandled_event. When I test the game, it gives no errors, but just as I open the inv window, select 1 item & click over another, the game crashes with the message "Invalid inventory item specified).
But my default script for using an inventory on a hotspot & using an inventory on an object works just fine.
Here's my script:
--------------------
function unhandled_event (int what, int type) {
string name;
string invent;
GetLocationName(mouse.x,mouse.y,name);
if ((what==1) && (type==4)) //Talk to any hotspot
DisplaySpeech (EGO, "I don't think the %s can talk",name);
else if ((what==2) && (type==2))//Talk to any object
DisplaySpeech (EGO, "I don't think talking with the inanimate %s will help. Try looking or interacting with the %s.",name, name);
else if ((what==1) && (type==2))//Use Hotspot
DisplaySpeech (EGO, "I don't think I can fit the %s inside my pocket",name);
else if ((what==1) && (type==1))//Look at Hotspot
DisplaySpeech (EGO, "Its not worth looking at the %s",name);
else if ((what==1) && (type==3)) {
GetInvName(player.activeinv, invent);
DisplaySpeech (EGO, "I can't use the %s with the %s",invent, name);//use inventory with hotspot
}
else if ((what==2) && (type==3)) {
GetInvName(player.activeinv, invent);
DisplaySpeech (EGO, "I can't use the %s with the %s",invent, name);//use inventory with hotspot
}
else if ((what==5) && (type==3)) {
GetInvName(player.activeinv ,invent);
DisplaySpeech (EGO, "I can't use the %s with this",invent);//use invent with invent
}
}
Can you tell me just what I'm doing wrong?
DisplaySpeech (EGO, "I can't use the %s with this %s",invent,name);//use invent with name
Above workaround seemed to work for me. I'm still using ags 255.
Hello!
I'm having the problem ONLY when I try to use 1 inventory item with another inventory item.
Using an invent item with a hotspot or object works fine. The problem is:
else if ((what==5) && (type==3)) {
GetInvName(player.activeinv ,invent);
DisplaySpeech (EGO, "I can't use the %s with this",invent);//use invent with invent
}
The error comes in the following line:
GetInvName(player.activeinv ,invent);
It says invalid inventory item.
I believe the problem is that there is no such global variable player.activeinv. Instead you should use this: character[CHARID].activeinv. :)
Are you using the default built-in inventory window, or a custom inventory?
AGS doens't set the player.activeinv variable in the default inventory window, until you exit the window. Thus, the variable is not yet set, so try game.usedinv instead:
GetInvName(game.usedinv, invent);
This will be fixed in the next version to make it consistent.
that would explain why I didn't get the error since my inventory screen is not the default.
It's always visible on screen.
:)
Hi again!
My problem got solved after I replaced
GetInvName(player.activeinv ,invent);
with
GetInvName(game.usedinv, invent);
Thanks to all of you who've answered my post. And yes I'm using the built in inventory window.
But I have another question, if I have to use 1 invent item with another, I will be calling the first selected item as "activeinv" how do I refer to the item I clicked on next ?
Say: the player tried to use a key with a note. The description of key is stored in
GetInvName(game.usedinv, invent);
But how'll I refer to the note?
It may be a stupid question but I'm really new in scripting & variables so I don't know. Please tell me.
Thanx again!
game.inv_activated
Thanx!
It works like a charm now!
:)