Is there anyway to make the player say a defualt line when I try to use an inventory item with an object/hotspot. E.g when I use say the flower with something that isn't right he'll say "That doens't need any decoration". Or would I have to program it in to say that when the player uses the flower with every other object except the right one :-X
check out
unhandled_event
in the manual
Sorry to butt in here but what would it look like if you want to use unhandled_event (int what, int type) to say something if an item is used on something that is not the right one etc .
unhandled_event (int what, int type)
{
Ã, if (type == 3)Ã, // all type 3's are inventory
Ã, {
Ã, Ã, Ã, if (character[CHARID].activeinv == ITEM_FLOWER)
Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, DisplaySpeech (CHARID, "That doesn't need any decoration");
Ã, Ã, Ã, }
Ã, }
}
Now, if you have a character, object, hotspot, etc that supports inventory click then what you may need to do is a common function on the final else of each inventory click...
On_SOMECHARACTER/ITEM/HOTSPOT/ETC_Inventory_CLICK
{
if (using the correct item)
{
// do the right thing
}
else
{
DoInvalidItem();
}
}
function DoInvalidItem()
{
if (character[CHARID].activeinv == ITEM_FLOWER)
{
DisplaySpeech (CHARID, "That doesn't need any decoration");
}
else if (character[CHARID].activeinv == ITEM_BOWLINGBALL)
{
DisplaySpeech (CHARID, "I can't bowl here.");
}
}
if there is a better way, "I" would appreciate knowing
Ok I put:
function unhandled_event (int what, int type) {
if (type == 3) // all type 3's are inventory
{
if (character[BOB].activeinv == ITEM_FLOWER);
{
DisplaySpeech (BOB, "That doesn't need a decoration");
}
But I get a Nested functions not supported error but I seemed to have got the code looking why it's supposed to, I dunno what's going on here.
Coutn the braces, you may also use the "Match Braces" feature of the editor.
If that part of the code you pasted is ALL of that function, you're missing at least 2 closing braces, so function declarations following it would be considered to be
within unhandled_event(), also there's an extra semi-colon after an if clause, see:
function unhandled_event (int what, int type) {
Ã, if (type == 3) // all type 3's are inventory
Ã, Ã, {
Ã, Ã, if (character[BOB].activeinv == ITEM_FLOWER) //removed semicolon
Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, DisplaySpeech (BOB, "That doesn't need a decoration");
Ã, Ã, }
Ã, } //Missed this
} //Missed this
You can tidy it up and make it more readible:
function unhandled_event (int what, int type) {
Ã, if (type == 3) {// all type 3's are inventory
Ã, Ã, if (character[BOB].activeinv == ITEM_FLOWER) Ã, Ã, Ã, DisplaySpeech (BOB, "That doesn't need a decoration");
Ã, }
}
Thank you it works woderfully now!