What if I don't want the PC entering a trigger to speak but someone else? SOLVED-User Error!

I’ve been playing about with scripting ( no, I’m not being modest, I don’t have a clue other than patching together bits of other scripts and relying on SG) !

I have a trigger which I want to produce floating text above an NPC’s head ( “Grandad” for this one). now I’m reasonable with creating triggers where the PC enters and speaks but what if you want someone else to speak. Tried it in SG and got part of the way but then had to work in the include to allow coloured text which in turn changes the way you script the speech (code for colour I want is “070”).

Bottom line is that I have a script which compiles but then doesn’t fire. Any thoughts on why this might be would be appreciated. I have a feeling I’m halfway between two stools at the moment.

#include "x3_inc_string"

 *  Script generated by LS Script Generator, v.TK.0
 *  For download info, please visit:
 *  http://nwvault.ign.com/View.php?view=Other.Detail&id=1502
// Put this script OnEnter.

void main()
    object oPC = GetEnteringObject();
    object oGdad = GetObjectByTag("Grandad");

    if ( !GetIsPC(oPC)  ||  GetIsDMPossessed(oPC) )

    if ( GetLocalInt(GetModule(), "DO_ONCE__" + GetTag(OBJECT_SELF)) )
    SetLocalInt(GetModule(), "DO_ONCE__" + GetTag(OBJECT_SELF), TRUE);

    int i;
    string sSpeak = GetLocalString(OBJECT_SELF, "SPEAK_0");
    while (sSpeak != "")
        DelayCommand(IntToFloat(i)*4.0, AssignCommand(oGdad,SpeakString(StringToRGBString(sSpeak, "070"))));
        sSpeak = GetLocalString(OBJECT_SELF, "SPEAK_"+IntToString(++i));


Variable strings are stored properly.

Just to clarify, you are using variables on the trigger to determine the spoken text of the NPC. Looks pretty cool. For myself, I would put some debug text in to see where the script was misfiring. I’m going to try it out first and see if I can find any issues.

1 Like

Thanks. Yes, the trigger variables store the NPC lines.

To be fair to the excellent Script Generator, it has not failed - it’s me mucking about with it to try to bend it to my needs.

Are you sure it doesn’t fire? As Mannast suggested, put some debug text messages to see where it breaks (I’m wondering if that couldn’t be because of the tag “Grandad”: the script fires, but cannot find “Grandad”, so cannot assign speak strings to oGdad…)

1 Like

Looking at that now I’m wondering if I’ve made an error in that Grandad’s tag might be “grandad” without the capital. Off to try that. Thanks.

EDIT: works perfectly. :see_no_evil: Stupid elementary error in capitalisation. Thanks both. Looks good.

1 Like