Jump to content
The Dark Mod Forums

tdm_user_addons preference over tdm_custom_scripts


snatcher

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 4.0

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 4.0

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 4.0

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.

  • Recent Status Updates

    • Petike the Taffer  »  DeTeEff

      I've updated the articles for your FMs and your author category at the wiki. Your newer nickname (DeTeEff) now comes first, and the one in parentheses is your older nickname (Fieldmedic). Just to avoid confusing people who played your FMs years ago and remember your older nickname. I've added a wiki article for your latest FM, Who Watches the Watcher?, as part of my current updating efforts. Unless I overlooked something, you have five different FMs so far.
      · 0 replies
    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 4 replies
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
    • OrbWeaver

      I like the new frob highlight but it would nice if it was less "flickery" while moving over objects (especially barred metal doors).
      · 4 replies
×
×
  • Create New...