[help] which script renames NPC objects

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Post Reply
User avatar
Xkuka
Posts: 207
Joined: Sun, 14. Mar 10, 19:25
x4

[help] which script renames NPC objects

Post by Xkuka » Wed, 22. Mar 23, 10:38

Hey there,

like the title says, i am looking for the script that renames NPC owned objects, likes ships, stations etc.
Have tried to find it myself, but i think i went through everything and i am unable to identify this simple thing^^
I have only basic coding knowledge, doesnt help to know what to look for.
I am assuming it is part of the faction logic, must be, as the AI renames stuff actively. :gruebel:

First reason is, i wanna see if i can utilize this for my own little mod that aims to refine ship classification and add prefixes to each ship and add a few new class icons. I cant be bothered anymore with renaming stuff everytime. I have actually already two working mods with different methods, but its static and AI uses its own scheme. So i wanna inject my stuff in that scheme, but i cant find it.
Second reason is, the way i've done it was pretty time consuming. A cool excercise to learn about the references. Now lets automate stuff... :mrgreen:

Thanks
***Never not modified***
Specs: I9 9900k, 32GB DDR4, ASUS RTX2060 12GB, Sys drive: 1TB Nvme SSD, Games drive: 1TB Nvme SSD, Win10 pro 21H2

User avatar
Reisser
Posts: 745
Joined: Mon, 28. Feb 05, 15:39
x4

Re: [help] which script renames NPC objects

Post by Reisser » Wed, 22. Mar 23, 13:11

1) Take a mod that does something like this - one that is as manageable as possible
2) Then search for corresponding lines
2b) (you can also go through ALL the scripts with AstroGrep and search for "name" - but that might give a bit many results)
3) Adapt and use the line accordingly for yourself

As an example, here is a mod that temporarily changes the name of a ship ... depending on use, of course, permanently:

https://www.nexusmods.com/x4foundations/mods/370

The interesting line in it then looks like this:

Code: Select all

<do_if value="$ADD_ORDER_TAG">
      <set_value name="this.$OldName" exact="this.ship.name"/>
      <set_object_name object="this.ship" name="this.ship.name + '\033#FFA2560B# #DVE\033X'"/>
</do_if>
Of course, the whole thing also depends on the reference system ... in the ai script it is the ship itself (this.ship), in an MD script it can look different again ...
Meine Mods bei NexusMods: RS Loss Report RS Bribe for Scandata RS Colors RS Marine Special Training
Meine Mod-Collection bei NexusMods: X4 VRO Reloaded

User avatar
Xkuka
Posts: 207
Joined: Sun, 14. Mar 10, 19:25
x4

Re: [help] which script renames NPC objects

Post by Xkuka » Wed, 22. Mar 23, 18:12

Reisser wrote:
Wed, 22. Mar 23, 13:11
1) Take a mod that does something like this - one that is as manageable as possible
Thanks man, looks like i can make use of that. Yeah i started off by looking into smaller mods and expanded from there.
Reisser wrote:
Wed, 22. Mar 23, 13:11
2b) (you can also go through ALL the scripts with AstroGrep and search for "name" - but that might give a bit many results)
Good tip, luckily I use Directory Opus which does that by default, would be lost working with win file explorer...

Reisser wrote:
Wed, 22. Mar 23, 13:11
Of course, the whole thing also depends on the reference system ... in the ai script it is the ship itself (this.ship), in an MD script it can look different again ...
The references... a rabbit hole, as it turns out. I am currently working on a complete overhaul of all kinds of atributes and references i might need. The t file is so powerful, as soon as its cleaned up, expanded and properly structured so that noobs like me can work with it. :mrgreen:
***Never not modified***
Specs: I9 9900k, 32GB DDR4, ASUS RTX2060 12GB, Sys drive: 1TB Nvme SSD, Games drive: 1TB Nvme SSD, Win10 pro 21H2

User avatar
Reisser
Posts: 745
Joined: Mon, 28. Feb 05, 15:39
x4

Re: [help] which script renames NPC objects

Post by Reisser » Wed, 22. Mar 23, 19:25

No, try AstroGrep, because we don't search files with content - we also want to see the content immediately (adjustable - e.g. 5 lines before and after the appearance of your search term). Believe me ... try it ... that's when it really started for me (well ... a little bit ... but 1000x better than before when you were aimlessly digging around in files)

And of course a good editor. I recommend Notepad++ here - it also has extensive syntax highlighting etc etc ... very helpful.
Meine Mods bei NexusMods: RS Loss Report RS Bribe for Scandata RS Colors RS Marine Special Training
Meine Mod-Collection bei NexusMods: X4 VRO Reloaded

Post Reply

Return to “X4: Foundations - Scripts and Modding”