Having unusual difficulity with Part 4 of the Getting Started tutorial

Started by gollier, Thu 14/02/2008 22:46:08

Previous topic - Next topic

gollier

So, I'm making a test game to get a good handle on building an AGS game.  I got to Part 4 of the tutorial, and created the oKey and iKey objects.

I also added the script here: 

function oKey_Interact()
{
  oKey.Visible = false;
  player.AddInventory(iKey);
}

However, when I run the game, I can't interact with the key in any way.  The key doesn't disappear or go into my inventory at all.  This is the same case when I attempt writing the code as function oKey_PickUp.

Can anyone help me understand what I'm doing wrong here?

monkey0506

If the function isn't properly linked then it won't be called. In the Room Editor pane, select the object in question, oKey, and then select the Events pane (the lightning-bolt icon immediately above "Appearance, Description, Image, ...") and then make sure you have the name of the function typed exactly into the name of the appropriate interaction event. So for "oKey_Interact" you would put that in the event labeled as "Use object".

Of course this is just what the tutorial tells you, but if you accidentally missed it that would explain why it isn't working.

Otherwise I don't really see where you could be going wrong. So long as you have the function name typed exactly the same in the Events pane and in the script...

gollier

OK, I've looked back over the object events pane, but nothing seems to be wrong.  oKey_PickUp is entered inside the "Pick up object" textbox.

I'm fairly certain this is just a linkage issue, but I'm still confused.

monkey0506

It might be a stupid question...but you're putting this in the room script right? I don't think it would compile otherwise, yet I don't see where you've done anything wrong.

Perhaps there's an issue with your click-processing? For that we would need to see any on_mouse_click functions you've got. Probably only just the one from your Global Script, but if you're using any script modules they may have one as well.

gollier

Yeah, it's in the room's script.

I don't think I'm having any problem with clicking, because I'm able to view and interact with hotspots perfectly fine.  It's just with this object where I'm running into problems.

Khris

PickUp won't work by default since it's not set as standard cursor mode.
Stick to Interact for now.

Could you do this:
Open the room and make sure that the Room script's tab is closed.
Switch to the objects, select the key from the dropdown menu below the tree, click the bolt icon, then click on the ...-button in the "Interact object" line.
AGS should now open the room script tab and move the cursor to the line saying "function oKey_Interact()". (Which btw you should never have had to type yourself; AGS should have created this function for you.)

To make sure it isn't something else, try to create another, fresh object using a big sprite, add the Interact link, then simply put a "Display("test");" inside the function.

monkey0506

Quote from: KhrisMUC on Fri 15/02/2008 03:15:54(Which btw you should never have had to type yourself; AGS should have created this function for you.)

Actually, I always type the function myself. :P


monkey0506

Because...automation is the devil! :=

Also, I usually like to sort of name things the way I want them. I'd use oKey_Use not oKey_Interact but I grew up on Monkey Island.

Wait...I wish I grew up there...then I could wander around asking people what they meant when they asked what happened to my pants.

I grew up playing Monkey Island. :-*

Khris

Yeah, that's fine, but once you've typed your custom function name into the event list window and clicked the ...-button, AGS still creates the function in the script, right?

Edit: actually, it doesn't. Wow. That's really weird. Almost like a bug.

gollier

Hey Khris, I tried changing the code from oKey_PickUp to oKey_Interact, and that basically did the trick! Thank you very much.

I still don't understand why the PickUp function won't work the same as the Interact function, though.  I mean, I understand that the Interact code works by whatever you type in, but I assumed the PickUp function would work anyway.

Khris

It doesn't matter what you've entered next to "Pick up object"; by default, it will never get called.
If you want a separate PickUp-action, go to the mode's cursor properties (in the tree, expand Mouse cursors, then double-click 5: Pick Up) and set StandardMode to true.
Now you can switch to PickUp mode in-game by right clicking a few times and if you click on an object using the PickUp mode, AGS will now call whatever function is entered next to "Pick up object".

SMF spam blocked by CleanTalk