Scripting - Picking up items? - Need Help!!

Started by Iceshoot, Wed 17/02/2010 22:39:39

Previous topic - Next topic

Iceshoot

Ok then..

Well i am currently following the tutorial, and now it came around to making my first object.
It said, as i'm using default(sierra style or something), i had no use yet for the pick-up script, as my style didn't really have a 'pick-up' option.
So i had to make an Interaction script.

So i made one, following the tutorial, only the thing now is..

When i try to pick the 'KEY' up, it trows me out of the game and say's 'There's no such function in the script, try the AnyClick script.'

But with the AnyClick script, even the LookAt function picks up the key..

Also, They key is quite hard to click on... Really tiny responsive space, like 1 pixel of the key..

My Script:

function oKey_to_Heaven_Interact()
{
oKey_to_Heaven.Visible = false;
player.AddInventory (iKey);
GiveScore (5);
}

Any Suggestions?

Dualnames

Quote from: Iceshoot on Wed 17/02/2010 22:39:39
Ok then..

Well i am currently following the tutorial, and now it came around to making my first object.
It said, as i'm using default(sierra style or something), i had no use yet for the pick-up script, as my style didn't really have a 'pick-up' option.
So i had to make an Interaction script.

So i made one, following the tutorial, only the thing now is..

When i try to pick the 'KEY' up, it trows me out of the game and say's 'There's no such function in the script, try the AnyClick script.'

But with the AnyClick script, even the LookAt function picks up the key..

Also, They key is quite hard to click on... Really tiny responsive space, like 1 pixel of the key..

My Script:

function oKey_to_Heaven_Interact()
{
oKey_to_Heaven.Visible = false;
player.AddInventory (iKey);
GiveScore (5);
}

Any Suggestions?

You should perhaps change pixel perfect click detection to false, that will sort eliminate the pixel hunt. The code is fine, and it should work like a charm. Thing is, you probably have or haven't declared the interact of the key object correctly. It's really hard to understand that part, and I re-read your post a couple of times. If however you want to use the any_click script put this inside it:

Code: ags


if (mouse.mode==eModeInteract) {
     oKey_to_Heaven.Visible = false;
     player.AddInventory (iKey);
     GiveScore (5);
}
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Khris

Make sure the function's name is entered into the event field exactly as it appears in the script.

Is there a hotspot behind the key that might trigger a function that doesn't exist yet?

An easy way to check is adding a label to the Statusbar GUI with the text "@OVERHOTSPOT@" (without the quotes). This'll show the description of whatever is under the mouse.

Iceshoot

#3
Ok, Thanks in advance for the Pixel Perfect Comment, that took care of the pixel hunt ;D

Let me describe my problem in more detail.

With the Default settings, wich you choose in the beginning of making a game, you get a certain interface(look, talk, interact etc.).

I want to pick up the key with the interaction option(the hand-cursor).

When i try to, the game closes, and an error message tells me this:

Error prepare_script: Error -18(no such function in script) trying to run 'oKey_to_Heaven_AnyClick' (room 1)

And i use this script:

function oKey_to_Heaven_Interact()
{
oKey_to_Heaven.Visible = false;
player.AddInventory (iKey);
GiveScore (5);
}

I dont want to use anyclick, because then EVERY option(Look etc.) picks up the key.

To Khris:

Yes, i made sure everything was entered just perfect.

And no, i had that problem before, but then i adressed a function to the background, and that problem was eleminated.
Plus with pixel perfect gone, this is not an issue anymore.

Khris

The problem is that AGS tries to call both functions. First the function in the "interact with object" field is called, then the one in the "any click on object" field.

You need to clear the latter field.

Iceshoot

Quote from: Khris on Wed 17/02/2010 23:35:38
The problem is that AGS tries to call both functions. First the function in the "interact with object" field is called, then the one in the "any click on object" field.

You need to clear the latter field.

And how do i clear the spaces in the 'Events' tab?

The scripting for AnyClick is gone already..

I don't get it, specify the problem and solution please.

Khris

Problem:
Quote from: Iceshoot on Wed 17/02/2010 23:40:52
The scripting for AnyClick is gone already..

Solution:

1. Click here:


2. Use the backspace and/or delete key to remove all text from the field.

Iceshoot

Quote from: Khris on Wed 17/02/2010 23:58:44
Problem:
Quote from: Iceshoot on Wed 17/02/2010 23:40:52
The scripting for AnyClick is gone already..

Solution:

1. Click here:


2. Use the backspace and/or delete key to remove all text from the field.

Yay everything's working now!!! ;D

Thanks alot Everyone!!

This thread is closed for discussion, but will remain open for people with the same problem.

Matti

Then put a (SOLVED) in the threads topic, the "NEED HELP!" doesn't look like the problem is gone ;)

Khris

Also, beneath the last post is a "Reply" link. So in case you don't want to unnecessarily quote the complete previous post, you don't even have to delete the quote from the window ;)

SMF spam blocked by CleanTalk