function Object_UseInv()[Not working]

Started by Icey, Mon 14/03/2011 00:26:34

Previous topic - Next topic

Icey

For some reason I cant get the inv item on a obj. However I I can use the other command option on it like interact.

I thought something was blocking me for touch the Obj but I was wrong. The _UseInv was taking from another room which it worked in. If nothing else in the code works th "if" line + thing inside should work just fine.




Code: ags

function Shiva_UseInv()
{
  //Attack
if(Dave.ActiveInventory == com1)
{
    Dave.ChangeView(28);
    Dave.Animate(2, 3, eOnce, eBlock, eForwards);
   
  EnemyST -= 5;
   Dave.ChangeView(26);
   Dave.FaceObject(Shiva, eBlock);
  //Attack
 
  tifa.ChangeView(16);
    tifa.Animate(2, 4, eOnce, eBlock, eForwards);
 playerHP += 7;
 tifa.ChangeView(10);
   tifa.FaceObject(Shiva, eBlock);
  //----------------------------------------------------------
}
  
  if(EnemyST <= 0){
    adeath.Play(eAudioPriorityHigh); //Play death sound
  Shiva.TweenTransparency(1.0, 100);
 
  GiveScore(125);
  Shiva.Visible = false;
  HUD.TweenTransparency(0.5, 100);
  HUD.Visible = false;
  mouse.EnableMode(eModeTalkto);
  mouse.EnableMode(eModeWalkto);
  mouse.EnableMode(eModeLookat);
  gGui5.Clickable = true;
  party.Clickable = true;
    gGui5.TweenTransparency(0.1, 0);
    party.TweenTransparency(0.1, 0);
    gGui5.Visible = false;
party.Visible = false;

Dave.Say("Yeah we did it! Let's head back ok.");
//Play fanfare.
mouse.Visible = true;
Spoils.Visible = true;
qu3.Visible = false;
tifa.ChangeRoom(9, 312, 1206);
}
  //timer death---------------------------------<><><>

  
  //--------------------------------------------<><><>
  if(playerHP <= 1){
  playerHP -= 10;//player lose HP (Place here)
if(playerHP <= 0){
 CountDown.Stop();
 Dave.SayAt(8, 167, 320,"Dave:Is this it?.");
adeath.Play(eAudioPriorityHigh);
 Dave.Tint(204, 0, 0, 50, 0);
 tifa.Tint(204, 0, 0, 50, 0);
 gameover.TweenTransparency(0.1, 100);
Dave.TweenTransparency(1.5, 100);
  tifa.TweenTransparency(1.5, 100);
  aBoss1a.Stop();
  gameover.Visible = true;
  gameover.TweenTransparency(2.0, 0);
  Wait(19);
  RestartGame();
  
}
  }
}
function Shiva_Interact()
{
  Dave.SayAt(8, 167, 320,"Dave:Is this it?.");
//Attack
    Dave.ChangeView(28);
    Dave.Animate(2, 3, eOnce, eBlock, eForwards);
   
  EnemyST -= 5;
   Dave.ChangeView(26);
   Dave.FaceObject(Shiva, eBlock);
  //Attack
 
  tifa.ChangeView(16);
    tifa.Animate(2, 4, eOnce, eBlock, eForwards);
 playerHP += 7;
 tifa.ChangeView(10);
   tifa.FaceObject(Shiva, eBlock);
  //-------------------------
}

monkey0506

Without even looking at your code (at all), I'm going to diagnose your problem, based entirely off of what you've said that you've done. If I'm wrong, feel free to call me an arrogant prat. :=

Quote from: Studio3 on Mon 14/03/2011 00:26:34The _UseInv was taking from another room which it worked in.

You've copied and pasted the function from one room script to the other, haven't you? And you haven't linked the function in the object's events pane, have you? If you don't know what I mean about this second question..if you've copied and pasted the function from one room script to the other, you will have to go to the object's events pane and paste the name of the function in the appropriate box for the event handler.

Icey

#2
I edited the script to work with the obj. That's why I said when I take the first part of the script and copy it to the interaction area the code works.

I don't think that your a arrogant prat for saying that but I already know to do that.

monkey0506

You're still describing the exact same scenario that I described. You've copied and pasted the UseInv function from one room script to another. When you move the code from said UseInv function to the Interact function for the same object, it works. Why? Because the Interact function is linked via the Events pane for the object because you didn't copy the function from another script, you used the Events pane to create the function, and added your code later. The reason the UseInv function is not working is most likely because you did not link it in the Events pane. At least, if you did, you still have not given indication that you did.

Even if I am wrong about the function not being linked via the Events pane, you've given no indication as to what results you are actually getting. As far as I can tell your code looks like it should at least be executing something if the function is being called, but since you intentionally go out of your way to mess with the indentation (which is handled automatically for you) and make your code unreadable, it's kind of hard to tell.

Icey

Wait I just thought about something. My PC shut off and the obj lost the command to do the stuff in the script yet every thing in the script was still there.

SMF spam blocked by CleanTalk