Dialog_Request script

Started by Unknown_Terror, Tue 30/01/2007 21:07:03

Previous topic - Next topic

Unknown_Terror

Hey guys, I need a bit of help getting this part of my script to work..
In my Dialog topic i want the character i'm talking to to go get an item for me after i ask him about it. In my Dialog Script i have added the line: run-script 1 and to the Global script i have used the following code to do it....


function dialog_request (int 1) {        \\Something is wrong with this line
character[BUT].ChangeView(1);            I get the Error "PE02: Parse Error
character[BUT].Walk(198, 142);                   at "1"  I'm guessing 1 is the
character[BUT].FaceLocation(199, 88);         wrong value for the run-script
character[BUT].ChangeRoom(6);                   value.
Wait(160);
character[BUT].ChangeRoom(2, 198, 142);
character[BUT].FaceLocation(197, 155);
character[BUT].Walk(224, 147);
character[BUT].ChangeView(7);
}

Any help is much appreicated, Thanks in advance
"To Live a Perfectly Normal Life, You Must Accept The Fact That Life Will Never Be Normal"

GarageGothic

What you need is this:

Code: ags
function dialog_request (int parameter)  { 
  if (parameter == 1) {
    character[BUT].ChangeView(1);
    character[BUT].Walk(198, 142);
    character[BUT].FaceLocation(199, 88);
    character[BUT].ChangeRoom(6);         
    Wait(160);
    character[BUT].ChangeRoom(2, 198, 142);
    character[BUT].FaceLocation(197, 155);
    character[BUT].Walk(224, 147);
    character[BUT].ChangeView(7);
    }
  }


I haven't checked the entire code, but the function declaration was definitely wrong. Let me know if you get other problems further down.

Unknown_Terror

No it worked perfectly apart from the fact for forgot the word True at the end of the Walk co-ordinates.

I read through the manual on various topics and it didn't seem to explain it very well.

But i see now what i did wrong. I didn't realise i had to keep it as (int parameter) I thought i could make a shortcut without the IF statement to make it just run straight off. I won't make that mistake again....

Thanks a million for your help mate.
"To Live a Perfectly Normal Life, You Must Accept The Fact That Life Will Never Be Normal"

Khris

Theoretically you don't need to put the code inside an if-block, but then run-script x will always run the whole code, no matter what the x is.

Just a side note about the indentation of the paranthesis:

I'd do it this way:
Code: ags
Ã,  Ã,  ...
Ã,  Ã,  character[BUT].Walk(224, 147);
Ã,  Ã,  character[BUT].ChangeView(7);
Ã,  }
}


Looks cleaner, IMO.

Unknown_Terror

Yea you're right..

Humm i just need a little more help please if thats ok....

I am trying to write a script in the Character interaction menu for an NPC, so that when i talk to him in a certain room the main character will walk to specific co-ordinates only in that room. Rather than always walking to the same spot no matter what room he's in...because this NPC moves to different rooms.

I know the basis to the code, which is If Character is in Room(X) Then Character Walks to (X, X)...
but all i can think about is QBASIC language and there doesn't seem to be any THEN statements in AGS. So i'm a bit lost.

Thanks
"To Live a Perfectly Normal Life, You Must Accept The Fact That Life Will Never Be Normal"

Khris

#5
No then here, no.

if (condition) {
Ã,  doStuff;
Ã,  doMoreStuff;
Ã,  doEvenMoreStuff;
}

If only one command is to be run dependant on the condition, there's no need to put it inside the {}.

if (rain_falls) BringUmbrella;

Else if and else are put below:

if (a==1) Display("a equals 1.");
else if (a==2) Display("a equals 2.");
else Display("a is neither 1 nor 2.");

Or the long version:

if (a==1) {
Ã,  Display("a equals 1.");
Ã,  Display("Additional info.");
}
else if (a==2) {
Ã,  Display("a equals 2.");
Ã,  Display("So a is the lowest prime number.");
}
else Display("a is neither 1 nor 2.");

It's in the manual, too.

Unknown_Terror

#6
I'm still missing something. Or doing something completely wrong here i have done 2 variations of this script. and none seem to work, I just can't think about it in the right way. My brain has broken.

