Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - PERXEO

#41
Sorry for my delay for answer but I had a hard day.
I've used an empty template and I did all from zero.
The purpose of my unhandled-event function is to prepare some variables like name of the object or hotspot or character in wich we interact, the content of some properties like genre and number of these objects and the mouse coordinates. All these parameters are send to some special functions like randomUse, randomSay, randomLook, and so on . My unhandled_event function is this one:

Code: ags
function unhandled_event(int what, int type) 
{
	String locname;
	String invname;
  int generoNumero;
  int theHotSpotID;
  int theObjectID;
  int theCharacterID;
  int theInventoryItemID;
locname = Game.GetLocationName(mouse.x,mouse.y);
  
  String hotSpotProperty;
  if (what==1) //HOTSPOT
  {
    Hotspot *theHotSpot = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
    if (theHotSpot!=null)
    {
      theHotSpotID=theHotSpot.ID;
      generoNumero=hotspot[theHotSpotID].GetProperty("generoNumero");
  
    }else
    {
      Display("No hay un HOTSPOT");
      generoNumero=0;
    }
  }
  else if(what==2) //OBJECT
  {
      Object *theObject = Object.GetAtScreenXY(mouse.x, mouse.y);
      //Display("WHAT 2== %s ", theObject);
      if (theObject!=null)
    {
      theObjectID=theObject.ID;
      generoNumero=object[theObjectID].GetProperty("generoNumero");
     
    }else
    {
      Display("No hay un OBJETO");
      generoNumero=0;
      }
  }
  else if(what==3) //CHARACTER
  {
    
     Character *theCharacter = Character.GetAtScreenXY(mouse.x, mouse.y);
      if (theCharacter!=null && theCharacter!=cPerxeo)
    {
      theCharacterID=theCharacter.ID;
      generoNumero=character[theCharacterID].GetProperty("generoNumero");
    
    }else
    {

      generoNumero=0;
      }
  }
  else if (what==5)//objeto de inventario
  {
   InventoryItem  *theInventoryItem= InventoryItem.GetAtScreenXY(mouse.x,  mouse.y);
   if (theInventoryItem!=null)
   {
     theInventoryItemID=theInventoryItem.ID;
     generoNumero=inventory[theInventoryItemID].GetProperty("generoNumero");
    }else
    {
      Display("No hay un objeto de inventario");
      generoNumero=0;
     }
   }
	RandomLook(locname,  generoNumero,  mouse.x,  mouse.y);
	}
	else if ((what==1)&&(type==2)) {
    //si se interactua con algun hotspot

	RandomUse(locname,  generoNumero,  mouse.x,  mouse.y);
	}else if ((what==1)&&(type==3)) {

    //usar inventario en HOTSPOT OPCION 2 PARA HACER UNHANLED EVENTS ENTRE UN INVENTARIO Y UN HOTSPOT
    String cosa=player.ActiveInventory.Name;
    int idInv=player.ActiveInventory.ID;
    int generoInv=inventory[idInv].GetProperty("generoNumero");
	RandomInvUse(locname,  generoNumero,  cosa,  generoInv,  mouse.x,  mouse.y);
	}
	else if ((what==1)&&(type==7)) {
//COGER UN HOTSPOT
		RandomPickUp(locname,  generoNumero,  mouse.x,  mouse.y);
	}else if ((what==2)&&(type==5)) {
//COGER UN OBJETO
		RandomPickUp(locname,  generoNumero,  mouse.x,  mouse.y);
	}
  else if ((what==5)&&(type==0))
  {
    RandomLook(locname, generoNumero,  mouse.x,  mouse.y);  
  // mirar inventario  
  } 
   else if ((what==5)&&(type==3))
  {
    //usar objeto de inventario en otro
    player.Say("Usar eso asi, no tiene ningun sentido");
    RandomUse(locname, generoNumero,  mouse.x,  mouse.y);
  } else if ((what==1)&&(type==4))
  {
    RandomSay(locname, generoNumero,  mouse.x,  mouse.y);
  } else if ((what==2)&&(type==2))
  {
    RandomSay(locname, generoNumero,  mouse.x,  mouse.y);
  } else if ((what==5)&&(type==2))
  {
    RandomSay(locname, generoNumero,  mouse.x,  mouse.y);
  }
  

}
#42
I really appreciate the interest you show in the doubts that newbies like me raise. What I mean by the fact that the event occurs with an action is the following, which I best explain with an example.
You click on a hotspot in the scene, with the verb see, in some x,y coordinates, for example. The AGS engine, which does not have this event to watch for this hotspot, collects the name of the element that is in said hotspot with this code:

