Jump to content

Writing .d files - guidance sought


ericp07

Recommended Posts

What? You mean spaces and tabs and things?

 

WeiDU doesn't care. You could put the mod all on one line and WeiDU would chug through it happily enough. When you decompile a dilaouge file or script, WeiDU arranges things the way it wants, i.e. indents, line breaks, etc., but there is no reason you have to code it that way.

 

So the anser here is that you should do whatever is easiest for you. If it's clear and visually easy for you to follow, WeiDU can handle it.

 

Yes, that's what I was referring to. OK, so I think the only thing I should do is to not leave too much blank space between blocks of code. I'll extend this thinking to all the files I compose by hand (thinking especially about the .tp2 here). I also like the code to be "robust" (plenty of comments, for clarity's sake).

 

Things are going well with the mod I'm writing now, and I'm hoping to nail down everything outside of dialogues/banters, and then get to writing those, so Hinaeariel won't be tight-lipped anymore :suspect: Already got a little bit of "spoken" text in there, as a start.

 

Thanks!

Eric

Link to comment

Heh. You and I take opposite approaches to negative space in code, but that's OK. Since WeiDU will do what it's designed to do anyway, D file format shoud suit the modder.

 

I like to leave tons of blank space around dialogue code because it makes it easier to find stuff, but that's just me.

 

One thing I do with longer files that may help you: I put a table of contents at the top of longer files. For example, I'm working on a PID file at the moment, so this is my table of contents.

 

/* General conversation topics */

 

/* Personal information */

 

/* Religion */

 

/* Flirts */

 

/* Relationship management */

 

I'll put that at the top of the file and duplicate it in the body of the PID. That way, if i want to look up something about religion, I don't have to scroll down so much. All I have to do is select the text and hit the "find next instance" softkey.

Link to comment
Heh. You and I take opposite approaches to negative space in code, but that's OK. Since WeiDU will do what it's designed to do anyway, D file format shoud suit the modder.

 

I like to leave tons of blank space around dialogue code because it makes it easier to find stuff, but that's just me.

 

One thing I do with longer files that may help you: I put a table of contents at the top of longer files. For example, I'm working on a PID file at the moment, so this is my table of contents.

 

/* General conversation topics */

 

/* Personal information */

 

/* Religion */

 

/* Flirts */

 

/* Relationship management */

 

I'll put that at the top of the file and duplicate it in the body of the PID. That way, if i want to look up something about religion, I don't have to scroll down so much. All I have to do is select the text and hit the "find next instance" softkey.

 

I've noticed such formatting in Haldamir's banter file, if memory serves, and I followed that approach when I set up Hinaeariel's B.d as well. I hadn't thought of using a kind of TOC as you described, but I suspect I'll add more to my files along these lines as time I become more experienced and more organization-minded.

 

I'm just using "// blah" for comments, instead of "/* blah */", just because it works better for me :suspect:

 

Thanks,

Eric

Link to comment

So, now I'm rethinking the commenting style/format for my mod files, as I have an almost unhealthy need for organization and consistency, along with wanting to make things easier for others as well as for myself. My understanding is that using // comments out one line at a time (regardless of length?), whereas /* */ comments out everything in between, so you can have several lines surrounded by those markings. I'm reminded of BASIC programming, in which you comment by adding REM (short for REMARK) statements, and people would sometimes get...creative...with the use of * symbols to surround comment blocks. I'll get in the habit of using /* */, and see how it looks and "feels" ???

 

Any thoughts about this?

Thanks,

Eric

Link to comment

happy DOS and BASIC days!

 

Well, we had troubles with your .d having // comments earlier in another thread, so I would go with /* comment */ everywhere, just in case... Mike1072 reported oddities with comments not parsing correctly when the encoding on the file is not Unix; so to be the safest, just go for the /* */ pairings!

 

And though technically we have proven that Nythrun is correct, and you can actually have this compile correctly:

 

IF ~~ a1161 SAY ~[ARAN] (Aran has obviously not felt your kiss, but turns to see why you are so close, bumping your nose in the process. As your eyes water, he grabs both of your shoulders and peers intently into your eyes, fishing a cloth from his belt pouch.)~ = ~[ARAN] Now then you don't have no call for th' cryin', there. That's not like you one bit, eh? Hold still - you got somethin' goin' wrong wi' your nose. Must be somethin' bloomin'.~ ++ ~[PC] (You smile at him as he rubs the rough cloth across your face.)~ + a1167 ++ ~[PC] (You snarl at him, pushing his hands away from your face and walking away.)~ EXIT ++ ~[PC] I'm not crying, idiot. You just bumped my nose. Go do something useful, and leave me alone!~ EXIT ++ ~[PC] I can take care of myself, thank you. (You take the cloth from his hands, and motion for him to go about his business.)~ EXIT END /*start of reply states */ IF ~~ a1162 SAY ~[ARAN] (Aran's quick turn of head and cautious glance is followed by a smile.) I don't rightly know what I did for to deserve that, but I'll take that kind o' coin any day. Thanks.~ IF ~~ THEN EXIT END IF ~~ a1163 SAY ~[ARAN] (Aran snatches his hand away quickly, pulling a cloth out of his beltpouch and scrubbing at his hands with it.) Chauntea's Chalice, <CHARNAME>. I appreciate th' sentiment, I do, but I didn't have no chance to wash my hands after that last dinner prep. You'll end up with some mighty swollen lips if that curry spice was on 'em.~ IF ~~ THEN EXIT END IF ~~ a1164 SAY ~[ARAN] (Aran's arms reach out for you, but they are still holding weapons and gear, and with a muffled oath gear, weapons, and Aran end up in a tangled mess. He shakes his head, laughing as he gathers and readjusts everything.)~ IF ~~ THEN EXIT END IF ~~ a1165 SAY ~[ARAN] (Soft hair flows through your fingers, curling and twisting under your touch.) Hey, now, you won't find no wounds there, <CHARNAME>. I learned in Calimport that th' best remedy for aught that ails a man is to bathe every day, even if it be in a splash o' water from a bucket. Better to go for a strong swim, but I'll take what I can get. An' tangled hair don't rightly help when there's a head wound. Learned that one on Moonshea, when I done had to shave my head clean on account o' a lucky arrow creasin' my scalp.~ IF ~~ THEN EXIT END IF ~~ a1166 SAY ~[ARAN] (His eyes wander across your face, down to your neck, and then lower... and a dark blush begins creeping up from his neck to cover his cheeks. He turns away coughing lightly into his fist, and clearing his throat.)~ IF ~~ THEN EXIT END IF ~~ a1167 SAY ~[ARAN] (His hand covers yours and squeezes briefly. As you turn away, you can feel his eyes following your every motion.)~ IF ~~ THEN EXIT END IF ~~ a1168 SAY ~[ARAN] (Aran moves towards you, anxiously scrabbling at his hair.) Where? I don't want no problems wi' that, now, I don't. I should braid it up or somethin' so as to get more cushion under a helm. Clean, brushed, an' proper, that's th' only way to keep from havin' a head wound turn right bad, it is.~ = ~[ARAN] (He thrusts his head close to you, letting you comb through his locks, wincing and muttering oaths when you encounter a tangle.)~ IF ~~ THEN EXIT END IF ~~ a1169 SAY ~[ARAN] [ARAN] Istishia's Icicles! Your hands are blighted cold! You can harm a lad that way!~ IF ~~ THEN EXIT END IF ~~ a1170 SAY ~[ARAN] Why, now, I do believe they do. We Whitehands grow big, at least on th' men's side o' things. Makes fittin' armour a mite tough at times.~ IF ~~ THEN EXIT END IF ~~ a1171 SAY ~[ARAN] (Aran grins at you, and makes a gesture with one hand as if saluting.) Why, sure enough, <CHARNAME>. It be a right fine adventure, but th' companionship, that's great!~ IF ~~ THEN EXIT END IF ~~ a1172 SAY ~[ARAN] Why, thank you, <CHARNAME>. An' you are a sight for sore eyes, you are. That be a right fine outfit, <CHARNAME>. Almost does you justice.~ IF ~~ THEN EXIT END

... I am with B in the need for some whitespace and keeping things organized. After all, try troubleshooting that! I follow the bigg's advice, and do indentation, too. And I try to use Berelinde's approach, to a point. Because my files for Aran are getting very long, I tend to leave things that are simple

 

IF ~~ a1172 
SAY ~[ARAN] Why, thank you, <CHARNAME>. An' you are a sight for sore eyes, you are. That be a right fine outfit, <CHARNAME>. Almost does you justice.~ 
IF ~~ THEN EXIT 
END

 

as

 

IF ~~ a1172 SAY ~[ARAN] Why, thank you, <CHARNAME>. An' you are a sight for sore eyes, you are. That be a right fine outfit, <CHARNAME>. Almost does you justice.~ IF ~~ THEN EXIT END

 

in a single line format, so I can move blocks of them around easily and not have so far to scroll down. But when I am done with the mod, it all goes back to indentation, so that I can check triggers vs actions easily.

 

If you are using Notepad++, I do have a set of highlighters that I have been tinkering with I could send you (the one in the distributable is ok, too, but I have been trying to clean it up, and Mike1072 has some cool stuff with autocompletion that might help out too.).

 

(Aran is also set up as a tutorial/codeblog/discussion, so if it helps, there are examples of lots of this stuff to be found there. But the cleanest example/most well commented/straightforward mod to follow is Haldamir, hands down.)

Link to comment
happy DOS and BASIC days!

 

Well, we had troubles with your .d having // comments earlier in another thread, so I would go with /* comment */ everywhere, just in case... Mike1072 reported oddities with comments not parsing correctly when the encoding on the file is not Unix; so to be the safest, just go for the /* */ pairings!

 

And though technically we have proven that Nythrun is correct, and you can actually have this compile correctly:

 

IF ~~ a1161 SAY ~[ARAN] (Aran has obviously not felt your kiss, but turns to see why you are so close, bumping your nose in the process. As your eyes water, he grabs both of your shoulders and peers intently into your eyes, fishing a cloth from his belt pouch.)~ = ~[ARAN] Now then you don't have no call for th' cryin', there. That's not like you one bit, eh? Hold still - you got somethin' goin' wrong wi' your nose. Must be somethin' bloomin'.~ ++ ~[PC] (You smile at him as he rubs the rough cloth across your face.)~ + a1167 ++ ~[PC] (You snarl at him, pushing his hands away from your face and walking away.)~ EXIT ++ ~[PC] I'm not crying, idiot. You just bumped my nose. Go do something useful, and leave me alone!~ EXIT ++ ~[PC] I can take care of myself, thank you. (You take the cloth from his hands, and motion for him to go about his business.)~ EXIT END /*start of reply states */ IF ~~ a1162 SAY ~[ARAN] (Aran's quick turn of head and cautious glance is followed by a smile.) I don't rightly know what I did for to deserve that, but I'll take that kind o' coin any day. Thanks.~ IF ~~ THEN EXIT END IF ~~ a1163 SAY ~[ARAN] (Aran snatches his hand away quickly, pulling a cloth out of his beltpouch and scrubbing at his hands with it.) Chauntea's Chalice, <CHARNAME>. I appreciate th' sentiment, I do, but I didn't have no chance to wash my hands after that last dinner prep. You'll end up with some mighty swollen lips if that curry spice was on 'em.~ IF ~~ THEN EXIT END IF ~~ a1164 SAY ~[ARAN] (Aran's arms reach out for you, but they are still holding weapons and gear, and with a muffled oath gear, weapons, and Aran end up in a tangled mess. He shakes his head, laughing as he gathers and readjusts everything.)~ IF ~~ THEN EXIT END IF ~~ a1165 SAY ~[ARAN] (Soft hair flows through your fingers, curling and twisting under your touch.) Hey, now, you won't find no wounds there, <CHARNAME>. I learned in Calimport that th' best remedy for aught that ails a man is to bathe every day, even if it be in a splash o' water from a bucket. Better to go for a strong swim, but I'll take what I can get. An' tangled hair don't rightly help when there's a head wound. Learned that one on Moonshea, when I done had to shave my head clean on account o' a lucky arrow creasin' my scalp.~ IF ~~ THEN EXIT END IF ~~ a1166 SAY ~[ARAN] (His eyes wander across your face, down to your neck, and then lower... and a dark blush begins creeping up from his neck to cover his cheeks. He turns away coughing lightly into his fist, and clearing his throat.)~ IF ~~ THEN EXIT END IF ~~ a1167 SAY ~[ARAN] (His hand covers yours and squeezes briefly. As you turn away, you can feel his eyes following your every motion.)~ IF ~~ THEN EXIT END IF ~~ a1168 SAY ~[ARAN] (Aran moves towards you, anxiously scrabbling at his hair.) Where? I don't want no problems wi' that, now, I don't. I should braid it up or somethin' so as to get more cushion under a helm. Clean, brushed, an' proper, that's th' only way to keep from havin' a head wound turn right bad, it is.~ = ~[ARAN] (He thrusts his head close to you, letting you comb through his locks, wincing and muttering oaths when you encounter a tangle.)~ IF ~~ THEN EXIT END IF ~~ a1169 SAY ~[ARAN] [ARAN] Istishia's Icicles! Your hands are blighted cold! You can harm a lad that way!~ IF ~~ THEN EXIT END IF ~~ a1170 SAY ~[ARAN] Why, now, I do believe they do. We Whitehands grow big, at least on th' men's side o' things. Makes fittin' armour a mite tough at times.~ IF ~~ THEN EXIT END IF ~~ a1171 SAY ~[ARAN] (Aran grins at you, and makes a gesture with one hand as if saluting.) Why, sure enough, <CHARNAME>. It be a right fine adventure, but th' companionship, that's great!~ IF ~~ THEN EXIT END IF ~~ a1172 SAY ~[ARAN] Why, thank you, <CHARNAME>. An' you are a sight for sore eyes, you are. That be a right fine outfit, <CHARNAME>. Almost does you justice.~ IF ~~ THEN EXIT END

... I am with B in the need for some whitespace and keeping things organized. After all, try troubleshooting that! I follow the bigg's advice, and do indentation, too. And I try to use Berelinde's approach, to a point. Because my files for Aran are getting very long, I tend to leave things that are simple

 

IF ~~ a1172 
SAY ~[ARAN] Why, thank you, <CHARNAME>. An' you are a sight for sore eyes, you are. That be a right fine outfit, <CHARNAME>. Almost does you justice.~ 
IF ~~ THEN EXIT 
END

 

as

 

IF ~~ a1172 SAY ~[ARAN] Why, thank you, <CHARNAME>. An' you are a sight for sore eyes, you are. That be a right fine outfit, <CHARNAME>. Almost does you justice.~ IF ~~ THEN EXIT END

 

in a single line format, so I can move blocks of them around easily and not have so far to scroll down. But when I am done with the mod, it all goes back to indentation, so that I can check triggers vs actions easily.

 

If you are using Notepad++, I do have a set of highlighters that I have been tinkering with I could send you (the one in the distributable is ok, too, but I have been trying to clean it up, and Mike1072 has some cool stuff with autocompletion that might help out too.).

 

(Aran is also set up as a tutorial/codeblog/discussion, so if it helps, there are examples of lots of this stuff to be found there. But the cleanest example/most well commented/straightforward mod to follow is Haldamir, hands down.)

 

This is all very useful, worthy of consideration, and appreciated! I'm not yet experienced in indenting as I code, but would like to develop the habit (and any other beneficial habits) to improve my composing skills. There is no Notepad for Mac, but there is TextEdit (comes with the OS), which defaults to saving a file as an .rtf, and there is TextWrangler, which appears to be the preferred tool for writing mod files.

 

If I remember, I'll check out Aran...and I look forward to seeing that mod go live. Haldamir has already been recommended for use as an example of no-nonsense formatting; I've already patterened some things after it in my own files.

 

As for commenting, it occurs to me that using // for something very short, like a code block's title, might be a good idea. I'll be looking through all my mod files now, and revising appropriately, as I have a need for consistency and efficiency ???

 

Much thanks!

Eric

Link to comment

TextWrangler is what I use at work - it has just one simple color and you can't highlight everything the way you can in NotePad++., but it works pretty well. I'll toss up the highlighter file for TextWrangler in this thread next time I am at work. It helps to have some of the basics pop into color when they are typed correctly!

Link to comment
TextWrangler is what I use at work - it has just one simple color and you can't highlight everything the way you can in NotePad++., but it works pretty well. I'll toss up the highlighter file for TextWrangler in this thread next time I am at work. It helps to have some of the basics pop into color when they are typed correctly!

 

Yes, that would be really handy!

 

Thanks,

Eric

Link to comment

I'd like to explore adding to the P file. Some NPCs are given the option to "wait here" or to "go wait for me at [location x/y/z]." I know what to do for the waiting in place option, but not how to first make her walk off, away from charname, and then...do I use ~MoveToArea("ARxxxx")~, and do I need to supply coordinates in that area? I've set it up in the file for three different possible locations for the NPC to go to and wait to meet charname again. Please advise, including to point me toward examples to study, if possible.

 

Thanks,

Eric

Link to comment

I'll have to get back to you on the Move etc., but check BG1NPC v18 and Gavin and HomewordBound for good examples - Amber has some too. In vanilla game files, I'd have to check.

 

(I do remember that in ToB content, you can use MoveGlobal("AR4500","c-aran",[1999.1228]) but it is different in SoA content - I think it is LeaveAreaLUA or something like that)

 

But for TextWrangler:

Home/Library/Application Support/TextWrangler

 

create folder (if it doesn't already exist): Language Modules

 

put this file, "WeiDU.plist" WeiDU.plist.zip

into that folder (uncompress it first - since this was created and compressed on a Mac, it should do it with whatever mac has as the internal archive, probably StufIt)

 

Run TextWrangler, and choose "EDIT" > "Text Options" > "Language", and set it to WeiDU.

 

Go back to TextWrangler's main interface, and choose "Preferences" (right under "register" and "About TextWrangler").

 

Choose "Preferences", and look under "Editor Defaults"; check the box for "Syntax Coloring".

 

Then choose the set of preferences for Lanuguages - for the suffix mappings, set up .d, .tp2, and .baf as WeiDU, and under Installed Languages highlight WeiDU and hit the Options button in the upper left, checking that it is set up the way you want. You can change the color of the highlighting here, or you can do it under Text Colors .

 

Close TextWranger, open it up again, and you should be good to go.

 

 

 

And for the links you requested,

 

 

general reference for dialog files

Dialog Files and How They Are Referenced, pdialog.2da, interdia.2da, and .dlg: templates

 

pre-joining file introduction

SoA Pre-Joined Dialog, c-aran.dlg, "Sword an' Pen, ready for hire."

 

Post-Joined "P file" introduction

P-file Phat Phun - from traditional to CHAIN in one step., SoA, ToB, Joinin', rejoinin'...

Link to comment

You can use MoveGlobal("Area",[x-coordinate.y-coordinate],face), but I like to use EscapeAreaMove("Area",xcoordinate,y-coordinate,face) instead because it makes the NPC physically leave the area. You can use EAM() on any NPC, but if you want to use MoveGlobal(), the NPC needs to be added to the saved game file. This means that the NPC has to have been in the party at some point or you need to have used MakeGlobal(), a ToB action, on the non-joinable NPC.

Link to comment
EscapeAreaMove("Area",xcoordinate,y-coordinate,face)

There have been some subtle hints EscapeAreaMove is not reliable and can occasionally drop the "Move" part, effectively making it an EscapeArea instead. But naturally it's hard to say if that's the case since the problem doesn't appear to be reproducible and reversing the executable isn't for everyone.

Link to comment
I'll have to get back to you on the Move etc., but check BG1NPC v18 and Gavin and HomewordBound for good examples - Amber has some too. In vanilla game files, I'd have to check.

 

(I do remember that in ToB content, you can use MoveGlobal("AR4500","c-aran",[1999.1228]) but it is different in SoA content - I think it is LeaveAreaLUA or something like that)

 

But for TextWrangler:

Home/Library/Application Support/TextWrangler

 

create folder (if it doesn't already exist): Language Modules

 

put this file, "WeiDU.plist" WeiDU.plist.zip

into that folder (uncompress it first - since this was created and compressed on a Mac, it should do it with whatever mac has as the internal archive, probably StufIt)

 

Run TextWrangler, and choose "EDIT" > "Text Options" > "Language", and set it to WeiDU.

 

Go back to TextWrangler's main interface, and choose "Preferences" (right under "register" and "About TextWrangler").

 

Choose "Preferences", and look under "Editor Defaults"; check the box for "Syntax Coloring".

 

Then choose the set of preferences for Lanuguages - for the suffix mappings, set up .d, .tp2, and .baf as WeiDU, and under Installed Languages highlight WeiDU and hit the Options button in the upper left, checking that it is set up the way you want. You can change the color of the highlighting here, or you can do it under Text Colors .

 

Close TextWranger, open it up again, and you should be good to go.

 

 

 

And for the links you requested,

 

 

general reference for dialog files

Dialog Files and How They Are Referenced, pdialog.2da, interdia.2da, and .dlg: templates

 

pre-joining file introduction

SoA Pre-Joined Dialog, c-aran.dlg, "Sword an' Pen, ready for hire."

 

Post-Joined "P file" introduction

P-file Phat Phun - from traditional to CHAIN in one step., SoA, ToB, Joinin', rejoinin'...

 

Thank you so, so much for these! I've set up TextWrangler, and bookmarked the pages ???

 

- E

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...