playMaker

Author Topic: ...just another big Custom Action collection (A-L)  (Read 27439 times)

Deek

  • Full Member
  • ***
  • Posts: 133
Re: ...just another big Custom Action collection
« Reply #15 on: January 19, 2018, 08:48:18 PM »
@Voa
Thanks for your feedback and sorry for the late reply (busy workweek).
I've noticed that error message already back then when creating that action but started to ignore it, since there were a few ways to circumvent it; though I knew that this was anything but ideal.
That's why I looked into it (and also because of your "reminder" :P ), created a better version and found out a few things on what caused it.

tl:dr
You can now get the improved and working action "Send Events" from the Ecosystem, should likely convert any 'Send Event Multi' actions to that and delete the SendEventMulti.cs from your Custom PlayMaker Actions folder (or keep it if you want).

Details:
The problem was, that the default 'Send Event' action uses an FsmEventTarget (Self, Broadcast, ...) and an FsmEvent variable, which get linked internally, so that depending on the selected EventTarget, the Event either only shows global variables or also local ones and automatically checks if the selected target does have the global event or not.
Since I was using an FsmGameObject[] (-Array) instead of FsmEventTarget in my "Send Event Multi"-Action, the FsmEvent variable had no target at compile time to check against, thus it always showed all available events and threw an error if it couldn't find a matching event/transition by default.

First I created another version with an FsmEventTarget[] instead of the FsmGameObject-Array, but that also didn't seem to work and made everything more bloated + you had to click more often to set up even one entry.

After that I thought of letting the user only define the EventTarget once and have him be able to select several of these targets, but since I couldn't directly manipulate the FsmEventTarget class itself and intervene it's functionality, I had to create my own version of it by creating a custom inspector that mimics the default functionality by only showing the relevant fields depending on the selected target type and hooked up matching functionality in the actual action.
I've added even more options than the standard version provided, like only sending events to FSMs with the right FSM-name, searching for SubFSMs by their name and hiding/disabling the delay field when either Broadcast All or Every Frame is selected.
But even after that, the error still showed up and I couldn't find a way to tell the FsmEvent that it should only show global events when a certain EventTarget was selected, until I found that someone already posted a similar problem on this forum (here).
I adapted that "temporary" fix (since it seems like he didn't add that NoErrorCheck-attribute) to get the FsmEvent into thinking that there is an FsmEventTarget available which won't get drawn by my custom inspector and now it stops showing that pesky error.

So the final result isn't 100% perfect, but at least way better than my inital attempt.

craigz

  • Beta Group
  • Full Member
  • *
  • Posts: 234
    • Haven Made
Re: ...just another big Custom Action collection
« Reply #16 on: March 08, 2018, 03:02:32 PM »
Hey @Deek!

Saw you asking questions on the Unity Forum for Game Data Editor :)

Gotta say, I discovered the asset from your actions for it here a few months back, and seriously it is SO awesome :) thanks for taking the time to write all these actions for it. It's made my life so much easier :D

Also! Did you end up getting the delete item action to work you were talking about with Celeste? I'm looking into reworking my player inventory and that would be huuugely useful xD

best,

craigz

Deek

  • Full Member
  • ***
  • Posts: 133
Re: ...just another big Custom Action collection (A-L)
« Reply #17 on: March 10, 2018, 09:25:20 AM »
@craigz

Thanks for your kind words.

I was actually spending the last few weeks creating a helper class for GDE containing various useful functions for the GDE PlayMaker actions, because there was a lot of redundancy in them (unnecessary duplicate code); meaning that you will also need that script to make most of the other actions work, but also that there are now even more actions for GDE available :)

Additionally, I've combined the Add Int, Add Float, Multiply Int and Multiply Float into Float Operator and Int Operator, but you can still use the old versions in your project if you want.

With Celeste's help I also figured out how to remove items, though I'm not quite convinced that it works 100% of the time, that's why it would be great if you could also test the action "GDERemoveItem". To debug the ModifiedData dictionary, I've also created the GDEDebugData action, to make that process more simple.

