Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Alen101 on Sun 22/11/2015 05:19:28

Title: Unhandled event dont work if stuff has already been asigned with code?
Post by: Alen101 on Sun 22/11/2015 05:19:28
Im using UNHANDLED EVENT,

Code (ags) Select
if ((what==2) && (type==3)) //Use inventory on object
  {
  player.Say("Dont work.");
  }



the problem is that it works ok but not on an object with this code on it:
Code (ags) Select
function hElectdoor_UseInv()
{
if (player.ActiveInventory == iCtrluni)
{
player.Walk(130, 125, eBlock, eWalkableAreas);
player.FaceObject(oPorton, eBlock);
aClick.Play();
Wait(5);
aDoorclose.Play();
hElectdoor.Enabled = false;
oPorton.Visible = true;
player.Say("Listo, la puerta esta abierta.");
}
}

If the function "function hElectdoor_UseInv()" is running it doesnt work :(   //i think it doesnt matter the code, just that the useinv function is on.


Example: I got a garage door that opens only with an inventory item (remote control). I got a (bottle) as another inventory item.
If i use the (bottle) on the door it would be great that the "Dont work" message would be displayed, but because the function hElectdoor_UseInv() have code on it for the
remote control to open the door, if i use the bottle on the door the message wont display so the unhandled event dont work.

So is there any option for this to happen in the rigth way?:confused:???
I need it in the simple way possible because im not a programer.
Title: Re: Unhandled event dont work if stuff has already been asigned with code?
Post by: Cassiebsg on Sun 22/11/2015 10:45:11
Code (ags) Select

function hElectdoor_UseInv()
{
if (player.ActiveInventory == iCtrluni)
   {
    player.Walk(130, 125, eBlock, eWalkableAreas);
    player.FaceObject(oPorton, eBlock);
    aClick.Play();
    Wait(5);
    aDoorclose.Play();
     hElectdoor.Enabled = false;
     oPorton.Visible = true;
     player.Say("Listo, la puerta esta abierta.");
    }
else if "Don't work."; // probably the easiest solution.
}
Title: Re: Unhandled event dont work if stuff has already been asigned with code?
Post by: Khris on Sun 22/11/2015 13:04:31
Asked an answered just a few days ago: http://www.adventuregamestudio.co.uk/forums/index.php?topic=52905.msg636525113#msg636525113