Jump to content

code optimization help request


smeagolheart

Recommended Posts

Hi.

 

So I've got something like this in my mod http://www.shsforums.net/files/file/1102-awesome-soundsets-vol-1/

 

	ACTION_IF GAME_IS ~bgee~ THEN BEGIN		// BG1EE version of sounds
		PRINT @3
		INCLUDE ~S9Soundsets/BAF/corebgee.tpa~
	END	
	ACTION_IF GAME_IS ~bg2ee~ THEN BEGIN		// BG2EE version of sounds
		PRINT @4
		INCLUDE ~S9Soundsets/BAF/corebg2ee.tpa~
	END
	ACTION_IF GAME_IS ~iwdee~ THEN BEGIN			// IWDEE version of sounds
		PRINT @5
		INCLUDE ~S9Soundsets/BAF/coreiwdee.tpa~
	END

Maybe there's a way to customize the .tpa so I have only one TPA instead of three and I can quit copying and pasting that block for every soundset I have?

 

 

 

Is there something like an action_if game_is I can do to this code:

 

 

IWDee version

APPEND_COL "CHARSND.2da" "$ $ %soundName% %soundName%a %soundName%b %soundName%c %soundName%d %soundName%e %soundName%f %soundName%g %soundName%h %soundName%0 %soundName%i %soundName%j %soundName%k %soundName%s %soundName%t %soundName%u %soundName%v %soundName%l %soundName%m %soundName%8 %soundName%9 %soundName%x %soundName%y %soundName%_ -1 -1 -1 -1 -1 -1 -1 -1 -1 %soundName%w"

BG2EE version

APPEND_COL "CHARSND.2da" "$ $ %soundName% %soundName%a %soundName%b %soundName%c %soundName%d %soundName%e %soundName%f %soundName%g %soundName%h %soundName%i %soundName%j %soundName%k %soundName%s %soundName%t %soundName%u %soundName%v %soundName%l %soundName%m %soundName%8 %soundName%9 %soundName%x %soundName%y %soundName%z %soundName%1 %soundName%2 %soundName%3 %soundName%4 %soundName%5 %soundName%6 %soundName%7"

BG1EE version

APPEND_COL "CHARSND.2da" "$ $ %soundName% %soundName%a %soundName%b %soundName%c %soundName%d %soundName%e %soundName%f %soundName%g %soundName%h %soundName%i %soundName%j %soundName%k %soundName%l %soundName%m %soundName%8 %soundName%9 %soundName%x %soundName%y %soundName%z %soundName%1 %soundName%2 %soundName%3 %soundName%4 %soundName%5 %soundName%6 %soundName%7"

So anyway they are all slightly different but the bulk of the TPA can be identical. What's the best way to consolidate these three files I've got going into one?

 

 

Also, I have another question and it might be a really.

 

As you can see above I'm setting columns with those names and then I'm searching for and replacing them based on the tags from a TRA file. Suppose I've got an entry in my TRA with a -1, the way I'm doing it, it resolves to 41021 or whatever instead of to a -1 so it's writing a new entry to the dialogue.tlk instead of just changing to -1.

 

I think I'd like it to read all the changes as strings but then change any of the strings that are -1 to an actual -1, know what I mean?

 

 

So I'm reading the tags from the TRA as such:

COPY_EXISTING "CHARSND.2da" "override/CHARSND.2da"
	REPLACE "%soundName%a" @0
	REPLACE "%soundName%b" @1

etc...

Do I need to REPLACE_TEXUALLY or something instead? What's the best way to re-read everything or check for -1's to set them?

 

I've attached one of the 3 bafs I've got going on for reference.

 

 

 

 

 

corebg2ee.tpa

Link to comment

Hmm, erhm, give the whole code, the .tp2 code and one of the .tpa codes... yeah, I understand that you try to do it, but it looks like your implementation is just suboptimal and you could do the whole thing with a simple check of choice in the install, a BG1EE, BG2EE or IWDEE at the component level.

//Ajantis
BEGIN @1010 DESIGNATED 1010
GROUP @1000
OUTER_SPRINT soundName @1011