Currently, there's also a problem with GDECreateItem not applying the field values, so you should stick to the previous version until I fix that (and GDEFind is currently not finding any Field Types, but that's a minor issue). If you run into any problem with the new actions, don't hesitate to notify me.

P.S.: Because of the character limit on this topic I had to split it in half, which means that the third party section is now on this post if you're looking for updates, because I'm not done with creating actions for GDE yet :D


Edit (important):
Now I know why I wasn't quite convinced: In order to completely remove an Item from the GDE data it's for some reason also necessary to remove the Item from the DataDictionary, not just the ModifiedData. I adjusted the function so now it removes any Item correctly 100% of the time.
I also bundled the current version of my GDE actions so that you (or anyone interested) doesn't need to download my whole repo or has to copy over each single script individually (see attachments).

Edit 2:
"also"-Counter: 8 :P
« Last Edit: January 14, 2019, 10:37:25 AM by Deek »

craigz

  • Beta Group
  • Full Member
  • *
  • Posts: 234
    • Haven Made
Re: ...just another big Custom Action collection (A-L)
« Reply #18 on: April 19, 2018, 03:17:28 PM »
Deek!

I am SO sorry again for the late response, I forgot to click notify on the thread xP

Ahh! :D I'm so excited to play with these actions, thanks for making an operator for the float/int interactions as well, I had ended up building out a few of them that I needed, but combined is WAY more practical :)

Saw your edit change on the other topic, so I'll be sure to download the actions from your repo instead. So, SO useful :D

-craigz



craigz

  • Beta Group
  • Full Member
  • *
  • Posts: 234
    • Haven Made
Re: ...just another big Custom Action collection (A-L)
« Reply #19 on: June 21, 2018, 05:05:50 PM »
Hey Deek! :D

Just wanted to give a shout, I'm having issues with the (more) updated version of GDE Bool Test, for some reason if I point it towards an older GDE bool I've created, it works no problem, but any of my new ones I've made I get a 'InvalidCastException' from xD

Any ideas? :/

-craigz

*EDIT: I'm primarily using the action in a template, but am getting the issue in and out of a template.

Code: [Select]
InvalidCastException: Cannot cast from source type to destination type.
HutongGames.PlayMaker.Actions.GDEBoolTest.CheckGDEBool () (at Assets/PlayMaker Custom Actions/UsefulUnityUtilitiesMaster/Custom PlayMaker Actions/_ThirdParty/GDE Customs/GDEBoolTest.cs:56)
HutongGames.PlayMaker.Actions.GDEBoolTest.OnEnter () (at Assets/PlayMaker Custom Actions/UsefulUnityUtilitiesMaster/Custom PlayMaker Actions/_ThirdParty/GDE Customs/GDEBoolTest.cs:40)
HutongGames.PlayMaker.FsmState.ActivateActions (Int32 startIndex) (at C:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:205)
HutongGames.PlayMaker.FsmState.OnEnter () (at C:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:175)
HutongGames.PlayMaker.Fsm.EnterState (HutongGames.PlayMaker.FsmState state) (at C:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2695)
HutongGames.PlayMaker.Fsm.SwitchState (HutongGames.PlayMaker.FsmState toState) (at C:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2642)
HutongGames.PlayMaker.Fsm.UpdateStateChanges () (at C:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2570)
HutongGames.PlayMaker.Fsm.UpdateState (HutongGames.PlayMaker.FsmState state) (at C:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2711)
HutongGames.PlayMaker.Fsm.Update () (at C:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:1934)
HutongGames.PlayMaker.Actions.RunFSMAction.OnUpdate () (at Assets/PlayMaker/Actions/RunFSMAction.cs:55)
HutongGames.PlayMaker.FsmState.OnUpdate () (at C:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:265)
HutongGames.PlayMaker.Fsm.UpdateState (HutongGames.PlayMaker.FsmState state) (at C:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2710)
HutongGames.PlayMaker.Fsm.Update () (at C:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:1934)
PlayMakerFSM.Update () (at C:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/PlayMakerFSM.cs:539)
« Last Edit: June 21, 2018, 05:15:12 PM by craigz »

craigz

  • Beta Group
  • Full Member
  • *
  • Posts: 234
    • Haven Made
