Dwarf Fortress > DF Modding

Notepad++ highlighting mod remade v1.2 "Comments and dark mode improved"

(1/3) > >>

Sirmaril:
Hi everyone!

This is my first utility mod for Dwarf Fortress. This is expanded version of "Notepad++ raw file highlighting mode" made by Kazimuth, since he seems to have abandoned it, and the Bay12Forums, his post can be found here: http://www.bay12forums.com/smf/index.php?topic=130510

What does it do?

This file can be used by Notepad++ editor to highlight syntax used in Dwarf Fortress moding. You can change the default colours I chose by following the instructions down below or in the download file. You can see how it looks here:

Spoiler (click to show/hide)
entity_default.txt


init.txt


What's new?

Spoiler (click to show/hide)Version 1.2:
    SET_SCHOLARS_ON_VALUES_AND_JOBS is now highlighted properly.
    Added OUTSIDER_CONTROLLABLE token to the definition.
    Removed comma as a statement termintator, see version 1.0.
    Improved dark mode, now background should be transparent.
    Try out new system for comments, let's see how that looks.

Version 1.1:
    Added new tokens.
    Added dark mode.
    Updated How To guide accordingly.

Version 1.0:
    Initial release.
    Upgraded highlighting with a lot of new tokens.
    Changed old colours.
    Tried fix with comments by enabling comma as a statement terminator.
    Added a How To guide.

How to use it?

A simple how-to guide is included in with the download or you can check the spoiler here:

Spoiler (click to show/hide)Download the zip file and unzip it somewhere, you should see two xml files named “df_moding_language_npp.xml” and “df_moding_language_dark_npp.xml”.

Startup Notepad++, in the toolbar open “Language” menu and choose “Define your language…” option.


In the new window that popped up now choose import and select xml file that you’ve unzipped earlier, choose dark for black background in highlighting.


Restart Notepad++.

Now when you open any file you want to mod open “Language” menu and choose “DF Modding Language” at the bottom.


If you dislike colours I chose for the highlighting you can easily change them by doing this:

Startup Notepad++, in the toolbar open “Language” menu and choose “Define your language…” option.

In the new window that popped up now go to “Folder & Default” tab to change comment colour, “Keyword List” tab to change keyword coulour or “Comment & Number” to change number colour.

There click the styler button for appropriate group and chose colour you like from the colour picker that pops up when you click the “Foreground color” box.

Click ok and go back to your file, you should see changes immediately.



Download

Mod file and how-to guide can be downloaded here: http://dffd.bay12games.com/file.php?id=12053

Progress so far.

So far I've managed to give it a basic functionality I wanted. You can open any file like d_init.txt in data folder or entity_default.txt in raw folder and get a helpful highlighting. I'm not sure if i have included all the tokens so if anything is missing please let me know.

Known issues.

Some tokens are used differently in different files so sometimes some odd words may be highlighted, event though they shouldn't be highlighted here, but they are useful elsewhere.
Comments, highlighted blue, are highlighted black after colon, ":", there is nothing I can do about that, it's just a limitation imposed by Notepad++.

Found any errors, missing tokens, etc.?

If you do please comment here.

ArchbishopDave:
Hi there!

I saw the post with the old language file the other day and was really hoping for a new one! I fiddled around, but could not find a good example for writing my own. This though is pretty spot on and extremely helpful!

Some things I noticed during the few files I've poked through with it.


1. The only a single ATTRIBUTE_TAG is included in the ruleset. STRENGTH is the only one that is color coded (and in group 4). Below is a link to the page that lists them all, but it doesn't seem to actually have the tags associated with them. I took what I found quickly in creature_standard though.

http://dwarffortresswiki.org/index.php/DF2014:Attribute

Spoiler (click to show/hide)   
        [PHYS_ATT_RANGE:STRENGTH:450:950:1150:1250:1350:1550:2250]              +
   [PHYS_ATT_RANGE:AGILITY:150:600:800:900:1000:1100:1500]                 -
   [PHYS_ATT_RANGE:TOUGHNESS:450:950:1150:1250:1350:1550:2250]             +
   [MENT_ATT_RANGE:ANALYTICAL_ABILITY:450:950:1150:1250:1350:1550:2250]    +
   [MENT_ATT_RANGE:FOCUS:700:1200:1400:1500:1600:1800:2500]                ++
   [MENT_ATT_RANGE:CREATIVITY:450:950:1150:1250:1350:1550:2250]            +
   [MENT_ATT_RANGE:PATIENCE:450:950:1150:1250:1350:1550:2250]              +
   [MENT_ATT_RANGE:MEMORY:450:950:1150:1250:1350:1550:2250]                +
   [MENT_ATT_RANGE:SPATIAL_SENSE:700:1200:1400:1500:1600:1800:2500]        ++
