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:
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
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)
Just beat me scavenger
Extra: the script gets added to the GlobalScript.asc
:=
barefoot
Could u plz explain more how to add interactions ?
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
Where do I find Interaction Editor?
(http://img823.imageshack.us/img823/2710/interactx.png)
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?
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.
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
Did you link the function properly?
(http://img858.imageshack.us/img858/7466/fadein.png)
I did link it now from the Interaction you showed Matti. But I'm getting same error when going to Room 2
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
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");
What if I want the cVamp to have new dialog??
No offense, but you should really figure basic stuff like this out for yourself. Densming's video tutorials (http://www.youtube.com/user/densming#p/u/69/1Ml_DR76Cl4) might help you getting used to AGS.
What's the problem with starting a new dialog?
Well, this is Beginners Technical Questions
And I just haven't had enough time to watch all the videos through
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.
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
What exactly is your problem?
I want cVamp to start a different Dialog than he did when the door was closed.
I tried to figure how it works out myself, but failed
this is what I tried
function cVamp_Talk()
{
if object(0).Visible=true dVamp1.Start();
else if object(0).Visible=false dVamp.Start();
}
Quote from: beenf on Sun 03/04/2011 19:36:31
this is what I tried
function cVamp_Talk()
{
if object(0).Visible=true dVamp1.Start();
else if object(0).Visible=false dVamp.Start();
}
What are the error messages you got there? Not of any help?
- object is an array, its members are accessed with [], not ()
- comparisons are done with ==, a single = is only used to assign values
- conditions are enclosed in (), "if (object[0].Visible == true) dVamp1.Start();" ("== true" can be omitted here)
(all things you already did correct in the previous posts, why change it for the worse ;))
I get this: GlobalScript.asc(576): Error (line 576): expected '('
even if i changed my ()'s to []'s and "=" to "=="
function cVamp_Talk()
{
if object[0].Visible == true dVamp1.Start();
else if object[0].Visible == false dVamp3.Start();
}
Yeah, read my post again... the error message gives the right hint. :)
I'm sorry, but I still don't get it.
It's like there's a "(" which does not fit in the code. But I can't seem to find which one is it.
Edit: Or does it need an extra "("
You need to put () around the conditions:
if (object[0].Visible == true) dVamp1.Start();
else if (object[0].Visible == false) dVamp3.Start();
Hmm, that's what I did before
http://i36.photobucket.com/albums/e10/beenf/error3.jpg
Yeah well, line 577 obviously is further down in your script. If we're supposed to help you, you should post the relevant code snippet.
Ohh, that was the case. I tought it was something about the same lane, cause when I clicked the error it would highlight the 527th line