Defualt Inventory Lines [SOLVED]

Started by Krazy, Tue 25/01/2005 23:11:59

Previous topic - Next topic

Krazy

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
My Stuffs:
Tumblr

Etcher Squared Games

check out

unhandled_event

in the manual
website: http://www.etcher2games.com/
email: etcher2games@yahoo.com
forum: http://www.etcher2games.com/forums

Anyone want to make my website for free?

Candle

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 .

Etcher Squared Games

#3
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
website: http://www.etcher2games.com/
email: etcher2games@yahoo.com
forum: http://www.etcher2games.com/forums

Anyone want to make my website for free?

Krazy

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.
My Stuffs:
Tumblr

Gilbert

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");
Ã,  }
}

Krazy

#6
Thank you it works woderfully now!
My Stuffs:
Tumblr

SMF spam blocked by CleanTalk