Re: ...just another big Custom Action collection (A-L)
« Reply #20 on: June 22, 2018, 10:48:51 PM »
Sorry for the double post :) also wanted to ask if you know of any way with the current actions to reset a particular item at run time? (all of its fields) Rather than having to manually reset them all xP

I have a feeling there might already be a way and I'm overlooking a term, but I though I should ask :D

Thanks again Deek for all these rad actions! :D

-craigz

Deek

  • Full Member
  • ***
  • Posts: 133
Re: ...just another big Custom Action collection (A-L)
« Reply #21 on: June 24, 2018, 01:32:55 PM »
No problem.
To reset all fields of an Item I've made a GDEResetItem action that you can get from my Repo or the attachments.
This one (and the ResetFields action) removes the item fields from the ModifiedData dictionary (changed data), unlike the RemoveItem action that also clears it from the DataDictionary (persistent data).

For the GDEBoolTest problem, please replace your GDEHelpers.cs script with the version in the attachments, which should work more reliable (because I reverted back to using the GDEGetBool approach to retrieve bool variables).
The InvalidCastException also often only shows up when the searched Item or Field couldn't be found, so another thing to make sure when such an error pops up is that the given search parameters are correct and that the Item/Field exists at all ("InvalidCast" because it tries to convert the retrieved object to a boolean and if the retrieved result is null/non-existent it throws this exception).

craigz

  • Beta Group
  • Full Member
  • *
  • Posts: 234
    • Haven Made
Re: ...just another big Custom Action collection (A-L)
« Reply #22 on: June 25, 2018, 12:20:23 AM »
AH! :D

Deek you are seriously the best :) you make me feel invincible with GDE! :D

So a huge thank you for the updates and the scripts, it really means a lot to me. I'm pulling them in now.

Good call on double checking for existing an Item/Field, always my first gut call :) good to know that's what the InvalidCastException is usually meaning.

best,

craigz

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: ...just another big Custom Action collection (A-L)
« Reply #23 on: September 06, 2018, 07:05:29 PM »
Thanks for the actions! I also found a bug in one of them.

SendEventSetValue.cs
Bug: It works exactly once, then stops working. I suspect that it doesn't reset properly.

In the screenshot attached you see the setup. The top action is SendEventSetValue.cs and this produces the problem as described. The two lower actions do the same, but by conventional methods (which works). I only put them together to show the setup.

Hope that helps :)







Deek

  • Full Member
  • ***
  • Posts: 133
Re: ...just another big Custom Action collection (A-L)
« Reply #24 on: September 07, 2018, 04:50:44 PM »
@Thore
I tried to replicate it, but it always seemed to work for me. I've also used that action in one of my projects for a prolonged time without noticing anything like that.
One thing you could do is to update the action in the Ecosystem, that should reimport it and might fix this behavior.
If it still doesn't work, could you please test that action in simplified setup, to make sure that the problem lies within the action and not something else?

szomaza

  • Sr. Member
  • ****
  • Posts: 253
Re: ...just another big Custom Action collection (A-L)
« Reply #25 on: October 28, 2018, 06:25:52 AM »
Thanks for the actions!

I noticed that the "Get Multilevel GameObject" is a bit buggy.
- With 0 it gets the owner as it should,
- With -1 it does not do anything, (something buggy here and then all the rest are offset)
- with -2 it gets the 1st child,
- with -3 it gets the 1st child of the 1st child,
- ...

Br,
szomaza


Code: [Select]
// License: Attribution 4.0 International (CC BY 4.0)
/*--- __ECO__ __PLAYMAKER__ __ACTION__ ---*/
// Author : Deek

