PDA

View Full Version : scripting dialog modification


jrc24
06-24-2004, 09:23 PM
hi

how can I do that ?

I have a placeable (computer)

when I use it I get a dialog with many option (exemple : to diffuse toxic gas), or exit, or other...

I would do that : when I use the option (exemple : to diffuse toxic gas), I don t want that it can be possible to use it again, I want that the used option be disabled.

I m sure I must do that with a script but what is the command for this kind of things ? I don t know

must I do a script wich delete my placeaple and put an other placeable (at the same place) wich call an other dialog (I don t think)

or must I do a script wich edit the dialog, or other thing...

if somebody know, thanks

tk102
06-25-2004, 01:40 AM
jrc24, in your other thread (http://www.lucasforums.com/showthread.php?s=&threadid=130413) you asked about how to fire a script only once -- well that same idea applies here.

The secret to opening/closing forks in the dialog is in a certain field of the StartingList, EntriesList, and RepliesList. In GFF editor this field is called 'Active'. In DLGEdit, I simply called it 'Script'. But unlike normal scripts that begin 'void main()' the scripts that you reference in this field begin 'int StartingConditional()' and return either TRUE or FALSE at the end of the script. Then, the dialog knows whether or not to provide that fork.

So in this way, we can use the SetLocalBoolean/GetLocalBoolean functions again to provide a way for latching/unlatching certain dialog forks.

Here's an example:
EntryList
-> 0
-> -> Text: What do you want to do?
-> -> RepliesList:
-> -> -> 0
-> -> -> -> Active: chk_vent
-> -> -> -> Index: 0
-> -> -> 1
-> -> -> -> Active:
-> -> -> -> Index: 1

ReplyList
-> 0
-> -> Text: Turn off vent
-> -> Script: turn_off_vent
-> 1
-> -> Text: Nothing. I should go now.


chk_vent.nss has this code:

int StartingConditional() {
return (!GetLocalBoolean(GetObjectByTag("vent",1)));
}
and turn_off_vent.nss has this code:

void main() {
// do the main part of the code
// and at the end do this:
SetLocalBoolean(GetObjectByTag("vent"),1,TRUE);
}

When the PC first arrives at the vent, the LocalBoolean in the 1st slot is FALSE. When the dialog begins, chk_vent is run and returns the opposite of FALSE, TRUE. This allows ReplyList 0 to be available to the player. If the player chooses to turn off the vent, turn_off_vent script fires and sets the LocalBoolean, slot 1 of the vent to TRUE. Thus the next time dialog is initiated chk_vent will return FALSE and the PC will not get to do it again.

jrc24
06-25-2004, 03:21 PM
I understand very well how it functions now, thank you

but I have a problem when I try to compile the first script

code:
----------------------------------------------------------------------------
int StartingConditional() {
return (!GetLocalBoolean(GetObjectByTag("my_object_tag",1)));
}
--------------------------------------------------------------------------------

nwnnsscomp say to me :

error : required argument missing in call to "GetLocalBoolean"
error : not all paths return a value

if you know what is the problem, thank you

Darth333
06-25-2004, 03:41 PM
Try the following syntax:
----------------------------------------------------------------------------
int StartingConditional() {
return (!GetLocalBoolean(GetObjectByTag("my_object_tag"),1 ));
}
--------------------------------------------------------------------------------

tk102
06-25-2004, 04:01 PM
:o
Yes - what she said.

Thanks Darth333. :D

Darth333
06-25-2004, 04:16 PM
Originally posted by tk102
:o
Yes - what she said.

Thanks Darth333. :D
I had a good teacher ;)

jrc24
06-25-2004, 07:01 PM
yeeeeeeeeeeeeeeeessssss !!!!!

now it works !

thank you very much tk102 and darth333

:D :D :D :D :D :D :D :D :D :D