Jump to content

Problem with Encapsulation and Immutability


Lauriel

Recommended Posts

I'm running into an issue with installs since trying to accommodate encapsulation and immutability.  I've linked my mod's folder so that I don't have to copy it to a bazillion different game folders for testing.  I've got the translations and other output set to subdirectories in weidu-external.  I already had each component in its own file, so just wrapped them into their own functions.  That was easy enough.  But now, when I do a partial install, WeiDU:

  1. doesn't recognize the fact that I've already installed something that is required for a component that still needs to be installed, so skips it the 2nd time around
  2. doesn't ask what to do with components not yet installed (at the beginning of the run)

How did I manage to mess that up?

Here's my preamble..

Spoiler

BACKUP ~weidu_external/backup/transitions~
AUTHOR ~For help troubleshooting installation problems, go to the Transitions forum at forums.gibberlings3.net which doesn't exist yet because I'm a newb, but hopefully it'll be there before this gets distributed to anyone.  #RunOnSentencesRUs~
VERSION ~v0.1~

README ~transitions/readme.transitions.%LANGUAGE%.txt~ ~transitions/readme.transitions.english.txt~

ALWAYS
   ACTION_IF !VARIABLE_IS_SET deja_vu BEGIN
      // Global static variables used by WeiDU
      OUTER_SPRINT mod_root "transitions"
      OUTER_SPRINT external_loc "weidu_external"
      OUTER_SPRINT tra_base "languages"
      OUTER_SPRINT base_language "american"
      OUTER_SPRINT workspace "%external_loc%/workspace/%mod_root%"
      OUTER_SPRINT tra_loc "%workspace%/%tra_base%"

      INCLUDE ~EET/other/cpmvars/eet_cpmvars.tpa~     

      // Library functions used throughout
      INCLUDE ~%mod_root%/lib/alter_script.tpa~
      INCLUDE ~%mod_root%/lib/gw_cartes.tpa~
      INCLUDE ~%mod_root%/lib/change_door_name.tpa~
      INCLUDE ~%mod_root%/lib/update_bcs.tpa~

      INCLUDE ~%mod_root%/lib/run_once.tpa~
      LAF DO_RUN_ONCE END

      OUTER_SET deja_vu = 1
   END

   // This needs to be run before every component for some reason
   // It has something to do with languages that use a different character set
   // Why just converting it once and having the output stored (which happens)
   // is not good enough, I'm not sure I'll ever understand or really believe
   // but who cares, honestly, if it's done once or a thousand times
   ACTION_DEFINE_ARRAY thismod_noconvert BEGIN setup END
   ACTION_DEFINE_ARRAY thismod_reload BEGIN game cases END

   LAF HANDLE_CHARSETS
      INT_VAR
         infer_charsets = 1
      STR_VAR
         iconv_path = EVAL "%mod_root%/%tra_base%/iconv"
         tra_path = EVAL "%tra_loc%"
         noconvert_array = thismod_noconvert
         reload_array = thismod_reload
   END

   ACTION_IF NOT GAME_IS ~eet~ BEGIN
      FAIL @1
   END
END

LANGUAGE ~American English~ ~american~   
   ~transitions/languages/american/setup.tra~
   ~transitions/languages/american/game.tra~
   ~transitions/languages/american/cases.tra~

 

Here's my run_once function:

Spoiler

DEFINE_ACTION_FUNCTION DO_RUN_ONCE BEGIN
   MKDIR "%external_loc%"
   MKDIR "%external_loc%/workspace"
   MKDIR "%workspace%"
   MKDIR "%tra_loc%"
   MKDIR "%tra_loc%/american"
   MKDIR "%tra_loc%/%LANGUAGE%"

   ACTION_BASH_FOR "%mod_root%/languages/%LANGUAGE%" ".*\.tra" BEGIN
      COPY "%BASH_FOR_FILESPEC%" "%tra_loc%/%LANGUAGE%"
   END

   ACTION_MATCH "%LANGUAGE%" WITH
      american BEGIN /* DO NOTHING - IT'S OUR DEFAULT */ END
      DEFAULT
         ACTION_BASH_FOR "%mod_root%/languages/american" ".*\.tra" BEGIN
            COPY "%BASH_FOR_FILESPEC%" "%tra_loc%/american"
         END
   END

   INCLUDE ~%mod_root%/lib/cases.tpa~
   LAF INSTALL_PROPER_CASES END
END