//Determine specific script tailored to entries on each game's CHARSND.2da
ACTION_IF GAME_IS ~bgee~ THEN BEGIN // BG1EE version of sounds
PRINT @3
INCLUDE ~S9Soundsets/BAF/corebgee.tpa~
END
ACTION_IF GAME_IS ~bg2ee~ THEN BEGIN // BG2EE version of sounds
PRINT @4
INCLUDE ~S9Soundsets/BAF/corebg2ee.tpa~
END
ACTION_IF GAME_IS ~iwdee~ THEN BEGIN // IWDEE version of sounds
PRINT @5
INCLUDE ~S9Soundsets/BAF/coreiwdee.tpa~
END

COPY ~S9Soundsets/SND/ajantis/sounds~ ~lang/en_US/sounds~

That's the base .tp2 file, while this is the WHOLE corebgee.tpa file:

 

LOAD_TRA ~S9Soundsets/SND/%soundName%/%soundName%.tra~

APPEND_COL "CHARSND.2da" "$ $ %soundName% %soundName%a %soundName%b %soundName%c %soundName%d %soundName%e %soundName%f %soundName%g %soundName%h %soundName%i %soundName%j %soundName%k %soundName%l %soundName%m %soundName%8 %soundName%9 %soundName%x %soundName%y %soundName%z %soundName%1 %soundName%2 %soundName%3 %soundName%4 %soundName%5 %soundName%6 %soundName%7"
COPY_EXISTING "CHARSND.2da" "override/CHARSND.2da"
REPLACE "%soundName%a" @0
REPLACE "%soundName%b" @1
REPLACE "%soundName%c" @2
REPLACE "%soundName%d" @3
REPLACE "%soundName%e" @4
REPLACE "%soundName%f" @5
REPLACE "%soundName%g" @6
REPLACE "%soundName%h" @7
REPLACE "%soundName%0" @8
REPLACE "%soundName%i" @9
REPLACE "%soundName%j" @10
REPLACE "%soundName%k" @11
REPLACE "%soundName%s" @12
REPLACE "%soundName%t" @13
REPLACE "%soundName%u" @14
REPLACE "%soundName%v" @15
REPLACE "%soundName%l" @16
REPLACE "%soundName%m" @17
REPLACE "%soundName%8" @18
REPLACE "%soundName%9" @19
REPLACE "%soundName%x" @20
REPLACE "%soundName%y" @21
REPLACE "%soundName%_" @22
REPLACE "%soundName%z" @23
REPLACE "%soundName%1" @24
REPLACE "%soundName%2" @25
REPLACE "%soundName%3" @26
REPLACE "%soundName%4" @27
REPLACE "%soundName%5" @28
REPLACE "%soundName%6" @29
REPLACE "%soundName%7" @30
REPLACE "%soundName%w" @31
PRETTY_PRINT_2DA

LOAD_TRA ~S9Soundsets/languages/english/setup.tra~

You probably would do better with a simple Marco for the second.

 

Also, have you separated this to per character install ? That's a waste, it's likely that the player would install all or just one, 2 or 3 of these components, this is from the readme:

2qxp25j.jpg

Link to comment

That's the base .tp2 file, while this is the WHOLE corebgee.tpa file:

 
LOAD_TRA ~S9Soundsets/SND/%soundName%/%soundName%.tra~

