Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Ewery1 on Wed 01/01/2014 00:02:19

Title: [SOLVED] MI-9 Nothing Activating when Using/Looking At an Item
Post by: Ewery1 on Wed 01/01/2014 00:02:19
In the MI-9 style, nothing activates when I do something with an item. This is the script for the items:

Code (ags) Select
function iBook_AnyClick()
{
  if (UsedAction(eGA_LookAt)) {
    dBook.Start();
  }
}

function iSheet_AnyClick()
{
  if (UsedAction(eGA_LookAt)) {
    cRachel.Say("It's my bedsheet.");
  }
  if (UsedAction(eGA_UseInv)) {
    if (cRachel.ActiveInventory == iPants) {
      cRachel.AddInventory(iSPTT);
      cRachel.LoseInventory(iSheet);
      cRachel.LoseInventory(iPants);
      cRachel.Say("I tied my pants and sheet together. It looks like a rope now.");
    }
  } 
}

function iPants_AnyClick()
{
  if (UsedAction(eGA_LookAt)) {
    cRachel.Say("It's my pants.");
  }
  if (UsedAction(eGA_UseInv)) {
    if (cRachel.ActiveInventory == iSheet) {
      cRachel.AddInventory(iSPTT);
      cRachel.LoseInventory(iSheet);
      cRachel.LoseInventory(iPants);
      cRachel.Say("I tied my pants and sheet together. It looks like a rope now.");
    }
  } 
}


And Khris, I did what you said in the last post. It worked temporarily but for some reason now it doesn't want to work...
Title: Re: MI-9 Nothing Activating when Using/Looking At an Item
Post by: Khris on Wed 01/01/2014 04:47:18
Did you copy-paste those functions into the script?
Because you need to link them to the event.

AGS isn't going to even look for those functions unless they are entered in the events pane.
Title: Re: MI-9 Nothing Activating when Using/Looking At an Item
Post by: Ewery1 on Wed 01/01/2014 05:12:45
Quote from: Khris on Wed 01/01/2014 04:47:18
Did you copy-paste those functions into the script?
Because you need to link them to the event.

AGS isn't going to even look for those functions unless they are entered in the events pane.

Yup, I did. In the events pane it says i(item)_AnyClick for each event.
Title: Re: MI-9 Nothing Activating when Using/Looking At an Item
Post by: Khris on Wed 01/01/2014 16:23:41
Weird, works fine for me.

One thing you could do (and should, anyway) is to add
Code (ags) Select
  else Unhandled();
at the end, in order to avoid the game doing nothing upon certain actions.

You can also put a Display("Function is called."); at the start of the function to try and isolate the problem.
Title: Re: MI-9 Nothing Activating when Using/Looking At an Item
Post by: Ewery1 on Wed 01/01/2014 23:43:26
Quote from: Khris on Wed 01/01/2014 16:23:41
Weird, works fine for me.

One thing you could do (and should, anyway) is to add
Code (ags) Select
  else Unhandled();
at the end, in order to avoid the game doing nothing upon certain actions.

You can also put a Display("Function is called."); at the start of the function to try and isolate the problem.

I have tried
Code (ags) Select
  else Unhandled();
and I have used it for all of the physical things in the room. Oh one thing I forgot to mention, when using
Code (ags) Select
  else Unhandled();
it showed the text from Unhandled, but nothing I put there.
Title: Re: MI-9 Nothing Activating when Using/Looking At an Item
Post by: Khris on Thu 02/01/2014 01:28:29
So the function gets called. Are you actually looking at the items? As opposed to pushing or opening them?

And what do you mean by "nothing I put there"? Where? In Unhandled()?
Title: Re: MI-9 Nothing Activating when Using/Looking At an Item
Post by: Ewery1 on Thu 02/01/2014 18:59:57
Quote from: Khris on Thu 02/01/2014 01:28:29
So the function gets called. Are you actually looking at the items? As opposed to pushing or opening them?

And what do you mean by "nothing I put there"? Where? In Unhandled()?

I meant to say nothing I put there. And yes, I am looking and doing use with.
Title: Re: MI-9 Nothing Activating when Using/Looking At an Item
Post by: Ewery1 on Mon 17/02/2014 01:23:06
Okay so I did the display thing, and yes, it showed up, but not the part where it says "It's my pants." So I think the problem is with:

