The Black Wyrm's Lair - Forums

Mod development resources & discussion => Modder's Workshop => Topic started by: aigleborgne on August 25, 2006, 06:59:03 AM

Title: TP2 - Conditionnal copy
Post by: aigleborgne on August 25, 2006, 06:59:03 AM
Hi,

I am not really confident in tp2 coding and still have troubles.

In short, there are 2 files, I will patch one of them, depending of a variable. I have try this code:

Part of Setup-Enhanced_Creatures.tp2:
INCLUDE ~Enhanced_Creatures/Setup-Enhanced_Creatures.tph~
OUTER_SET "component" = 4
LAUNCH_ACTION_MACRO ~PATCH_CREATURES~

Part of Setup-Enhanced_Creatures.tph:
DEFINE_ACTION_MACRO ~PATCH_CREATURES~ BEGIN
ACTION_IF ("%component%" = 3) BEGIN
  COPY ~Enhanced_Creatures/JA#monst.2da~ ~override/JA#monst.2da~
ELSE
  COPY ~Enhanced_Creatures/JA#npc.2da~ ~override/JA#npc.2da~
END

Or:

DEFINE_ACTION_MACRO ~PATCH_CREATURES~ BEGIN

ACTION_IF ("%component%" = 3) BEGIN
  SPRINT open_file  JA#monst.2da
ELSE
  SPRINT open_file  JA#npc.2da
END

COPY_EXISTING  ~%open_file%~ ~override/open_file~

Neither of this work. ACTION_IF, PATCH_IF... I tried both. I don't know how to solve it.
Well, I know one way: open any file, so I can use patch_if, then open the 2nd with inner action.

If someone know the right way to do this, I would really appreciate and be very happy