using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.GameObject)]
[HelpUrl("http://hutonggames.com/playmakerforum/index.php?topic=15458.0")]
[Tooltip("Get the Game Object and name of a higher parent or lower child specified by an index.")]
public class GetMultilevelGameObject : FsmStateAction
{
[RequiredField]
[Tooltip("The GameObject to start from.")]
public FsmOwnerDefault startingFrom;

[Tooltip("How many 'Directories' to go up or down. For example '2' would be the grandparent of the GameObject this FSM is attached to, '3' the parent of that one ... and so on. 0 returns the Owner. Anything below 0 goes in the other direction (-2 = first Child of the first Child). You can also set a very high number to definitely get the root.")]
public FsmInt index;

[UIHint(UIHint.Variable)]
[Tooltip("The final GameObject it reached.")]
public FsmGameObject storeResult;

[Tooltip("The Name of the final GameObject it reached.")]
public FsmString storeResultName;

[Tooltip("Follow the path it takes (throws Debug.Log's for every GameObject it passes). If there are several Log entries with the same GameObject, it means that the given index is higher than the GameObject has parents or lower than it has children.")]
public FsmBool debug;

public override void Reset()
{
startingFrom = null;
index = 1;
storeResult = null;
storeResultName = null;
debug = false;
}

public override void OnEnter()
{
var go = Fsm.GetOwnerDefaultTarget(startingFrom);
if(go != null)
{
//Get Owner
if(index.Value == 0)
{
storeResult.Value = Owner;
storeResultName = storeResult.Value.name;
if(debug.Value == true)
{
Debug.Log("GetMultilevelGameObject - Owner: " + Owner);
}

}

//Get ascending parent
if(index.Value > 0)
{
for(int i = 1; i < index.Value; ++i)
{

go = go.transform.parent == null ? go : go.transform.parent.gameObject;

if(debug.Value == true)
{
var j = i + 1;
Debug.Log("GetMultilevelGameObject - Parent " + j.ToString() + ": " + go.transform.gameObject.name);
}

storeResult.Value = go;
storeResultName = storeResult.Value.name;
}
}

//Get descending Child
if(index.Value < 0)
{
for(int i = -1; i > index.Value; i--)
{
go = go.transform.GetChild(0) == null ? go.transform.gameObject : go.transform.GetChild(0).gameObject;

if(debug.Value == true)
{
//Invert and add 1 to current Index
var j = (i * (-1)) + 1;
Debug.Log("GetMultilevelGameObject - Child " + j.ToString() + ": " + go.transform.gameObject.name);
}

storeResult.Value = go;
storeResultName = storeResult.Value.name;
}
}

}
//If startingFrom is Null
else
{
storeResult.Value = null;
storeResultName = "None";
if(debug.Value == true)
Debug.Log("GetMultilevelGameObject - NullReferenceException: 'Start From' is null");
}
Finish();
}
}
}

Deek

  • Full Member
  • ***
  • Posts: 133
Re: ...just another big Custom Action collection (A-L)
« Reply #26 on: October 28, 2018, 05:59:26 PM »
Yeah, I wasn't that thorough on that one. I initially created it to find certain parent GameObjects by level index and searching the other way was more of a by-product.

I now re-worked it, so that it gets the actual GameObject at the given index and that it stops when the index is too high or too low (also adjusted how the debug messages are formated). Additionally, I added the option to go through the children recursively or only search through the children of the starting GameObject.
You can get the new version by updating the action in the Ecosystem.

Thanks for reminding me to fix this action, as I kept putting it of.

Macol90

  • Playmaker Newbie
  • *
  • Posts: 15
Re: ...just another big Custom Action collection (A-L)
« Reply #27 on: November 02, 2018, 02:59:10 PM »
I just want to thank you for these Actions! I've used several of them. Other than Jean I didn't realize anyone added so many! I just want to say thanks for all your hard work, and your effort hasn't gone unnoticed!

Good luck with the project!
Cheers!
Mike

Deek

  • Full Member
  • ***
  • Posts: 133
Re: ...just another big Custom Action collection (A-L)
« Reply #28 on: November 02, 2018, 03:30:40 PM »
Thanks a lot, man!
I appreciate your appreciation :D

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: ...just another big Custom Action collection (A-L)
« Reply #29 on: January 14, 2019, 02:16:12 AM »
Hi Deek,

 Thanks for your contributions.

 one thing: StringAppend is a duplicate, it exists already in PlayMaker built in actions, I renamed to StringAppend2.

Always make sure you don't push actions on a repository that has errors. Simply run that repository with Unity to make sure all your actions compiles, the you can push/.

Bye,

 Jean