#2
14th Dec 2020 at 12:13 PM
Posts: 3,860
Thanks: 8537 in 67 Posts
28 Achievements
Jazz scripts are a bit interesting to get used to, because the mistake you made I did exactly the same thing :p
So, just to get it out of the way and inform others on how setParameters() actually work, when thinking about parameters (and how we handle the info given from our C# script > Jazz) has the following road to travel. I'll use the treehouse as an example:
Code:
public void SetParametersForPart(UsableParts part)
{
switch (part)
{
case UsableParts.BalconyA:
base.mCurrentStateMachine.SetParameter("isMirrored", true);
break;
case UsableParts.BalconyB:
base.mCurrentStateMachine.SetParameter("isMirrored", false);
break;
}
}
We've got one SetParameter that returns 'true' and the other 'false'
If we look at the original code for 'SetParameter' we see the following:
Code:
public void SetParameter(string paramName, bool paramValue)
{
if (paramValue)
{
SetParameter(paramName, YesOrNo.yes);
}
else
{
SetParameter(paramName, YesOrNo.no);
}
}
What it does is, it converts our boolean to the actual words 'No' and 'yes'. But why? Well:
(inside the jazz script for treehouse: )
Code:
Parameter "IsMirrored" = "yes"
Yes, being of course, the default setting for it. But it will change since our script might have communicated that it's a 'No'. So in the case of this:
Code:
Select on Parameter "IsMirrored"
{
Value "no"
{
Play "a2o_treehouse_balconySit_start_treehouse" for "treehouse"
{
Track Mask "TreehouseDoorMask"
}
Play "a2o_treehouse_balconySit_start_x" for "x"
}
Value "yes"
{
Play "a2o_treehouse_balconySit_start_treehouse" for "treehouse"
{
Track Mask "TreehouseDoorMask"
}
Play "a2o_treehouse_balconySit_start_mirror" for "x"
}
}
It basically says 'Did the C# script return a 'yes' then do that animation, if it's no, then do the other.' So, with Jazz scripts always remember the C# script communicates to the Jazz script. Not the other way around
Anyways! back to your question
x:Age is also a derived parameter from our C# 'data' so to speak. There's a reason why you usually don't see EA specifying age in their 'setParameters()' and that's because it's already been given to the Jazz script. So I'd assume you can even do something like:
Code:
State "MagicStuffs"
{
Transitions to "Exit"
Select on Parameter "x:Age"
{
Value "adult"
{
//Blah blah
}
Value "elder"
{
// Blah blah
}
Value "young_adult"
{
//Blah Blah
}
Value "child"
{
//Blah blah
}
}
Select on Parameter "y:Age"
{
Value "adult"
{
//Blah blah
}
Value "elder"
{
// Blah blah
}
Value "young_adult"
{
//Blah Blah
}
Value "child"
{
//Blah blah
}
}
}
That way you don't have to derive it the way you're doing it right now
Alternatively, you could also do the following:
Code:
base.SetParameter("Actors:Age", Actor.SimDescription.TeenOrAbove);
And then just do, instead of "Adult_Adult" you use the notations I showed above ("adult", "elder" etc).