Code (ags) Select
  if (UsedAction(eGA_LookAt)) {
Title: Re: MI-9 Nothing Activating when Using/Looking At an Item
Post by: Khris on Mon 17/02/2014 01:34:26
So the AnyClick function gets called, but UsedAction(eGA_LookAt) is false even though you're looking at the item?
What happens if you right-click the pants item? (the default right-click action should be "look at").

Are you getting "It's my pants" for any other action? The template can be tricky when it comes to the order of the verb buttons; maybe something got mixed up and the "look at" button isn't mapped to the "look at" action.
Title: Re: MI-9 Nothing Activating when Using/Looking At an Item
Post by: Ewery1 on Mon 17/02/2014 13:46:44
I'm not getting any actions while doing anything to the pants. Also the right click doesn't work.
Title: Re: MI-9 Nothing Activating when Using/Looking At an Item
Post by: Khris on Mon 17/02/2014 14:03:03
At this point you should probably zip the entire folder and upload it somewhere so we can take a look.
Title: Re: MI-9 Nothing Activating when Using/Looking At an Item
Post by: Ewery1 on Mon 17/02/2014 19:30:05
I edited some lines in the GlobalScript.asc and the guiscript.asc so I think that it is a problem with one of those. I am putting the information on pastebin, too many characters to put on here:

GlobalScript.asc: http://pastebin.com/mHuEezB7

guiscript.asc: http://pastebin.com/AyGRgiMT

(I'm fairly certain it is a problem with the GlobalScript)
Title: Re: MI-9 Nothing Activating when Using/Looking At an Item
Post by: Khris on Mon 17/02/2014 22:09:57
Without the actual source files, you're on your own, sorry.
Title: Re: MI-9 Nothing Activating when Using/Looking At an Item
Post by: Ewery1 on Mon 17/02/2014 22:28:31
Alright, I'm going to try grabbing the unedited files and replacing the edited ones.
Title: Re: MI-9 Nothing Activating when Using/Looking At an Item
Post by: Ewery1 on Mon 17/02/2014 22:54:33
Alright, I'm uploading the source zip files: Here you go:

https://www.mediafire.com/?968ql88k2l683nc
Title: Re: MI-9 Nothing Activating when Using/Looking At an Item
Post by: Ewery1 on Mon 17/02/2014 22:56:33
(By the way it is very much a wip me experimenting with stuff. The art is awful XD)
Title: Re: MI-9 Nothing Activating when Using/Looking At an Item
Post by: Khris on Mon 17/02/2014 23:38:53
Don't worry :)
The file is broken though. It's 1.3MB, is that correct?
Title: Re: MI-9 Nothing Activating when Using/Looking At an Item
Post by: Ewery1 on Mon 17/02/2014 23:45:24
Yes, hold on lemme try it again.
Here: https://www.mediafire.com/?968ql88k2l683nc
Title: Re: MI-9 Nothing Activating when Using/Looking At an Item
Post by: Khris on Tue 18/02/2014 00:10:08
Found the error: for inventory items, the template actually relies on different event handlers.
In other words, even though you're looking at the pants, the game's action isn't set to eGA_LookAt because you're supposed to use a separate function and don't need to check UsedAction(eGA_LookAt).

If you clear AnyClick from the "look at item" field, then click the ...-button, you'll get iPants_Look, then just do this:
Code (ags) Select
function iPants_Look()
{
  cRachel.Say("It's my pants.");
}


Edit: I thought I remembered this: http://www.adventuregamestudio.co.uk/forums/index.php?topic=49759.msg636477030#msg636477030
In there I actually mentioned you have to use the dedicated look at event. I also posted the quote from the manual though, which wrongly states to use otherclick for all verbs.
Title: Re: MI-9 Nothing Activating when Using/Looking At an Item
Post by: Ewery1 on Tue 18/02/2014 00:20:40
Oh yah, for that I took your Otherclick advice, except named it anyclick. Tha ks so much! I'll test this out in a few seconds.
Title: Re: MI-9 Nothing Activating when Using/Looking At an Item
Post by: Ewery1 on Tue 18/02/2014 01:32:48
Yay! It worked :D Thanks so much Khris!