Code: ags
function unhandled_event(int what, int type) 
{
String locname;
String
locname = Game.GetLocationName(mouse.x,mouse.y);

At this moment, the name of the hotspot on which the cursor is positioned is taken in the locname variable. But while the player character walks towards that point, if we move the cursor and interfere with it, the value of locname changes, because another unhandled event fires. That's why I asked "at what moment does the unhandled event fire" and I see that it is not only activated with the first click, but also with the fact that the player character crosses the path of the cursor.
#43
Thanks, although I knew how the unhandled_event function works, what I was not clear about is "exactly" when the event is fired and I see that it jumps at any time when the action changes, not only on the initial click.
#44
I have a code snippet for unhandled_events, which I want to use to give special responses to certain unhandled events.
Code: ags
function unhandled_event(int what, int type)
{
String locname;

locname = Game.GetLocationName(mouse.x,mouse.y);
  int randomNumber=Random(100);
  int usemode=game.used_mode;
  gLabelAction.Text=String.Format("%s, %d, %d", locname, randomNumber, usemode);
...
}


The gLabelAction tag is a label that I use to show the typical text in the status bar, to indicate "Use xxxx" or "View xxxx" LucasArts style.
When I hover over a hotspot, the text initially appears fine, with the name of the hotspot, but when the player hovers over the cursor, the unhandled event is updated with the name of my player. This invalidates the usage because it now says things like "Use this Peter" or "Look at this Peter" instead of "Use this piano" or "Look at this piano" which would be desirable. The randonNumber is only to show me that the unhandled event changes over the time.
What triggers the unhandled-events? on a click? are they like repeatedly-executed? How can I restrict it to the first click on a hotspot?
#45
Thanks to all!! REALLY FANTASTIC ANSWERS!!
very grateful for everything! I already have it solved!!
#46
THANKS! MERCI! GRACIAS! DANKE!
For me this issue is greatefully solved!!! :smiley:
#47
Hi Khris!! Thanks a million for your patience! Now it works and it's fantastic, but I still have some residual doubts that still have me a little absorbed.
1) Why can't I click the right mouse button when I've the cursor over the inventory GUI area, in order to change the cursor mode with the function

Code: ags
....
 else if (button == eMouseRight)
  {
    // right-click, so cycle the mouse cursor mode
    Mouse.SelectNextMode();
   
  }
....

2) Why when I try to open the inventory from the button of a status bar GUI, with the function  ....
Code: ags
function btnInvOut_OnClick(GUIControl *control, MouseButton button)
{
 // player.Say("OPEN THE INVENTORY");
 
 gInv.X=(Screen.Width-gInv.Width)/2;
 gInv.Y=(Screen.Height-gInv.Height)/2;
 //Mouse.Mode = eModeInteract;
 Mouse.EnableMode(eModeUseinv);
 Mouse.Mode = eModeUseinv;
 gInv.Visible=true;
 
}


....the mode of the cursor to which I am indicating is not changed?

3) Why can't I change the cursor mode to eModeUseInv using the inventory gui button called "btnChangeMode" that I have for it, with this function?

Code: ags
function btnChangeMode_OnClick(GUIControl *control, MouseButton button)
{
  player.Say("CLICK TO CHANGE MODE");
  player.ActiveInventory=null;
  mouse.Mode=eModeUseinv;
  mouse.EnableMode(eModeUseinv);
  
}

#48
Thanks...i'll try it!
#49
Sorry to be insistent and boring with this topic... but I'm pretty stuck and I can't move on.
I have an inventory that appears to be fine. If I set the parameter "Override built-in inventory window click handling" to false, but only for inventory objects to which I have assigned a function that is:
Code: ags
function useGeneric()
{
  InventoryItem * currentThing = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
  String nameCurrentThing=CurrentThing.Name;
  String whatThing=player.ActiveInventory.Name;
  player.Say("I'll use %s with %s.", whatThing, currentThingname);
}

 Conversely, if I set the parameter "Override built-in inventory window click handling" to true, to apply your methods, this doesn't work well.
When I open the inventory window whit this function
Code: ags
function btnInvSelect_OnClick(GUIControl *control, MouseButton button)
{
  player.Say("PULSO BOTON INVSELECT DEL INVENTARIO");
  mouse.Mode = eModeInteract;
  //mouse.Mode = eModePickup;
  //mouse.Mode= eModeUseinv;
}

the only one mode I can use is eModeInteract. The others dont's work!!.

If I try to use your method

Code: ags
function on_mouse_click(MouseButton button)
{

  if (IsGamePaused())
  {
    // game is paused, so do nothing (i.e. don't process mouse clicks)
  }
  else if (button == eMouseLeftInv)
  {
    player.Say("USING LEFT BUTTON ON INVENTORY on %d ", game.inv_activated);
     if (mouse.Mode == eModeUseinv && player.ActiveInventory != null) {
      objetoUno = inventory[game.inv_activated];
      objetoDos = player.ActiveInventory;
      if (Combine() == false) 
      {
        player.Say("COMBINE == FALSE");
        objetoUno.RunInteraction(eModeUseinv);
      }else
      {
        player.Say("ELSE");
       }
    } 
  }
}

I can't never enter in if (mouse.Mode == eModeUseinv && player.ActiveInventory != null) because the mouse.Mode is not eModeUseinv...and I don't know how to set it!!!

