Jump to content
The Dark Mod Forums

Recommended Posts

Posted

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_Thumb.png

Posted

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
Posted

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_Thumb.png

Posted
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

Posted

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_Thumb.png

Posted
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
Posted
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.

Posted

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.

Posted

There's no problem since I won't be overriding FMs unless the engine allows me to do it by design. I just detected an "issue" that might prevent "other works" from realizing.

Thanks!

TDM_Modpack_Thumb.png

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

    • STiFU

      Oh my gosh, I just realized, I will have my 20 year Dark Mod anniversary this year. 😮 I've literally spent half my life with The Dark Mod. That's crazy!!
      · 3 replies
    • Arcturus

      I need money. Anyone wanna hire a 3d artist?
      · 4 replies
    • Petike the Taffer

      The preliminary working titles for the missions in my now-in-developmentĀ Partners in Crime series:Ā 
      - Partners in Crime 1: A Mere Trinket
      - Partners in Crime 2: Beacon Burglary
      - Partners in Crime 3: In the Bleak Midwinter
      - Partners in Crime 4 (5 ?): Fishy Dealings
      - Partners in Crime 5 (4 ?): A Thief in the Night

      No title stealing, please. Ā In return, I promise to finish these.Ā I do stress the preliminary part. Beyond the broad strokes storyline, plot, objectives, briefings and the (currently built) layouts of these FMs, I haven't fully decided about every single detail yet, including the exact order of the missions (4 and 5 might switch places, with the story adjusted accordingly). I want the overall plot to be plotted out a bit in advance and not suffer too much from inserting prequels later. I also prefer to let my FM building fill out part of the details naturally.

      Currently working on the second FM, and once I do enough work on the current prototype, I'll work on the first one, until I get that one released. Then complete the second one, get that one ready for release (hopefully) a few months later, and so on. I want most of the early missions to be fairly small and confined, and get a bit bigger as I grow more confident in my FM making skills.

      Though there is an overarching storyline to this series, the missions themselves are mostly episodic in nature. They factor into the character development of the two main characters I'll have in the series, but it's the kind of continuity where the mission's own plot and story wouldn't depend on it.Ā 
      · 2 replies
    • SeriousToni

      Nice to see that ai_undressed_old_man_01 will be finally available in TDM !Ā 
      · 0 replies
    • opnode  »  STiFU

      Saw you username pop up, just wanted to say thanks for your recent commits :3
      · 0 replies
×
×
  • Create New...