2. A Couple of high level CREATURE_TOKEN seem to be missing.

STRANGE_MOODS and OUTSIDER_CONTROLLABLE are ones I immediately saw.
The CREATURE_TOKEN (Caste) MULTIPART_FULL_VISION is as well.
Should probably be level 3 with the rest of the high level tags.

3. The rules for comments causes some strange tagging to occur in some strings. See spoiler for examples. Looks like the comma is really the only one that would be used regularly and cause this problem, but DF doesn't need to escape it. Where is that used as a separator in the modding language? In any case, very small problem.

Spoiler (click to show/hide)[DESCRIPTION:A huge humanoid monster with coarse fur, large tusks and horns.]
[DESCRIPTION:A large humanoid monster from the wild tundra.  It has translucent skin, icicles for teeth, red glowing eyes and pointed ears.]
4. Really Small Issue
SET_SCHOLARS_ON_VALUES_AND_JOBS appears to be a high level ENTITY_TOKEN but is set to a different level than all of the others? It is 4, while most others are 3. ( [MERCENARY] for example is Green, while it is Orange)



Other Comments

At some point, it might be good to split the different high level tags (Group 3-Green) into another, one that accepts arguments and one that does not. So something like WOOD_WEAPONS and PERMITTED_JOB, while being the same kind of token have different rules. Perhaps the color difference could be subtle in this case.

This note is a slippery slope, but perhaps tags that expect nested values could have their own color as well? For example, the POSITION ENTITY_TOKEN. Truth be told, I have no idea how DF decides that the next tag is not a part of it when reading the raws. Maybe just the first time it runs into something non-valid? In any case, someone messing with the raws I'm sure knows, but it still might be a good feature to have.

I use a different standard color set for my text viewing (dark mode). When using the language, the background color for all tokens is set to white instead of translucent.


All in all, awesome work! As I said at the beginning, this is really helpful with just letting me scan something and immediately find what I'm looking for. Thanks!

Dirst:

--- Quote from: ArchbishopDave on May 22, 2016, 04:25:38 pm ---Other Comments

At some point, it might be good to split the different high level tags (Group 3-Green) into another, one that accepts arguments and one that does not. So something like WOOD_WEAPONS and PERMITTED_JOB, while being the same kind of token have different rules. Perhaps the color difference could be subtle in this case.

This note is a slippery slope, but perhaps tags that expect nested values could have their own color as well? For example, the POSITION ENTITY_TOKEN. Truth be told, I have no idea how DF decides that the next tag is not a part of it when reading the raws. Maybe just the first time it runs into something non-valid? In any case, someone messing with the raws I'm sure knows, but it still might be a good feature to have.

--- End quote ---
This would be awesome, but DF structures only have an "open tag" and simply close when the next "open tag" or end-of-file occur.  Notepad++ language files, to my knowledge, only understand structures with an "open tag" and a "close tag".

We could make up a close tag that DF sees as a comment, but then it would only work on specially-made raws.

Thundercraft:

--- Quote from: Dirst on May 22, 2016, 05:58:31 pm ---
--- Quote from: ArchbishopDave on May 22, 2016, 04:25:38 pm ---[snip]...perhaps tags that expect nested values could have their own color as well? For example, the POSITION ENTITY_TOKEN. Truth be told, I have no idea how DF decides that the next tag is not a part of it when reading the raws...
--- End quote ---
This would be awesome, but DF structures only have an "open tag" and simply close when the next "open tag" or end-of-file occur.  Notepad++ language files, to my knowledge, only understand structures with an "open tag" and a "close tag".

We could make up a close tag that DF sees as a comment, but then it would only work on specially-made raws.
--- End quote ---

In terms of making up a fake close tag for this highlighting mod to interpret as a close: Is there anything to prevent Notepad++ from interpreting, say, the next "]" or ":" or other punctuation as a close? But then, is it possible for Notepad++ to use the same combination of letters and symbols as the close tag for multiple, different tokens? Worth a shot?

Sirmaril:
Hi folks!

Thanks for all your input. I will try to implement your suggestions ASAP, although I won't be able to work on it this week since I need to finish my project for my university class.

About comments in DF files. I cannot make them any better than they are right now. Problem is that when you put colon, ":", anywhere in the comment it will interpret is as an operator, and then it will highlight the rest of the line accordingly. I've managed to work around it by making any other punctuation character an operator stopper. I wanted to set whitespace as such, but sadly it's impossible. If DF files had a designated comment operator, like say Java has "//" it would be mush easier, but ATM I cannot do anything about it.

Navigation

[0] Message Index

[#] Next page

Go to full version