Update author's template effect token usage live
This commit is contained in:
parent
c21c1e3dc0
commit
6ac970b1c0
|
@ -3634,7 +3634,7 @@ def get_message(msg):
|
|||
)
|
||||
else:
|
||||
if field == "anoteinput":
|
||||
unencoded = buildauthorsnote(unencoded)
|
||||
unencoded = buildauthorsnote(unencoded, msg["data"]["anotetemplate"])
|
||||
tokens_length = len(tokenizer.encode(unencoded))
|
||||
|
||||
emit(
|
||||
|
@ -3972,11 +3972,11 @@ def actionredo():
|
|||
#==================================================================#
|
||||
#
|
||||
#==================================================================#
|
||||
def buildauthorsnote(authorsnote):
|
||||
def buildauthorsnote(authorsnote, template):
|
||||
# Build Author's Note if set
|
||||
if authorsnote == "":
|
||||
return ""
|
||||
return ("\n" + vars.authornotetemplate + "\n").replace("<|>", authorsnote)
|
||||
return ("\n" + template + "\n").replace("<|>", authorsnote)
|
||||
|
||||
def calcsubmitbudgetheader(txt, **kwargs):
|
||||
# Scan for WorldInfo matches
|
||||
|
@ -3988,7 +3988,7 @@ def calcsubmitbudgetheader(txt, **kwargs):
|
|||
else:
|
||||
mem = vars.memory
|
||||
|
||||
anotetxt = buildauthorsnote(vars.authornote)
|
||||
anotetxt = buildauthorsnote(vars.authornote, vars.authornotetemplate)
|
||||
|
||||
return winfo, mem, anotetxt, found_entries
|
||||
|
||||
|
|
|
@ -2151,7 +2151,13 @@ function interpolateRGB(color0, color1, t) {
|
|||
}
|
||||
|
||||
function updateInputBudget(inputElement) {
|
||||
socket.send({"cmd": "getfieldbudget", "data": {"unencoded": inputElement.value, "field": inputElement.id}});
|
||||
let data = {"unencoded": inputElement.value, "field": inputElement.id};
|
||||
|
||||
if (inputElement.id === "anoteinput") {
|
||||
data["anotetemplate"] = $("#anotetemplate").val();
|
||||
}
|
||||
|
||||
socket.send({"cmd": "getfieldbudget", "data": data});
|
||||
}
|
||||
|
||||
function registerTokenCounters() {
|
||||
|
@ -3430,6 +3436,10 @@ $(document).ready(function(){
|
|||
if (handled) ev.preventDefault();
|
||||
});
|
||||
|
||||
$("#anotetemplate").on("input", function() {
|
||||
updateInputBudget(anote_input[0]);
|
||||
})
|
||||
|
||||
registerTokenCounters();
|
||||
|
||||
updateInputBudget(input_text[0]);
|
||||
|
|
Loading…
Reference in New Issue