jastey Posted June 2, 2022 Posted June 2, 2022 BG1NPC patches this for Ajantis Romance: APPEND ~gtimes.ids~ ~3600 AJROM_TIMER~ UNLESS ~AJROM_TIMER~ Sir Ajantis for BGII patches this: APPEND ~gtimes.ids~ ~3600 C#AJROM_TIMER~ If Ajantis BGII is installed before the BG1 romance, patching the gtime.ids fails because it detects "AJROM_TIMER" - which is nonsense of course. How would I make the check so it does what it's supposed to without giving a false positive if the name snippet is detected? Quote
argent77 Posted June 2, 2022 Posted June 2, 2022 Try this: APPEND ~gtimes.ids~ ~3600 AJROM_TIMER~ UNLESS ~[ %TAB%]AJROM_TIMER$~ Quote
Bubb Posted June 2, 2022 Posted June 2, 2022 Slightly overkill, but EEex uses something like this: DEFINE_ACTION_FUNCTION B3_ESCAPE_STRING STR_VAR str = ~~ RET escaped_str BEGIN ACTION_DEFINE_ASSOCIATIVE_ARRAY to_escape BEGIN ~$~ => 1 ~^~ => 1 ~.~ => 1 ~*~ => 1 ~+~ => 1 ~?~ => 1 ~[~ => 1 ~]~ => 1 ~\~ => 1 END OUTER_PATCH_SAVE escaped_str ~%str%~ BEGIN limit = BUFFER_LENGTH FOR (i = 0; i < limit; ++i) BEGIN READ_ASCII i character (1) PATCH_IF VARIABLE_IS_SET EVAL ~to_escape_%character%~ BEGIN INSERT_BYTES i 1 WRITE_ASCII i ~\~ ++i ++limit END END END END DEFINE_ACTION_FUNCTION B3_APPEND_UNIQUE_IDS STR_VAR file_name = ~~ column_one = ~~ column_two = ~~ BEGIN LAF B3_ESCAPE_STRING STR_VAR str = EVAL ~%column_one%~ RET column_one_escaped = escaped_str END LAF B3_ESCAPE_STRING STR_VAR str = EVAL ~%column_two%~ RET column_two_escaped = escaped_str END APPEND ~%file_name%.IDS~ ~%column_one% %column_two%~ UNLESS ~^[ %TAB%]*%column_one_escaped%[ %TAB%]+%column_two_escaped%[ %TAB%]*%MNL%*$~ END This appends an entry only if there isn't an exact match already present in the file, (barring whitespace). Used like: LAF B3_APPEND_UNIQUE_IDS STR_VAR file_name = ~GTIMES~ column_one = ~3600~ column_two = ~AJROM_TIMER~ END LAF B3_APPEND_UNIQUE_IDS STR_VAR file_name = ~GTIMES~ column_one = ~3600~ column_two = ~C#AJROM_TIMER~ END (I started writing this before argent commented so I'm still posting it) Quote
CamDawg Posted June 2, 2022 Posted June 2, 2022 Or you could just set the timer to a variable, use that in scripts/dialogue, compile with EVALUATE_BUFFER, and avoid patching gtimes altogether. Quote
jastey Posted June 2, 2022 Author Posted June 2, 2022 1 hour ago, Bubb said: Slightly overkill, but EEex uses something like this I'll be blunt: Is what @argent77 posted less save to use or would you strongly recommend using your EEx approach? 1 hour ago, CamDawg said: you could just set the timer to a variable, use that in scripts/dialogue, compile with EVALUATE_BUFFER, and avoid patching gtimes altogether. For BG1NPC that would be possible, but I'd have to replace all romance timer for all romances in all baf- and d-files, and I'll go the easiest way. Quote
Bubb Posted June 2, 2022 Posted June 2, 2022 (edited) 1 hour ago, jastey said: I'll be blunt: Is what @argent77 posted less save to use or would you strongly recommend using your EEx approach? For this specific case argent's suggestion is more elegant. My solution is more generalized -- it should work for all symbol names and should continue to function even if a mod decided to go crazy with whitespace. Edit: Argent's solution also needs to be tweaked slightly: APPEND ~gtimes.ids~ ~3600 AJROM_TIMER~ UNLESS ~[ %TAB%]AJROM_TIMER%MNL%*$~ Without that %MNL%* WeiDU doesn't match the EOL anchor when Windows-style newlines are being used, (a source of much agony in the Discord). Edited June 2, 2022 by Bubb Quote
DavidW Posted June 3, 2022 Posted June 3, 2022 Unless I'm missing something, you could avoid regexp entirely and just do ACTION_IF IDS_OF_SYMBOL (gtimes AJROM_TIMER) <0 BEGIN APPEND gtimes.ids "3600 AJROM_TIMER" END Similarly, I think Bubb's function could just be coded as DEFINE_ACTION_FUNCTION B3_APPEND_UNIQUE_IDS INT_VAR column_one=0 file_name=~~ column_two=~~ BEGIN ACTION_IF !(IDS_OF_SYMBOL ("%file_name%" "%column_two%")=column_one) BEGIN APPEND "%file_name%.ids" "%column_one% %column_two%" END END Quote
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.