General Barron 0 Posted April 13, 2004 Greetings all . I understand the basic idea behind #define; you use it as a constant, so you use whatever word you want in place of the number, making later changes easier. For example: #define MYCONSTANT 5 Wherever I would put MYCONSTANT in my cpp, it would be replaced with 5. However, can you make more than just a single number as a define? I'm trying to do this: #define ECP_MV_GRASS {"People\grass_L",0.0004,1},{"People\grass_R",0.0004,1} But it is giving me an error when I try to compile. Is there any way to #define things other than just numbers? Thanks in advance! Share this post Link to post Share on other sites
Rastavovich 0 Posted April 14, 2004 Yes you can define othe tings aswell. But define is a bit tricky I found out last time I overworked the VITAPC config. In what context you want to use the definition. Is it for sounds? Share this post Link to post Share on other sites
beedee 0 Posted April 14, 2004 Hi, It is #define <label> <textblock> or #define <label>(var1,var2,..) <textblock> a definition of a <label> by #define gives you a simple text block being processed by the game engine BEFORE it interpretes the logical structure of the config.cpp (class defs etc., this really took me some time to understand it!) In the call for the text block you can use variables to create slight variations. You could perhaps clean up your animation definitions (or everything that is repeated) in the config: example config.cpp (Btw, in this example "radconv" has to be defined first (before, on top of) the Anim definition - a factor for converting radians to degree, very handy for me, so I can directly put angles in degree like in O2!)         #define radconv 0.01745         ...         class Animations         { *             #define Anim(a,b,c,d,e) \ *?§           class ##a##Anim \ *             { \ *                 type = rotation; \ *§                selection = ##b; \ *§                axis = ##c; \ *                 angle0 = 0; \ *&               angle1 = d * radconv; \ *&               animperiod = e; \ *             }; +             Anim(GEAR,     gear,     osagear,     90.00,     1.20) +             Anim(DOOR,     door,     osadoor,     95.00,     2.20) +             Anim(CNPY,     canopy,     osacnpy,     50.00,     1.80)         }; The game engine would render it to this before processing the class definitions etc: ... class Animations {     class GEARAnim     {         type = rotation;         selection = gear;         axis = osagear;         angle0 = 0;         angle1 = 90.00 * 0.01745;         animperiod = 1.20;     };     class DOORAnim     {         type = rotation;         selection = door;         axis = osadoor;         angle0 = 0;         angle1 = 95.00 * 0.01745;         animperiod = 2.20;     };     class CNPYAnim     {         type = rotation;         selection = canopy;         axis = osacanopy;         angle0 = 0;         angle1 = 50.00 * 0.01745;         animperiod = 1.80;     }; }; What you can see: + = you can put #define almost everywhere in the config, but always before the call by <label> (= "Anim" in this example) * = You can define text blocks that span multiple lines by adding " \" ? = You can even define class-definitions (this is the proof for the "text block" thing!) & = variable names of variables containing numbers (in the <textblock> part) can be written directly into the definition, § = I'm not sure about the correct form of text variables:  I found that by "##" the game engine switches from interpreting the next letters as either plain <textblock>text or variable name and back. If the following character after a recognized variable name is a punctuation mark or space you may not switch it back by ##, it's auto. I could be wrong, but it works! Be carefull with spaces around variables, both in the call and the <value> part (error: "class GEAR Anim" - "A" found, "{" expected). But you can use [TAB] safely for a clearer layout. For the variables in the call you can even use text strings containing spaces without putting the string into quotes (e.g. axis canopy). Hope I could help! bye, Bert Share this post Link to post Share on other sites
General Barron 0 Posted April 14, 2004 Wow beedee, thanks for that great amount of info! That was actually more than I was asking about, but it answers some other questions I had but didn't ask, such as how to use variables in defines. I will definately be referring back to your post as a reference in the future. I'm still not quiet clear on how you were describing the use of ## before a variable name though.... But anyway, back to my original question. So I should be able to do the define I'm trying to do, right? To repeat it: #define ECP_MV_GRASS {"People\grass_L",0.0004,1},{"People\grass_R",0.0004,1} Rastavovich, you are correct, it is for sounds. Environmental sounds for a unit (in this case, the 'man' class- i.e. footstep sounds). I don't have any variables there, so my define falls under the first structure: #define <label> <textblock> But when I try to compile, I get an error. According to the info you gave me, that should work, right? Because I'm basically just putting one line of text into my textblock. But it isn't compiling for some reason . Could the problem be that I am using [tab] between the label and the textblock, instead of spaces? Share this post Link to post Share on other sites
Rastavovich 0 Posted April 14, 2004 if you only want those two sounds in there, try: #define ECP_MV_GRASS grass[]={{"People\grass_L",0.0004,1},{"People\grass_R",0.0004,1}}; Share this post Link to post Share on other sites
beedee 0 Posted April 14, 2004 hi again General Barron! you can regard the <label> from "#define" as a stamp - anywhere you put ECP_MV_GRASS within the config, there is {"People\grass_L",0.0004,1},{"People\grass_R",0.0004,1} instead! it has no interference with the config logic - The substitution of #define-labels (and also the #include <filename> lines) is executed prior to interpreting the addon-specific values and classes - at this stage the game engine acts like a macro in a word-processing program that performs simple copy and paste to put the text back into the long form, so that it can be interpreted! In short: #defines have no effect but for cleaning up things that are repeated very often or with many variations, (eye-candy so to speak)! I don't know much about the cfgSounds-section, so i looked it up in the breathe-demo-config. Can you describe how you want to use the ECP_MV_GRASS-label? is it this way within the cfgSounds-section? ... #define ECP_MV_GRASS Â {"People\grass_L",0.0004,1},{"People\grass_R",0.0004,1} sound[] = ECP_MV_GRASS; ...? Are you sure that it is possible to assign two sound definitions (those between the {}-bracket pairs) to one single "sound[]=" ? In the demo-config there was always only 1 sound assigned to it. As I said before, #defines are just substitutes for parts of a normal, long form of the config. can you post how you want to embed the label ECP_MV_GRASS in the normal config text or better, how the long form should look like? Share this post Link to post Share on other sites
General Barron 0 Posted April 15, 2004 @Rastavovich  Thanks for the tip, but I'm using more than just those sounds in there. Below is what is going in the 'man' class definition. Basically, for each type of terrain in the SoundEnvironExt, you define a set of sounds to play for each footstep. You should be able to see below the way I'm using the defines; basically, the same defines are used in different terrains, so I can't do your suggestion. @beedee  I uderstand the use of defines, but my problem is I am getting errors when I try to convert my cpp to a bin. The error says that there is a problem creating the define, not using it. So it seems like it should be working, from what you are telling me, but for some reason it is not . Below is a portion of the config, which would be under the 'man' class: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">//small sample of the defines #define ECP_MV_MUD {"People\mud_L",0.0015,1},{"People\mud_R",0.0015,1} #define ECP_MV_WOOD {"People\wood_L",0.0015,1},{"People\wood_R",0.0015,1} #define ECP_MV_METAL {"People\metal_L",0.0015,1},{"People\metal_R",0.0015,1} class SoundEnvironExt { normalExt[]={ ECP_MV_GRASS,ECP_MV_GRASS, ECP_MV_DIRT, ECP_MV_RATTLE11}; normal[]={ ECP_MV_DIRT,ECP_MV_DIRT,ECP_MV_DIRT,ECP_MV_DIRT, ECP_MV_RATTLE1}; road[]={ ECP_MV_CONCRETE,ECP_MV_CONCRETE,ECP_MV_CONCRETE, ECP_MV_RATTLE1}; rock[]={ ECP_MV_CONCRETE,ECP_MV_CONCRETE, ECP_MV_SAND, ECP_MV_RATTLE1,ECP_MV_RATTLE12}; water[]={ ECP_MV_WATER}; gravel[]={ ECP_MV_GRAVEL,ECP_MV_GRAVEL,ECP_MV_GRAVEL, ECP_MV_RATTLE12}; #EDIT  Here is some more info on the problem. When I erase the value of the define and replace it with a number, it compiles just fine:       #define ECP_MV_GRASS 5 When I erase everything except the first string in quotes, it doesn't compile (very odd): #define ECP_MV_GRASS "People\grass_L" When I erase the part after the comma, so there is only one thing encased in braces, it doesn't compile:        #define ECP_MV_GRASS {"People\grass_L",0.0004,1} When I replace the quotation marks with braces, it still doesn't compile:          #define ECP_MV_GRASS {{People\grass_L},0.0004,1},{{People\grass_R},0.0004,1} The exact error that cpp->bin gives me is:     error on constant definition ECP_MV_GRASS - Man: Land - CfgVehicles Could the problem maybe be the program, CPP-BIN? I haven't tried binarize, but has anyone done this with the program I'm using? Share this post Link to post Share on other sites
Rastavovich 0 Posted April 15, 2004 CPP-BIN is a nice programm but has several problems especially with defines. Did you try to simple use a config.cpp for testing and putting into the pbo. Share this post Link to post Share on other sites
General Barron 0 Posted April 15, 2004 Er... well no, but this is config replaces the game's config, for the ECP, so I don't think it will work if I don't use a bin file. So I guess I should try binarize? Share this post Link to post Share on other sites
kegetys 2 Posted April 15, 2004 .cpp files work fine as the "main" config too. cpp2bin doesn't seem to know much about the C style preprocessor definitions and often does all kinds of errors and mistakes with them... If you have a C compiler you can try running your .cpp though it's preprocessor first and then convert it to .bin with cpp2bin, but you might as well use the .cpp. Share this post Link to post Share on other sites