Thanks for your help!!! and sorry for my insistence!!
Could I be missing some code or some event in the inventory objects?
Am I missing some way to use the buttons?
Will it have to do with the standard mode of the cursors?
#50
Thanks for your answer. What I have in the scene is an inventory that appears in the middle of the scene.


This inventory has a button mistakenly called gInvSelect (the one I marked with a green arrow) that when pressed, calls the function that I put below.
Code: ags
function gInvSelect_OnClick(GUIControl *control, MouseButton button)
{
  //mouse.Mode = eModeInteract;
  //mouse.Mode = eModePickup;
  mouse.Mode= eModeUseinv;
}
It is at that moment when the cursor should be put in interact mode to be able to choose an object of inventory and being able to use it with another inventory object for example to be able to apply your snippet of combined use of two objects, in both directions.

From what you tell me then, by activating the option "Override built-in inventory window click handling" my button should no longer be necessary, but I would like that when I press my button, I could already connect it with the code you gave me before for the combined use of objects in both directions.
And this is where I am lost...
#51

If I have this parameter



set to true, what is the cursor mode that should be used to be able to interact with the inventory objects?
If my inventory butom for select inventory objects is gInvSelect, this is the correct code?

Code: ags
function gInvSelect_OnClick(GUIControl *control, MouseButton button)
{
  mouse.Mode = eModeInteract;
  //mouse.Mode = eModePickup;
}
#52
I understand that you mean this, right?

Even though I'm setting it to true, it still doesn't work for me....
#53
I understand all that you wrote me, but in this snippet
Code: ags
/ called when a mouse button is clicked
function on_mouse_click(MouseButton button)
{
  if (IsGamePaused())
  {
    // game is paused, so do nothing (i.e. don't process mouse clicks)
  }
  else if (button == eMouseLeft)
  {
    player.Say("USING LEFT BUTTON NORMALLY");
    // left-click, so try using the current mouse cursor mode at this position
    Room.ProcessClick(mouse.x, mouse.y, mouse.Mode);
  }
  else if (button == eMouseRight)
  {
    // right-click, so cycle the mouse cursor mode
    Mouse.SelectNextMode();
  }
  else if (button == eMouseLeftInv)
  {
    player.Say("USING LEFT BUTTON ON INVENTORY");
     if (mouse.Mode == eModeUseinv && player.ActiveInventory != null) {
      objetoUno = inventory[game.inv_activated];
      objetoDos = player.ActiveInventory;
      if (Combine() == false) 
      {
        player.Say("COMBINE == FALSE");
        objetoUno.RunInteraction(eModeUseinv);
      }else
      {
        player.Say("ELSE");
       }
    } 
  }
}

 I can't get the code to go through the else if (button == eMouseLeftInv) check regardless of whether the inventory is open or not. It always goes through the above check: else if (button == eMouseLeft) and I don't know what I'm doing wrong...
#54
Thanks!!! As effective as always!!
#55
I've obtained this error:

Code: ags
Error (line 664): Variable 'bool' is already defined

in this line:

Code: ags
function bool Combine() {
  if (IsItems(iLicuadora, iNaranja)) { // el orden no importa aqui 
    return true;
  }
  else
  {
    return false;
  }
}
#56
I've tried to use this code but ... i Can't not understand it. Maybe it's a bit confused to me. I don't know exactly where must I insert every snippet of code, and I don't understand what means this part: 

Code: ags
  if (button == eMouseLeftInv) {
    if (mouse.Mode == eModeUseinv && player.ActiveInventory != null) {
      one = inventory[game.inv_activated];
      two = player.ActiveInventory;
      if (!Combine()) one.RunInteraction(eModeUseinv);
    }
  }

If (!Combine()) one.RunInteraction(eModeUseInv); ... it's not finished and I don't understand what exactly means 
#57
What is the best place and the best method to determine if an object is solid or not? I mean to know in which part of the code should this type of thing be initialized? That is, at what point should I set oObjectX.Solid=true? In roomxxx.asc? In globalScript.asc?
#58
oh my god! Thanks!! What a complete answer!
#59
Code: ags
function oCacerolas_PickUp()
{
 cPerxeo.Walk(1037, 938, eBlock, eWalkableAreas);
  cPerxeo.FaceDirection(eDirectionUpRight);
  cPerxeo.LockView(3);
  cPerxeo.Animate(0, 0, eOnce, eBlock);
  Wait(2);
  oCacerolas.Visible=false;
  player.AddInventory(iCacerolas);
  cPerxeo.Say("I've the pans with me!!!.");
  cPerxeo.LockView(1);
  cPerxeo.UnlockView();
  cPerxeo.FaceDirection(eDirectionUpRight);
  
}
#60
I have an animation where a character reaches down to pick up something on the ground, but I can't make the object disappear at just the right moment. The animation is too long and I wish it could know exactly which frame the frame where the object is taken is in, to make a call just at that moment so that it disappears at the right moment. I've sometingh like that:
SMF spam blocked by CleanTalk