OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: Terox on 25 Oct 2009, 13:58:20

Title: Useage of preprocessor commands for dynamic path (SOLVED)
Post by: Terox on 25 Oct 2009, 13:58:20
I would like to dynamically apply a path  in a Description.EXT class attributes having defined that path in a #define statement  in the Description.ext. structure

Specifically I need to be able to apply a variable as part of a string path for cfgRadio sounds

I have tried various configurations of  __EXEC  and __EVAL statements, but all to no avail
Example
_strSHOT = __EVAL("(TX_ACTION_CORE) + 'Sounds\secop_artillery_30.wss'"    );
      sound[] = {_strSHOT, db +0, 1.0};

Here is a cut down code example as it stands now

Code: [Select]
// DESCRIPTION.EXT

#define TX_ACTION_CORE "Tx_Actions\"
#define TX_ACTION_USER "Tx_UserSetup\"

  class Tx_Actions
  {
Path_SetupFolder = TX_ACTION_USER;     // Used to get a dynamic path for scripts
Path_CoreFolder  = TX_ACTION_CORE;     // Used to get a dynamic path for scripts

// class Tx_Arty
// {
//  Irrelevant code
// };
  };


  class Cfgradio
  {
sounds[] =
{
Tx_arty_shot,
};

class Tx_arty_shot
{
name = "Tx_arty_shot";
sound[] = { "Tx_actions\sounds\secop_artillery_30.wss", db +0, 1.0};
title = "     << ARTY >>     Shot !!!!";
};
  };

So I would be greatly appreciative if someone could supply me with a working example of how best to do this...
Thanks in advance
Title: Re: Useage of preprocessor commands for dynamic path
Post by: i0n0s on 25 Oct 2009, 14:18:35
Shouldn't it be:
Code: [Select]
_strSHOT = __EVAL(TX_ACTION_CORE + "Sounds\secop_artillery_30.wss");
Otherwise you can create a macro:
Code: [Select]
#define TX_ACTION_USER_(X) TX_ACTION_USER##X

sound[] = { TX_ACTION_USER_("\sounds\secop_artillery_30.wss"), db +0, 1.0};
Title: Re: Useage of preprocessor commands for dynamic path
Post by: Terox on 25 Oct 2009, 17:42:13
I tried both of your example syntax's, neither played the sound, just the beep that ends all radio sound files

Code: [Select]
#define TX_ACTION_CORE "Tx_Actions\"
#define TX_ACTION_USER "Tx_UserSetup\"
#define TX_ACTION_DESC_(X) TX_ACTION_CORE##X


class Tx_arty_shot
{
name = "Tx_arty_shot";
sound[] = { TX_ACTION_DESC_("sounds\secop_artillery_30.wss"), db +0, 1.0};
// sound[] = {"Tx_Actions\sounds\secop_artillery_30.wss", db +0, 1.0};
title = "     << ARTY >>     Shot                  !!!!";
};


and
Code: [Select]
_strSHOT = __EVAL(TX_ACTION_CORE + "Sounds\secop_artillery_30.wss");
class Tx_arty_shot
{
name = "Tx_arty_shot";
sound[] = { _strSHOT , db +0, 1.0};
// sound[] = {"Tx_Actions\sounds\secop_artillery_30.wss", db +0, 1.0};
title = "     << ARTY >>     Shot                  !!!!";
};

Any more suggestions ??


Title: Re: Useage of preprocessor commands for dynamic path
Post by: kju on 26 Oct 2009, 20:24:18
Without it you can hear the sound?

I suggest you to try to play with the macro, define, EVAL in a situation
you can easily verify that it works or brakes. Aka to see the result
and see errors in the rpt.
Title: Re: Useage of preprocessor commands for dynamic path
Post by: Mandoble on 26 Oct 2009, 22:31:03
Have you tried this?
Code: [Select]
class Tx_arty_shot
{
name = "Tx_arty_shot";
sound[] = { __EVAL(TX_ACTION_CORE + "Sounds\secop_artillery_30.wss"), db +0, 1.0};
// sound[] = { __EVAL(str TX_ACTION_CORE + "Sounds\secop_artillery_30.wss"), db +0, 1.0};
title = "     << ARTY >>     Shot                  !!!!";
};
Title: Re: Useage of preprocessor commands for dynamic path
Post by: Terox on 27 Oct 2009, 22:11:31
Quote
      sound[] = { __EVAL(TX_ACTION_CORE + "Sounds\secop_artillery_30.wss"), db +0, 1.0};

Thx Mandoble, that works a treat  :good: