Jump to content
The Dark Mod Forums

tdm_user_addons preference over tdm_custom_scripts


snatcher
 Share

Recommended Posts

Hi,

Please correct me if I am overlooking something but I would expect that if I add a (base or custom) script to my tdm_user_addons it would override the same script that could be potentially found in tdm_custom_scripts in a mission.

In example, tdm_custom_scripts from a mission includes in the pk4:

#include "script/tdm_weapon_shortsword.script" (base)
#include "script/tdm_weapon_excalibur.script" (custom)

And my tdm_user_addons includes:

#include "script/tdm_weapon_shortsword.script" (base)
#include "script/tdm_weapon_excalibur.script" (custom)

Shouldn't my addons always take preference? It's my business what I do there anyway. Thoughts?

TDM Modpack

Link to comment
Share on other sites

It's not a question of overwriting. When the map loads, the #include lines are replaced with the contents of the specified .script files so that you get one giant merged script file in tdm_main.script. tdm_main.script includes tdm_custom_scripts.script, then tdm_user_addons.script, so the contained scripts will be added in that order.

If you #include the same .script file multiple times from different files, like in your example, you risk getting multiple copies of the same script which causes map loading to fail - see one-definition rule. Inclusion guards (#ifndef, #endif etc.) stop more than one copy of the same script from being added.

If you want your version of the script to take priority, you should give it the same file name and folder location as the base script, without using tdm_user_addons.script. It works the same as, for example, letting a custom model take priority over a base model.

  • Like 2
Link to comment
Share on other sites

Thanks for the detailed explanation, Dragofer.

I did notice if I place a script folder besides a mission pk4 my scripts take preference. That's a good thing but still, I think tdm_user_addons.script should be the ultimate ruler.

I also noticed your involvement in many scripts, including the subject here discussed. Thanks for your work.

TDM Modpack

Link to comment
Share on other sites

4 hours ago, snatcher said:

I did notice if I place a script folder besides a mission pk4 my scripts take preference. That's a good thing but still, I think tdm_user_addons.script should be the ultimate ruler

You are mixing up two different things here. That files take preference over each other has to do with how the code loads the files (or which ones). In regards to script or script functions it is a matter of how the script interpreting part of the code loads the respective files contents. Those are two different things done in a different matter.

You can have a file in a fm that already exists in the core game and it will overload the latter. But you cannot simple create a script function with a name already in use and expect the engine to replace the first one with the latter. This is not a common thing in programming and therefore not to be found in the scripting language. If you want to replace existing functions you have to replace the files containing them.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

Thanks, Obsttorte.

Your riddle, should you chose to accept it.

Same set of functions per script but different functionality.

  1. In which order the engine reads the scripts and commands and therefore the content?
  2. Which script wins, which script gets reloaded and which script gets obviated? In case a script breaks the engine, please discard it and carry on with the exercise.

Example with a base script:

  • TDM/tdm_base01.pk4 ~ script/tdm_movers.script
  • TDM/fms/anymission.pk4 ~ script/tdm_movers.script
  • TDM/fms/anymission.pk4 ~ script/tdm_custom_scripts.script ~  #include "script/tdm_movers.script" (let's pretend this happens)
  • TDM/fms/anymission/script/tdm_movers.script
  • TDM/fms/anymission/script/tdm_custom_scripts.script ~  #include "script/tdm_movers.script" (let's pretend this happens)
  • TDM/script/tdm_movers.script
  • TDM/script/tdm_user_addons.script ~  #include "script/tdm_movers.script" (let's pretend this happens)

Example with a custom script:

  • TDM/fms/anymission.pk4 ~ script/tdm_nuke.script
  • TDM/fms/anymission.pk4 ~ script/tdm_custom_scripts.script ~  #include "script/tdm_nuke.script"
  • TDM/fms/anymission/script/tdm_nuke.script
  • TDM/fms/anymission/script/tdm_custom_scripts.script ~  #include "script/tdm_nuke.script"
  • TDM/script/tdm_nuke.script
  • TDM/script/tdm_user_addons.script ~  #include "script/tdm_nuke.script"

Ready, steady, go 🙂

TDM Modpack

Link to comment
Share on other sites

10 minutes ago, snatcher said:

Example with a base script:

  • TDM/tdm_base01.pk4 ~ script/tdm_movers.script
  • TDM/fms/anymission.pk4 ~ script/tdm_movers.script
  • TDM/fms/anymission.pk4 ~ script/tdm_custom_scripts.script ~  #include "script/tdm_movers.script" (let's pretend this happens)
  • TDM/fms/anymission/script/tdm_movers.script
  • TDM/fms/anymission/script/tdm_custom_scripts.script ~  #include "script/tdm_movers.script" (let's pretend this happens)
  • TDM/script/tdm_movers.script
  • TDM/script/tdm_user_addons.script ~  #include "script/tdm_movers.script" (let's pretend this happens)

TDM/fms/anymission/script/tdm_mover.script replaces the 2 copies of tdm_mover.script in the .pk4 and the base installation.

tdm_custom_scripts.script and tdm_user_addon.script can be deleted because tdm_mover.script is already #included by tdm_main.script.

  • Thanks 1
Link to comment
Share on other sites

1 hour ago, snatcher said:

Do you then confirm when a mission author includes in the .pk4 a base script it cannot be overridden outside of the fm folder?

It works the same as any other file: if a file has the same name and folder location, then:

  • FM files overwrite base installation files
  • Files outside .pk4's overwrite files that are inside .pk4's

If you want to override the base version of tdm_mover.script, include your own copy of tdm_mover.script in your FM or addon package.

Link to comment
Share on other sites

Alright, the problem in your case seems to be that the addon files have to be on the level of the base installation (in order to apply to all FMs), so they can't overwrite files that already exist in FM .pk4's. Yes, that's a limitation.

What you can probably do, however, if you're modifying scriptobjects (tdm_movers.script contains only scriptobjects), is to derive a new scriptobject from the existing scriptobject and define its functions again. See here for more. You'll also have to update the base classes of affected entities to make use of your modified scriptobject.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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.

 Share

  • Recent Status Updates

    • nbohr1more

      The Dark Mod is hosting an Ask Me Anything thread on the PC Gaming reddit forum:  https://www.reddit.com/r/pcgaming/comments/10nfcwj/hello_we_are_the_international_development_team/
      Feel free to join the discussion there
      · 0 replies
    • stgatilov

      Bumped into an interesting piece of wisdom called Hyrum's Law:
      With a sufficient number of users of an API, it does not matter what you promise in the contract: all observable behaviors of your system will be depended on by somebody.
      · 5 replies
    • The Black Arrow

      I love playing The Dark Mod when it's cold in my place. Bonus points when it's a bit (or even very) dark and it's raining, too.
      · 1 reply
    • The Black Arrow

      I've been having stutters in Vulkan, apparently it's Nvidia Drivers' fault, so I reverted to 512 according to this: https://www.nvidia.com/en-us/geforce/forums/geforce-graphics-cards/5/505679/regular-microstutter-in-vulkan-applications-after-/?topicPage=40

      And no, that did NOT fix it. What's going on? My GPU is an RTX 2070, by the way.
      · 4 replies
    • datiswous

      I just figured out how to make subtitles work in TDM (srt) for ingame cutscenes and how to automatically generate the srt file in Kdenlive's speech recognition (I just had to edit it a bit).
      Kdenlive is a free and open source multiplatform pretty advanced video editor.
      Test case is the first builder gost scene in Requiem saying:
      1 00:00:00,180 --> 00:00:02,140 the builder be with you this night 2 00:00:02,600 --> 00:00:04,840 there will be secrets all around you 3 00:00:05,040 --> 00:00:06,439 so have a keen eye The following page gives you the basic info:
      https://wiki.thedarkmod.com/index.php?title=Subtitles
      These 2 tutorials give you the info for creating the srt files:
      If you run into the problem the Kdenlive cannot find your Python PATH, then here is a solution:
      https://www.mail-archive.com/kde-bugs-dist@kde.org/msg672183.html
      Edit: During the installation of Python, in the installer, if you select more options, you can specify to set the PATH. I tried this on another Windows computer and this fixed the issue. Much easier solution.
       
      This is all the code for the testcase:
       
      Maybe I will create a seperate (text,images based) tutorial on the wiki.
      · 8 replies
×
×
  • Create New...