The call to my main component (it's actually required but I like WeiDU giving me the option to uninstall it - which doesn't happen if it's set to required):

Spoiler

/////////////////////////////////////////////////////////////////////////
// MAIN COMPONENT: ALLOW CONTINUED PLAY AFTER SAREVOK IS DEFEATED      //
// OPEN THE PALACE AND MODIFY DUKE BELT TO ALLOW FOR GAME CONTINUATION //
// This component has three options from which to select               //
/////////////////////////////////////////////////////////////////////////
BEGIN @3    // MOD 0
// This option removes the movie from the end of the fight
// so it can be used in a dream sequence later on
SUBCOMPONENT @2
INCLUDE ~%mod_root%/components/main0.tpa~
LAF main0 END

 

And the main component:

Spoiler

/////////////////////////////////////////////////////////////////////////
// Main component that allows continued play after Sarevok is defeated //
// This options uses the BG1 end movie as part of a dream sequence     //
// that gives the protagonist an additional bhaal-spawn power          //
/////////////////////////////////////////////////////////////////////////

DEFINE_ACTION_FUNCTION main0 BEGIN
   // New dream and bhaal-spawn power
   COPY_EXISTING ~PLAYER1D.BCS~ ~override~
      DECOMPILE_AND_PATCH BEGIN
         APPEND_FILE TEXT ~%mod_root%/scripts/NewDrm1.baf~
      END
   BUT_ONLY_IF_IT_CHANGES

   // See if jastey's Endless BG1 mod has been installed
   ACTION_IF (MOD_IS_INSTALLED ~c#endlessbg1/c#endlessbg1.tp2~ 0) BEGIN
      // Replace jastey's play end-movie block with block that
      // just opens the door and sets global variables
      LAF REPLACE_SCRIPT_BLOCK
         INT_VAR
            only_once = 1
         STR_VAR
            script = BG0125
            match = ~Global("C#st_BG1End","GLOBAL",0)~
            insert = ~%mod_root%/scripts/BG0125a.baf~
      END
   END ELSE BEGIN
      // Replace original block that transitions to SoD with block that
      // just opens the door and sets global variables
      LAF REPLACE_SCRIPT_BLOCK
         INT_VAR
            only_once = 1
         STR_VAR
            script = BG0125
            match = ~StartCutSceneEx("BDSODTRN",TRUE)~
            insert = ~%mod_root%/scripts/BG0125a.baf~
      END
   END

   // Do actions common to both main0.tpa and main1.tpa
   INCLUDE ~%mod_root%/components/main_common.tpa~
END

The call to the 2nd component that requires the first:

Spoiler

//////////////////////////////////////////////
// DECIDE HOW TO HANDLE SAREVOK'S EQUIPMENT //
// This component has three options         //
//////////////////////////////////////////////
BEGIN @6       // MOD 10
DESIGNATED  10
// This option has Sarevok equip his equipment
// Will make the fight slightly more difficult
SUBCOMPONENT @5
REQUIRE_PREDICATE (MOD_IS_INSTALLED ~%mod_root%/setup-%mod_root%.tp2~ 0) OR (MOD_IS_INSTALLED ~%mod_root%/setup-%mod_root%.tp2~ 1) OR (MOD_IS_INSTALLED ~%mod_root%/setup-%mod_root%.tp2~ 2) @8
INCLUDE ~%mod_root%/components/sarevok0.tpa~
LAF sarevok0 END

 

 

Can anyone see what I've done wrong?

 

Link to comment

You’re doing a LOT of variable definition there, for basic stuff that doesn’t seem to need to be in variables (“%mod_root%,” “%workspace%,” etc.) There’s a lot going on there and I can’t tell if any of it might be problematic... but the fact that I can’t tell gives me pause, y’know? Kind of just adds more chances for human error.

As far as Weidu asking what to do with components already installed/not yet installed, I’m pretty sure that only happens if you have 5 or more components. 

Edited by subtledoctor
Link to comment
1 hour ago, subtledoctor said:

As far as Weidu asking what to do with components already installed/not yet installed, I’m pretty sure that only happens if you have 5 or more components. 

I have 10 so far.

1 hour ago, subtledoctor said:

You’re doing a LOT of variable definition there, for basic stuff that doesn’t seem to need to be in variables (“%mod_root%,” “%workspace%,” etc.)

mod_root I use everywhere because I'm not sure if Transitions has been taken.  If I need to change it, I don't want to have to go through all my files and change it everywhere.  I want to change a few variables and be done.  Do you think that is what is screwing up the install?  I'll try to not use a variable in the setup TP2 file and see what happens. EDIT: that was it.  I took the variables out of the required components and it worked as usual.  I don't have an issue with doing a search and replace on my TP2 file if my mod's name has to change, so I'm happy.

Thanks for the idea!

Edited by Lauriel
Link to comment

 

2 hours ago, subtledoctor said:

You’re doing a LOT of variable definition there, for basic stuff that doesn’t seem to need to be in variables (“%mod_root%,” “%workspace%,” etc.) There’s a lot going on there and I can’t tell if any of it might be problematic... but the fact that I can’t tell gives me pause, y’know? Kind of just adds more chances for human error.

I'm doing what DavidW did in his template (below).  That's all.  He says that these variables would default to something other than what I use, so I set them, well, except for mod_root.  That one would not necessarily need to be set, except I used one just like it everywhere already, just with a different name.  As long as there's already used by WeiDU out there, may as well use it.

 

On 9/19/2018 at 11:01 AM, DavidW said:

There is now a template version on GitHub at https://github.com/Gibberlings3/immutable .

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...