Jump to content
Sign in to follow this  
Undeceived

Automatic / consecutive numbering in big code blocks (e.g. in description.ext)

Recommended Posts

It has always been the same in all of my mission-editing projects: Manual forthgoing insertion of numbers in these larger code blocks, e.g. in the description.ext - one by one, from 1 to (sometimes) 100, block by block... Mission after mission, campaign after campaign. :smiley-punched:

class STR_intro[b]1[/b]
{
	name = "STR_intro[b]1[/b]";
	sound[] = {"", db+0, 1.0};
	titles[] = {0, $STR_intro[b]1[/b]};
};

class STR_intro[b]2[/b]
{
	name = "STR_intro[b]2[/b]";
	sound[] = {"", db+0, 1.0};
	titles[] = {0, $STR_intro[b]2[/b]};
};

class STR_intro[b]3[/b]
{
	name = "STR_intro[b]3[/b]";
	sound[] = {"", db+0, 1.0};
	titles[] = {0, $STR_intro[b]3[/b]};
};

class STR_intro[b]4[/b]
{
	name = "STR_intro[b]4[/b]";
	sound[] = {"", db+0, 1.0};
	titles[] = {0, $STR_intro[b]4[/b]};
};

... and ... so ... on ...

I'm so sick of this - it has to end now!!! :D

Could you please show me a way / tool / programm which does this work for me? I'd owe you "eternal debt of gratitude"! :notworthy: Thanks!

EDIT: Btw., I have Notepad++ and MS Excel. I'd download new stuff as well if it helped.

Edited by Undeceived

Share this post


Link to post
Share on other sites

If you have Notepad ++ you should use Makros and TexFX they can take the whole work from you.

Share this post


Link to post
Share on other sites

I don't know TextFX but it looks quite complicated. I'll try to find out how it works. Do you know it?

Edited by Undeceived

Share this post


Link to post
Share on other sites

Ok, now I am confused. :D What exactly do I have to do here?!

Share this post


Link to post
Share on other sites

Alright, macros and preprocessor stuff is rather difficuly to use especially when you have strings there, I'll help you by solving your problem, make sure to learn how it works :)

#define STRINGIFY(STRING) #STRING
#define CONCAT(LEFT, RIGHT) LEFT##RIGHT
#define INTRO_MACRO(INDEX, FILE) \
class STR_intro##INDEX \
{ \
	name = STRINGIFY(CONCAT(STR_intro,INDEX)); \
	sound[] = {FILE, db+0, 1.0}; \
	titles[] = {0, $CONCAT(STR_intro,INDEX)}; \
};

INTRO_MACRO(1, "mysound.wss")
INTRO_MACRO(2, "blah.wss")
INTRO_MACRO(123, "whatever.wss")

To make sure that it works execute this like:

copyToClipboard preprocessFile "description.ext";

and paste it somewhere to see how your file looks after preprocessor did its magic.

^ Updated to include filename

Edited by SaMatra

Share this post


Link to post
Share on other sites

Thanks a lot, SaMatra, this is quite impressive!

It returns a mess, not "beautiful" aligned blocks (see this screenshot) but it converted everything as it should be, as far as I could see.

So if I have e.g. 40 blocks to number, I just have to continue that INTRO_MACRO list up to 40, right? Well, that should be possible to achieve quickly with the simple Notepad++ macros (or MS Excel).

Share this post


Link to post
Share on other sites
Thanks a lot, SaMatra, this is quite impressive!

It returns a mess, not "beautiful" aligned blocks (see this screenshot) but it converted everything as it should be, as far as I could see.

So if I have e.g. 40 blocks to number, I just have to continue that INTRO_MACRO list up to 40, right? Well, that should be possible to achieve quickly with the simple Notepad++ macros.

It doesn't matter how it looks on output, you don't see or use that in game, this is simply a way to check how your file looks after preprocessor to understand what it does. Just make sure that file and its macros are readable and easily editable for you in source (pre-preprocessor) form. Yes, simply have list of INIT_MACRO with whatever indexes you want, you can extend macro to support custom stringtable entry or other parameters.

Share this post


Link to post
Share on other sites

Yeah, I know - I just like "clean looking" scripts, but this will do too of course.

If there's no other way to do the job (without the game), I'll stick to this method. Thanks so far!

---------- Post added at 20:33 ---------- Previous post was at 20:11 ----------

SaMatra,

could you set up this method for a sentences.bikb codeblock for me? I tried it but my game crashed.

Maybe I should not try it in the description.ext, but elsewhere? Do these #define magic things work elsewhere too?

This is a code block from sentences.bikb:

class STR_vegastart1
{
	text = "$STR_vegastart1";
	speech[] = {"\sounds\STR_vegastart1.ogg"};
	actor = "";
	variant = "";
	variantText = "";
	class Arguments {};
};

Thanks!

Share this post


Link to post
Share on other sites
If there's no other way to do the job (without the game), I'll stick to this method.

Well, of course there is. What's your favorite scripting language besides Arma/sqf stuff?

Why not write a small Python script that takes a bunch of arguments (basename, and an integer maybe?) and writes your config into a file?

I mean... all it takes is pretty much a single loop. Done.

In case you don't happen to have a favorite scripting language, install Python and you can learn all you need in like 10-30 minutes, maybe?

IMHO anyone working with a komputr should know at least one scripting language to automate his everyday needs (P.S. Python rocks, ;), and is available for pretty much any potato out there. P.P.S. don't bother with 2.7, go for 3.x).

:cool:

Edited by ruebe

Share this post


Link to post
Share on other sites

:D Having absolutely no idea about ANY scripting language, apart from .sqs and .sqf., I think I'm going to stick to these preprocessor macros for now. I don't have a clue about the logic behind it or how it works, but it works. :)

I thought/hoped that someone knew a tool for Notepad++ or something similar, but this seems to be more complicated than I thought.

Thanks for your replies!

Share this post


Link to post
Share on other sites

why not generate exact layout with sqf and format command and dump it in .rpt?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×