[SOLVED] Having problem with event: "Use inventory on Character"

Started by beenf, Sun 03/04/2011 13:03:26

Previous topic - Next topic

beenf

So my goal is to use an item on a character and after I've done that the door would open. So like he'd open the door for me.

I used this code:
Code: ags

function cVamp_UseInv()
{
if (player.ActiveInventory == iexampleitem) {
oDoorOpen.Visible = false;
oDoorClose.Visible = true;
player.LoseInventory(iexampleitem);
}

But ingame when I use the item on the character nothing happens.
I also wrote that code in the room.asc where the character and the door was.
if anyone has any idea what might be the problem thenplease help

Scavenger

The problem is character interactions need to be specified on the character interaction pane, not the room pane. if you want that to happen, just go to the character editor, then the interaction editor and add an interaction for UseInv that way (AGS needs to link interactions to function names, so you can't just write a function and be done with it)

If the character appears in more than one room, just add an additional condition to the if function you have there:

if (player.ActiveInventory == iexampleitem && player.Room == exampleroom)

barefoot

Just beat me scavenger  

Extra: the script gets added to the GlobalScript.asc

:=

barefoot
I May Not Be Perfect but I Have A Big Heart ..

beenf

Could u plz explain more how to add interactions ?

barefoot

Quote from: beenf on Sun 03/04/2011 14:15:04
Couldyouplease explain more how to add interactions ?

check out events panel bottom right of screen. it will always relate to the character/object/hotspot you have selected. click on yellow bolt to enter events such as look, talk, use inventory etc.. it will auto put event in script where you can then set its conditions... such as if you look at an object you could display some text describing what it is you see.  etc

barefoot
I May Not Be Perfect but I Have A Big Heart ..



beenf

So I added the same function from my first post to cCharacter "Use inventory on character" interaction.
But now I get this error:
http://i36.photobucket.com/albums/e10/beenf/error.jpg
Did I do something wrong?

Ryan Timothy B

On line 542 you have oDoorOpen. In the globalscript, it doesn't allow object name likes that, you'll have to refer to the object by the number.
Example (if oDoorOpen was object number 6 in that room):

You'd have to call it by this in the globalscript:
object[6].Animate(....

I would also check if you're actually in the room that has this object (if (Player.Room == 2) etc ). Unless this character that you're giving an item to, doesn't leave this particular room, then I wouldn't worry about it.

beenf

Thnx for the help so far, but when I changed the object like Ryan told me to. Then I tested it.
When I walked in the room where the character and object was (the door) the game crashed and gave me this error:
http://i36.photobucket.com/albums/e10/beenf/error2.jpg


Matti


beenf

I did link it now from the Interaction you showed Matti. But I'm getting same error when going to Room 2

beenf

Ohh I figured out now.
I had to open the room script under the edit room which I didn't do before :P

But I got a new question.
How can I change the characters Text after I have opened the door.
For example:
He told "Bring me a key and I will open the door" when the door was closed
But after I brought him key and door has opened he sais "The door has opened" or "I have no business with you anymore" etc

Matti

Something like this for example:

if (oDoorOpen.Visible) cVamp.Say ("I have no business with you anymore");
else cVamp.Say ("Bring me a key and I will open the door");

beenf


Matti

No offense, but you should really figure basic stuff like this out for yourself. Densming's video tutorials might help you getting used to AGS.

What's the problem with starting a new dialog?

beenf

Well, this is Beginners Technical Questions
And I just haven't had enough time to watch all the videos through

Khris

Quote from: beenf on Sun 03/04/2011 19:02:42
Well, this is Beginners Technical Questions

While that's true that doesn't mean you aren't supposed to exhaust the other resources first before posting here. Don't be a smartass, listen to people. We don't care if you didn't have the time yet; watch them before posting the most trivial of questions here.

beenf

Well I watched the Dialog tutorials already. I didn't find the answer I was looking. Or maybe I just didn't notice it.
If you ppl know a video tutorial for my problem then would be awesome to know about which one teaches that.
And sorry if I sounded Smartass

Matti


SMF spam blocked by CleanTalk