Dialog script

Started by Mr Flibble, Fri 02/04/2004 17:39:27

Previous topic - Next topic

Mr Flibble

Hi.
When I place a run-script function in my dialogue, where do I write the script for it? And how do I turn that function off?
Say if I wanted a character to give the player an item, but only run the animation once, but let the player run that line of conversation again.

Also, can somebody give me an example?

Thanks. [/pathetic]
Ah! There is no emoticon for what I'm feeling!

Ginny

I believe return has to be the last command in the list, otherwise it returns control to the player and never executes the option-off 1 command :).
Try Not to Breathe - coming sooner or later!

We may have years, we may have hours, but sooner or later, we push up flowers. - Membrillo, Grim Fandango coroner

Mr Flibble

Yeah, I worked out something along those lines, thats why I changed the first post.

I was forgetting to put an option off command at the start.

So now I have a better question.    /\
                                                        |
                                                        |
Ah! There is no emoticon for what I'm feeling!

Ginny

Ah, I must've replied while you were editing :)
So, once you put a run-script 1 (for example) command in the dialog, it calls the dialog_request function in the global scriot, but that doesn't exist yet, you need to create it, like this:
Somewhere between all the functions of the global script, put:
funtion dialog_request(int param) {

}
(param can be any word, just keep it consistent through the function, it's the integer that stores the number after run-script, like 1.)
I wouldn't put this at the end of the global script cause you probably have some inventory and character interactions there already, and it would look too messy imo.

Now, suppose you have a dialog the goes like:

@1
EGO: Hello.
MAN: Hi. Take this thing from me.
run-script 1
(
In the dialog_request put:
if (param==1) {
//run animation - I seem to have forgotten the script for this :P
AddInventory(X);
//also, I don't remember for sure, you may need a return; command here..?
}
where X would be the inventory item number of course.
You can run many scripts this way.

Now, about the second issue, if you don't want a new option for a different response (that is, keeping it the same), you could add at the top of the global script:
int item_given_true;
or whatever...

and in the function, add:
if (param==1) {
if (item_given_true==0) {
//stuff to do
item_given_true = 1;
}
}
So if the item has been given, it does nothing.

Perhaps there's a better way to do this?

Sorry I was so lengthy, I'm in a writing mood :)
Try Not to Breathe - coming sooner or later!

We may have years, we may have hours, but sooner or later, we push up flowers. - Membrillo, Grim Fandango coroner

Alynn

Another method of the non repeating the animation is as simple as

1) Give me the item.
2) Give me the item.


at the beginning you can only see option 1) upon completing the animation at the end of the dialog script turn off one and turn on 2... 2 will do the basic same thing, without running the script... Also by putting them right next to each other, it will stay in the same place (orderwise) with the other options.

SMF spam blocked by CleanTalk