Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: atmuc on August 28, 2013, 03:32:40 AM

Title: String Format Problem
Post by: atmuc on August 28, 2013, 03:32:40 AM
i use {0:F2} as format on Format String Action. it returns full float value like 0.232347284 not 0.32. F2 works on Convert Float To String Action. i also tried {0.00}. do i do something wrong?
Title: Re: String Format Problem
Post by: atmuc on August 28, 2013, 03:42:53 AM
if i change this line(objectArray = variables.GetValue(); ) it works. is there any reason to send FSMVars to stringFormat?

Code: [Select]
void DoFormatString()
        {
            for (var i = 0; i < variables.Length; i++)
            {
                objectArray[i] = variables[i].GetValue();
            }
           
            try
            {
                storeResult.Value = string.Format(format.Value, objectArray);
            }
            catch (System.FormatException e)
            {
                LogError(e.Message);
                Finish();
            }   
        }
Title: Re: String Format Problem
Post by: atmuc on August 28, 2013, 04:01:20 AM
FSMVar.GetValue does not work on Action.OnEnter method. even i see float value it return 0 when i call this method inside OnEnter. it works fine in OnUpdate. is it a bug or is it by design?
Title: Re: String Format Problem
Post by: atmuc on August 28, 2013, 04:19:40 AM
i think i cannot getvalue of named variables onenter method. when i change code like this it works. i changed it just for named float variable.

Code: [Select]
void DoFormatString()
        {
            for (var i = 0; i < variables.Length; i++)
            {
if(variables[i].Type== VariableType.Float)
{
objectArray[i] = ((FsmFloat)(variables[i].NamedVar)).Value;
}
else
                objectArray[i] = variables[i].GetValue();

            }
           
            try
            {
                storeResult.Value = string.Format(format.Value, objectArray);
            }
            catch (System.FormatException e)
            {
                LogError(e.Message);
                Finish();
            }   
        }
Title: Re: String Format Problem
Post by: atmuc on August 29, 2013, 04:17:09 AM
is it a bug? should i send it to bug report section?
Title: Re: String Format Problem
Post by: Alex Chouls on September 06, 2013, 10:19:22 AM
Please submit a bug report and I'll take a look... Thanks!
Title: Re: String Format Problem
Post by: Alex Chouls on September 06, 2013, 11:16:09 AM
I was able to repro. Indeed it should use GetValue(). Good catch!!

However, I wasn't able to repro GetValue failing in OnEnter(). Are you still seeing that?
Title: Re: String Format Problem
Post by: atmuc on September 09, 2013, 03:47:35 PM
i wrote my own action :-) for now i use it.
Title: Re: String Format Problem
Post by: PissedOffCil on September 20, 2013, 09:27:39 AM
This works:

Code: [Select]
        void DoFormatString()
        {
            for (var i = 0; i < variables.Length; i++)
            {
if (variables[i].NamedVar != null)
{
variables[i].GetValueFrom(variables[i].NamedVar);
}

                objectArray[i] = variables[i].GetValue();
            }
           
            try
            {
                storeResult.Value = string.Format(format.Value, objectArray);
            }
            catch (System.FormatException e)
            {
                LogError(e.Message);
                Finish();
            }   
        }
Title: Re: String Format Problem
Post by: jeanfabre on September 23, 2013, 02:02:49 AM
Hi,

 Also, ArrayMaker has a playMakerUtils set of class that feature Fsmvar wrappers to properly get/set them. I use it always when I work with FsmVar, it's doing all the tedious work. AND I am working on a system that can parse var types. for example you pass a string but want a vector 3, that playmakerUtils will let you do that automatically :) more on this in few weeks.

Bye

Jean