Heres the first one::::
// script for Character 0 (Butler): Talk to characterÃ, 
if (Room = 2) {
Ã,  character[LAM].Walk(238, 141);
Ã,  }

Second one::::

if (Room = 2) Character[LAM].Walk(238, 141);

It keeps saying Parse Error in expr near Room
"To Live a Perfectly Normal Life, You Must Accept The Fact That Life Will Never Be Normal"

Ashen

It's == for checking variables (as in if (Room == 2)), which'll be what's causing the parse error.

Secondly, is Room a variable you've declared? If not, you might get an error there as well. Do you want to check the room the player is in? That'd be player.Room, or other characters can be checked, e,g, cLam.Room.
I know what you're thinking ... Don't think that.

Unknown_Terror

#8
I think thats my problem, I do not know how to declare variables in AGS. I don't need to check what room the character is in myself....But do i have to check it for the game to know what room a character is in?
"To Live a Perfectly Normal Life, You Must Accept The Fact That Life Will Never Be Normal"

Ashen

I know what you're thinking ... Don't think that.

Unknown_Terror

Ok i understood all that anyway.
This would be correct....

int Room;
Room = 2;

But thats not what i want, Thats just saying the Variable "room" = 2.....and the script doesn't know that i mean "The Actual Room Number 2". Isn't there a variable type for this kind of thing? Do i need to do a function command? Like i said  i'm real lost here and my brain just can't get around how this specific script needs to be run to get it to work.

"To Live a Perfectly Normal Life, You Must Accept The Fact That Life Will Never Be Normal"

Ashen

Huh?
That code will create a variable called Room and set it to 2, yes. However, I'm not sure if you could create a variable called Room since there's already the Room properties (Room.Height, Room.Width, etc). There's also - as I mentioned in my last post - the Character.Room property which you can use to check what actual room a character is in. Is that waht you want?

No offense here, but it really looks like you haven't even tried to use the manual, BFAQ or forums before posting.
I know what you're thinking ... Don't think that.

Unknown_Terror

none taken although you are wrong, believe me i've been stuck on this for hours, and i've read & looked at every possible thing, and none of it makes sense to me, Forgive me for seeming so stupid.

if (cBut.Room == 2) character[LAM].Walk(238, 141); I did this and it Ran the game without moaning. Only when i Talk to the character he still doesn't walk anywhere....

Ok Ashen what i am trying to do here is when the butler is in Room 2 i want my character to walk to a specific position to talk to him. When the butler is in Room 4 i want him to then go to the appropriate position to talk to him. Rather than not moving at all to speak to him or having to use 1 set or co-ordinates for the whole game.... I am running the script on the Character Interaction menu under "Talk To Character"
"To Live a Perfectly Normal Life, You Must Accept The Fact That Life Will Never Be Normal"

Ashen

Quote from: The Manual, Character.Walk
If blocking is eNoBlock (the default) then control returns to the script immediately, and the character will move in the background.

Try adding the eBlock parameter - it's possible any other code you're got (e.g. speech, or the ChangeRoom stuff) is 'cancelling' the non-blocking Walk command.
I know what you're thinking ... Don't think that.

Unknown_Terror

Okay i managed to sort it out.

if (cBut.Room == 2) {
Ã,  character[LAM].Walk(236, 145, eBlock);
Ã,  character[LAM].FaceLocation(180, 127);
Ã,  dBUTLER.Start();
}

I know exactly what was going wrong and it's really a stupid thing, but anyone could make this mistake i guess.....What i was doing was this....

My run script looked like this Beforehand:

if (cBut.Room == 2) {
Ã,  character[LAM].Walk(236, 145, eBlock);
Ã,  character[LAM].FaceLocation(180, 127);
}

but the Problem actually was this:


It kept running the Dialog because it wasn't part of the Run-Script script, I didn't think it needed to be. I only found this out because it worked properly when i deleted the Run Dialog command, even without eBlock. So i am sorry for taking your time Ashen and thanks for the same thing. I am only a beginner at learning this language as u can obviously see, but i am definately learning some important things about how AGS works things out and how it runs.  Scripting is one thing.....But AGS's Engine is Another.
"To Live a Perfectly Normal Life, You Must Accept The Fact That Life Will Never Be Normal"

SMF spam blocked by CleanTalk