[SOLVED] MI-9 Nothing Activating when Using/Looking At an Item

Started by Ewery1, Wed 01/01/2014 00:02:19

Previous topic - Next topic

Ewery1

In the MI-9 style, nothing activates when I do something with an item. This is the script for the items:

Code: ags
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...

Khris

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.

Ewery1

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.

Khris

Weird, works fine for me.

One thing you could do (and should, anyway) is to add
Code: ags
  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.

Ewery1

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
  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
  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
  else Unhandled();

it showed the text from Unhandled, but nothing I put there.

Khris

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()?

Ewery1

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.

Ewery1

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
  if (UsedAction(eGA_LookAt)) {

Khris

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.

Ewery1

I'm not getting any actions while doing anything to the pants. Also the right click doesn't work.

Khris

At this point you should probably zip the entire folder and upload it somewhere so we can take a look.

Ewery1

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)

Khris

Without the actual source files, you're on your own, sorry.

Ewery1

Alright, I'm going to try grabbing the unedited files and replacing the edited ones.


Ewery1

(By the way it is very much a wip me experimenting with stuff. The art is awful XD)

Khris

Don't worry :)
The file is broken though. It's 1.3MB, is that correct?


Khris

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
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.

Ewery1

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.

SMF spam blocked by CleanTalk