Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: joduffy on October 05, 2013, 05:14:43 AM

Title: Custom Scripts: drop down list of variables[SOLVED]
Post by: joduffy on October 05, 2013, 05:14:43 AM
Hi guys,

I am trying to create an action for Rain AI. What I would like to do is write get / set AI property actions.

So What I would like to do is display a drop down list of variables for the user to pick. They then enter in the name of the variable and can also select a playmaker variable to store the result in (assuming we are talking about the get action).

I have create an enum with a switch statement but I was wondering if there was a better way.

      public enum VariableType
      {
         FLOAT,
         INT,
         BOOL,
         STRING,
         VECTOR2,
         VECTOR3,
         VECTOR4,
         GAMEOBJECT
      }
Title: Re: Custom Scripts: drop down list of variables
Post by: jeanfabre on October 07, 2013, 03:23:54 AM
Hi,

 Use FsmVar and then do a check using ErrorCheck and when the user selected a fsm type not supported you throw an error:


Code: [Select]
// Perform custom error checking here.
public override string ErrorCheck()
{
// Return an error string or null if no error.

return null;
}

bye,

 Jean
Title: Re: Custom Scripts: drop down list of variables
Post by: joduffy on October 07, 2013, 07:45:18 AM
Thanks Jean.

Is it possible to store a vector4 inside of a quaternion in playmaker.

I noticed there is not a FSMVector4.

I was thinking of using FsmQuaternion to bounce back and forth between quaternion and vector4.
Title: Re: Custom Scripts: drop down list of variables
Post by: joduffy on October 07, 2013, 08:06:32 AM
This does not seem to work and I dont know why not:

FsmQuaternion storeValue
Vector4 vec4Value

storeValue.Value.Set(vec4Value.x, vec4Value.y, vec4Value.z, vec4Value.w);

or even
         
storeValue.Value.Set(10.0f, 10.0f, 10.0f, 10.0f);
Title: Re: Custom Scripts: drop down list of variables
Post by: joduffy on October 07, 2013, 08:33:37 AM
This is the error when i do:

         storeValue.Value.x = vec4Value.x;


error CS1612: Cannot modify a value type return value of `HutongGames.PlayMaker.FsmQuaternion.Value'. Consider storing the value in a temporary variable
Title: Re: Custom Scripts: drop down list of variables
Post by: joduffy on October 07, 2013, 08:39:22 AM
Sorry for the spam guys.

figured it out:

FsmQuaternion storeValue;
Vector4 vec4Value;
         storeValue.Value = new Quaternion(vec4Value.x,vec4Value.y, vec4Value.z, vec4Value.w);
Title: Re: Custom Scripts: drop down list of variables[SOLVED]
Post by: joduffy on October 07, 2013, 08:58:57 AM
Sorry for the spam guys.

I dont think I can use the FSMQuaternion as it just displays x y z values in the editor and changes them.

So values of 10 in each become 0.09xxx 0.07xxx 0.07xx 0.9xx

Do I need to create a FSMVector4?
Title: Re: Custom Scripts: drop down list of variables[SOLVED]
Post by: jeanfabre on October 07, 2013, 09:11:01 AM
Hi,

CS1612 only means that you need to create a variable in between. like:

 Quaternion _temp =   storeValue.Value;
_temp.x = vec4Value.x;
 storeValue.Value = _temp;

Try this.

 Bye,

 Jean
Title: Re: Custom Scripts: drop down list of variables[SOLVED]
Post by: joduffy on October 07, 2013, 10:36:33 PM
Thanks Jean,

I solved this problem but am facing a different one which is basically using the existing FSM variables with another plugin for Vector4 data.

I have replied in the topic:

FSMVector4