Jump to content

Dyamically manipulating dialogue via script possible in papyrus/NVSE?


irswat

Recommended Posts

Wanted to help Lancer with his profanity filter mod. The poor guy is manually editing every single dialogue that has profanity. I wanted to write a script that searches dialogue trees for profanity, and when found replaces them with a censored copy. Are dialogues simply forms in GECK? I was looking at the functions available, and to my knowledge there is no way to GetDialogue, etc. The closest thing that I've found so far are the ar functions in the NVSE library. Does any one know if it is possible to dynamically read, write, copy dialogue tree forms via script?

Matt

Link to comment
Share on other sites

Some of these NVSE functions may be useful if there is a way to DeepCopy dialogue trees into string arrays. Is there a way to GetContents of a dialogue tree?

ar_Construct
ar_Size
ar_Dump
ar_DumpID
ar_Erase
ar_Sort
ar_CustomSort
ar_SortAlpha
ar_Find
ar_First
ar_Last
ar_Next
ar_Prev
ar_Keys
ar_HasKey
ar_BadStringIndex
ar_BadNumericIndex
ar_Copy
ar_DeepCopy
ar_Null
ar_Resize
ar_Insert
ar_InsertRange
ar_Append
ar_List
ar_Map
ar_Range
sv_Destruct
sv_Construct
sv_Set
sv_Compare
sv_Length
sv_Erase
sv_SubString
sv_ToNumeric
sv_Insert
sv_Count
sv_Find
sv_Replace
sv_GetChar
sv_Split
sv_Percentify
sv_ToUpper
sv_ToLower
Link to comment
Share on other sites

PseudoCode:

GetIsTalking
If yes

GetDialogueSpeaker


copy dialogue tree into array
copy array into text file
search text file for profanity
replace profanity with censored data
read text file into array
replace dialogue tree with array

Edited by irswat
Link to comment
Share on other sites

This code will solve your problems. JiP plugin required however. (for GetUIString)

It constantly running and is changing NPC text onscreen (in dialogue mode). I advice setting quest delay to 0.0014 to make it faster.

There are also NVSE special NVSE events for that but they don't seem to work so you need to use this.

Scriptname Myscript



string_var sv_DialText


begin menumode 1009 ; only in dialogue mode


        let sv_DialText := GetUIString "DialogMenu/NOGLOW_BRANCH/DM_SpeakerText/string"
        PrintD "LUNETTE:: Dialogue Text Value is " + $sv_DialText



    if eval (Sv_Find "Bad word", sv_DialText) >-1 ; of I found "Bad word" inside dialogue text
             Sv_Replace "Bad word|B#d W&$d", sv_DialText ; Replace "Bad word" with "B#d W&$d"
             SetUIString "DialogMenu/NOGLOW_BRANCH/DM_SpeakerText/string" $sv_DialText ; Set current text
    elseif eval (Sv_Find "Another Bad word", sv_DialText) >-1
             Sv_Replace "Another Bad word|An^th%r B#d W&$d", sv_DialText
             SetUIString "DialogMenu/NOGLOW_BRANCH/DM_SpeakerText/string" $sv_DialText
    endif

    

  sv_destruct sv_DialText ; don't forget to clear it.
end

I never checked it ingame (I used original code for other purpose) but it should work.

 

Important thing - don't separate check for strings by "||"- script might stop. Always use "elseif" instead.

 

 

Changing player prompt is trickier because there might be many entries to check. I can help you do it but do you really need it?

Changing subtitle text (in gamemode) is possible I think but I never tried. And that would require knowing XML path to them too.

Edited by TommInfinite
Link to comment
Share on other sites

Im just going to use an or operator to cover all the curse words, but let me ask you a question, what is -1? If the string for a curse is found shouldn't it return 1, and if no curse is found 0? If you do >-1 this would encompass both 0 and 1. Would it be better to use something like

if eval (Sv_Find "Bad word", sv_DialText) == 1

;Curse word found

?

Edited by irswat
Link to comment
Share on other sites

I also noticed that you are searching for "Curse", but not "CURSE", or "curse" am I correct to assume that the string find function is no case sensitive or should I use ToLower to search the strings in lower case?

Edited by irswat
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...