YolkfolkThe Dizzy Fansite 1 logged in0 playing
Community discussion

Code problem

Started by A Cool Guy on 20 August 2010 • 3,737 views

6 posts
#54784

Im trying to write the code so it dosent matter which order i give the 2 items however i want it so if i give item 1 first it says i still need item 2 and if i give item 2 first then say it still needs item 1 and if i given both items then disappear this is what i done so far but i cant get it working right so any help please.

func ActionObject_2(idx) 
{
    if (ObjGet(ObjFind(2),O_STATUS) == 0)
	   {
            Message1(5,4,"Hey i need 2 items");
            MessagePop();
            Message2(5,4,"ok i'll get them for you.");
            MessagePop();
            Message1(5,4,"thanks.");
            MessagePop();
            ObjSet(ObjFind(2),O_STATUS,1);
      }
else
{
    idx = OpenDialogInventory();
    if(idx!=-1) UseObject(idx);
}
}

func UseObject_2(idx)
    {
        itemid=ObjGet(idx,O_ID);
        if (ObjGet(ObjFind(2),O_STATUS) == 1)
            {
            if(itemid==26 && ObjGet(ObjFind(28),O_DISABLE) != 1)
	        {
            Message0(5,4,"Thanks i still need item 2.");
            MessagePop();
            InventorySub(idx);
            ObjSet(ObjFind(26),O_DISABLE,1);
            //ObjSet(ObjFind(2),O_STATUS,2);
            }
           
           else
           {
           Message0(5,4,"Thanks.");
           MessagePop();
           ObjSet(ObjFind(26),O_DISABLE,1);
           ObjSet(ObjFind(2),O_DISABLE,1);
           ObjSet(ObjFind(2),O_DRAW,0);
		   GameCommand(CMD_REFRESH);
           }
         
          if(itemid==28 && ObjGet(ObjFind(26),O_DISABLE) != 1)
          {
          Message0(5,4,"Thanks i still need item 1.");
          MessagePop();
          InventorySub(idx);
          ObjSet(ObjFind(28),O_DISABLE,1);
           // ObjSet(ObjFind(2),O_STATUS,2);
          }
          else
           {
           Message0(5,4,"Thanks.");
           MessagePop();
           ObjSet(ObjFind(28),O_DISABLE,1);
           ObjSet(ObjFind(2),O_DISABLE,1);
           ObjSet(ObjFind(2),O_DRAW,0);
		   GameCommand(CMD_REFRESH);
           }
           }
          else if(itemid !=26 || itemid !=28)
{
Message1(5,4,"That's not the items.");
MessagePop();
DropObject(idx);
} 
}

 

👍 0
#71432
I think it's something like this.. lol im not sure, i've not done it myself.
But with this he says the same message whatever item you give him..and when both items are giving the puzzle would be completed and then you can disable whatever it is you need to disable.

But im not 100?% sure if this is correct.


func UseObject_***( idx )
{
if(idx==ObjFind(***) || idx==ObjFind(***))
{
Message1(2,0,"Thanks");
MessagePop();
InventorySub(idx);

status = ObjGet(ObjFind(***),O_STATUS);
ObjSet(ObjFind(***),O_STATUS,status+1);
if(ObjGet(ObjFind(***),O_STATUS)==3) {

Message1(2,0,"Thats both of them/ puzzle finished");
MessagePop();

}
}
else
{
DropObject(idx);
}
}

func ActionObject_***( idx )
{
if(ObjGet(ObjFind(***),O_STATUS)==0)
{
Message1(2,0,"Dizzy i need two items"); MessagePop();
ObjSet(ObjFind(***),O_STATUS,1);
}
else
{
DropObject(idx);
}
}
👍 0
#71433
Thanks but i dont want the same message for the 2 items as they are different items.
👍 0
#71434
Well you can just change that so something like this,
But you need to make sure the status is updated after each one.


if(ObjGet(idx,O_ID)==***)
{

Message1(5,2," Item one");
MessagePop();
InventorySub(idx);
GameCommand(CMD_REFRESH);
return;
}
else
if(ObjGet(idx,O_ID)==***)

{

Message1(5,2,"Item 2");
MessagePop();
InventorySub(idx);
GameCommand(CMD_REFRESH);
return;
👍 0
#71453

Try this, I've checked it on a mini game and it works:
object 25 is the person needing two items
initial status at 0 and dynamic, class action
object 26 is item one
object 27 is item two
object 28 is an invisible dynamic object to check which item given
initial status 0, but set as matt (invisible)
and leave the class at none so it can't be actioned and ensures
that the status of 25 stays at 1 for the 'use object' function.

func ActionObject_25() //person needing two items
{
if (ObjGet(ObjFind(25), O_STATUS) == 0) //first time of talking
{
Message2 (4,4, ""I NEED TWO ITEMS"");
MessagePop();
ObjSet(ObjFind(25), O_STATUS, 1);
return;
}

if (ObjGet(ObjFind(25), O_STATUS) == 1)
{
idx = OpenDialogInventory();
if (idx!=-1) {UseObject(idx);}
}
}

func UseObject_25(idx) //person needing two items
{
     if (idx == ObjFind(26)) //item one
     {
          InventorySub(idx);
          if (ObjGet(ObjFind(28), O_STATUS) == 1) //already given item two
          {
          Message2 (4,4, ""THANKS, THAT'S nBOTH ITEMS"");
          MessagePop();
          ObjSet(ObjFind(25), O_DISABLE, 1);
          ObjSet(ObjFind(28), O_DISABLE, 1);
          return;
          }

          else
          {
          Message2 (4,4, ""THANKS, BUT I STILL nNEED ITEM TWO"");
          MessagePop();
          idx = ObjFind(28);
          ObjSet(idx, O_STATUS, ObjGet(idx, O_STATUS) +1); 
          }
     }

      if (idx == ObjFind(27)) //item two
     {
          InventorySub(idx);
          if (ObjGet(ObjFind(28), O_STATUS) == 1) //already given item one
          {
          Message2 (4,4, ""THANKS, THAT'S nBOTH ITEMS"");
          MessagePop();
          ObjSet(ObjFind(25), O_DISABLE, 1);
          ObjSet(ObjFind(28), O_DISABLE, 1);
          return;
          }

          else
          {
          Message2 (4,4, ""THANKS, BUT I STILL nNEED ITEM ONE"");
          MessagePop();
          idx = ObjFind(28);
          ObjSet(idx, O_STATUS, ObjGet(idx, O_STATUS) +1); 
          }
     }

     else
     {
     DropObject(idx);
     }
}
👍 0
#71454
Thanks a million grandad i was stuck on that for a while LoL
👍 0