APPEND_COL "CHARSND.2da" "$ $ %soundName% %soundName%a %soundName%b %soundName%c %soundName%d %soundName%e %soundName%f %soundName%g %soundName%h %soundName%i %soundName%j %soundName%k %soundName%l %soundName%m %soundName%8 %soundName%9 %soundName%x %soundName%y %soundName%z %soundName%1 %soundName%2 %soundName%3 %soundName%4 %soundName%5 %soundName%6 %soundName%7"
COPY_EXISTING "CHARSND.2da" "override/CHARSND.2da"
    REPLACE "%soundName%a" @0
    REPLACE "%soundName%b" @1
    REPLACE "%soundName%c" @2
    REPLACE "%soundName%d" @3
    REPLACE "%soundName%e" @4
    REPLACE "%soundName%f" @5
    REPLACE "%soundName%g" @6
    REPLACE "%soundName%h" @7
    REPLACE "%soundName%0" @8
    REPLACE "%soundName%i" @9
    REPLACE "%soundName%j" @10
    REPLACE "%soundName%k" @11
    REPLACE "%soundName%s" @12
    REPLACE "%soundName%t" @13
    REPLACE "%soundName%u" @14
    REPLACE "%soundName%v" @15
    REPLACE "%soundName%l" @16
    REPLACE "%soundName%m" @17
    REPLACE "%soundName%8" @18
    REPLACE "%soundName%9" @19
    REPLACE "%soundName%x" @20
    REPLACE "%soundName%y" @21
    REPLACE "%soundName%_" @22
    REPLACE "%soundName%z" @23    
    REPLACE "%soundName%1" @24
    REPLACE "%soundName%2" @25
    REPLACE "%soundName%3" @26
    REPLACE "%soundName%4" @27
    REPLACE "%soundName%5" @28
    REPLACE "%soundName%6" @29
    REPLACE "%soundName%7" @30    
    REPLACE "%soundName%w" @31
PRETTY_PRINT_2DA

LOAD_TRA ~S9Soundsets/languages/english/setup.tra~
You probably would do better with a simple Marco for the second.

 

I think it might be much better to place a PATCH_IF GAME_IS game BEGIN patch list END in the middle of the REPLACE commands instead of having something different but, oh, not so different :p (and yes, make a MACRO and call it form each check, but ONE macro).

 

Also, you could use ACTION_MATCH instead of many ACTION_IF, like this:

SET v =0
ACTION_MATCH v WITH
  ANY GAME_IS game BEGIN
    action list
  END

  ANY GAME_IS other_game BEGIN
    action list
  END

  ANY GAME_IS yet_another_game BEGIN
    action list
  END
END

Do I need to REPLACE_TEXUALLY or something instead? What's the best way to re-read everything or check for -1's to set them?

I am not sure if REPLACE evaluates %variables%, try if it works first. if it doesn't you should use REPLACE_EVALUATED.
Link to comment

@jarno

 

I've got it at the component level, I just don't want to do that every component. Those action ifs are on every component. So I was asking if I could put something into the baf instead of having that in each component.

 

I want to break it out the way I have into groups. If I can add that to the BAF then I don't need macros or a bunch of actionifs in the TP2.

 

I realize that people may want to install all but I like them grouped, I like organization. There's no "install all from this group" prompt in Weidu, but you click Y a bunch of times or i and then you don't have to look at it again. But If you want to go back and uninstall one or more you can do that instead of the all or none you get with the way you suggest. And you can skip a group or something if you don't like it.

 

Macros sounds promising for the Tp2.. From the weidu docs "Macros were originally intended as a way to repeat a certain tp2 block with small or no changes without resorting to copy-and-paste." because that's exactly what I'm messing with right now but the real issue is in the TPA.

 

I think.

 

@crevsdaak

 

The order doesn't matter for all those replaces, either it finds it or it doesn't. The variables, if they are active, are the same for all versions, know what I mean? If it doesn't find that variable defined into that particular append_column then it doesn't matter.

 

The append columns are the only thing different because those define what variables will be searched..

Link to comment

So I've got this now...

 

More elegant than before but it's not working. :)

 

It's setting the right number of columns in charsnd.2da but the variable soundname isn't being evaluated like it was before.

%soundName%
%soundName%a
%soundName%b
...
..
.
etc

Instead of setting the column correctly it's showing as so it's not evaluating the variable. It seems to be one thing behind. So if I do another soundset, it says

 

%Alora%a or something for the previous one, not the current one.

 

So I've figured out that the ALWAYS is evaling before I set the soundname variable later in the component. Hmmm...

 

EDIT:

 

Think I've got it now.. Now back to the 2nd issue about -1 not dialogue.tlk refs to a -1

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...