Jump to content


Photo

Question to FILE_EXISTS and file paths


6 replies to this topic

#1 jastey

jastey
  • Gibberlings
  • 6819 posts
  • Gender:Female

Posted 02 August 2017 - 07:36 AM

FILE_EXISTS ~bg1npc/tra/%s/x#viint.tra~ 

doesn't turn true.

 

The path in question is:

FILE_EXISTS ~bg1npc/tra/english/x#viint.tra~

If I put it like this, it works. The language in which the mod in question is to be installed is English.

 

Would someone point me to the obvious?

 

The whole code block:

ACTION_IF ((MOD_IS_INSTALLED ~BG1NPC/BG1NPC.TP2~ "1") AND (FILE_EXISTS 
~bg1npc/tra/%s/x#viint.tra~)) BEGIN
  PRINT ~#########   bg1npc detected ##############~
END


#2 Roxanne

Roxanne
  • Modders
  • 1497 posts
  • Gender:Not Telling

Posted 02 August 2017 - 07:45 AM

FILE_EXISTS ~bg1npc/tra/%s/x#viint.tra~ 

doesn't turn true.

 

The path in question is:

FILE_EXISTS ~bg1npc/tra/english/x#viint.tra~

If I put it like this, it works. The language in which the mod in question is to be installed is English.

 

Would someone point me to the obvious?

 

The whole code block:

ACTION_IF ((MOD_IS_INSTALLED ~BG1NPC/BG1NPC.TP2~ "1") AND (FILE_EXISTS 
~bg1npc/tra/%s/x#viint.tra~)) BEGIN
  PRINT ~#########   bg1npc detected ##############~
END

You need to specify a path that actually exists in the game for FILE_EXISTS to find it, like you did in your second example.

You can install from your own files with tra/%s/ because you define what %s can mean in your own tp2 by setting the available LANGUAGE(s). Afterwards the user selects the language in which the mod is installed (0,1,2 etc) and replaces %s by that number.

But you cannot read out backwards files in that manner.

Sorry, I am not a programmer, so I can only explain it in my own amateurish ways.


Edited by Roxanne, 02 August 2017 - 07:50 AM.

The Sandrah Saga

another piece of *buggy, cheesy, unbalanced junk*


#3 Wisp

Wisp
  • Modders
  • 1086 posts
  • Gender:Male

Posted 02 August 2017 - 08:05 AM

Only a few actions/patches/other resolve %s into the current language (a quick glance suggests it's D/DLG stuff only). For a general-purpose solution, you want the LANGUAGE variable.

~bg1npc/tra/%LANGUAGE%/x#viint.tra~


#4 CamDawg

CamDawg

    Seven billion ton robot monster

  • Gibberling Poobah
  • 9188 posts
  • Gender:Not Telling

Posted 02 August 2017 - 08:14 AM

 

Only a few actions/patches/other resolve %s into the current language (a quick glance suggests it's D/DLG stuff only). For a general-purpose solution, you want the LANGUAGE variable.

~bg1npc/tra/%LANGUAGE%/x#viint.tra~

A quick note to this though--because you're checking a different mod's tra files, using %LANGUAGE% only works if their labels are consistent between mods. E.g. BG1 NPC labels the German tra file as "German" and if your mod labels it "Deutsch" then it's still not going to match.

 

LANGUAGE ~Deutsch (Teiluebersetzung vom Kerzenburgforum, teilweise noch in englisch)~ ~german~ ~bg1npc/tra/german/setup.tra~ // http://kerzenburg.baldurs-gate.eu/

 

%LANGUAGE% is set to the second item, in this case "german", if this is the selected language at install.


I came here with a simple dream: a dream of killing all humans. And this is how it must end? Who's the real seven billion ton robot monster here? Not I. Not... I.


#5 Roxanne

Roxanne
  • Modders
  • 1497 posts
  • Gender:Not Telling

Posted 02 August 2017 - 08:43 AM

Just asking for the reason of your check,

The FILE_EXISTS check only answers the question *Is that mod (respectively the example file you check) present in the game directory?". Language would not matter, as the mod would have all the tra files existing for that mod. It does not tell you what language was chosen for install or if the mod was installed at all.


The Sandrah Saga

another piece of *buggy, cheesy, unbalanced junk*


#6 jastey

jastey
  • Gibberlings
  • 6819 posts
  • Gender:Female

Posted 02 August 2017 - 09:10 AM

Thank you for your answers. I wanted to check whether the tra file I am using in the next instance is actually there, but I might as well switch to checking whether the bg1re folder is still present in general.
As for whether the name of %LANGUAGE% actually matches between mods - it's all just a workaround and I expect it to fail on several instances.

#7 jastey

jastey
  • Gibberlings
  • 6819 posts
  • Gender:Female

Posted 02 August 2017 - 09:15 AM

Argh, I now understand what you mean with labels. So, if in mod A the languages are in a different order than in mod B, it's not evaluated by the language name but by the number the player pressed to chose the language option? This means I would have to check for which language is chosen and go to the appropriate bg1 npc tra files by hand. Thank for the heads up!



Reply to this topic



  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users