Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: djaydino on June 01, 2016, 01:29:11 PM

Title: coroutine in script
Post by: djaydino on June 01, 2016, 01:29:11 PM
Hi,
i am tying to make some actions to use http://dreamlo.com/ for a online highscore.

and i am trying to convert from this script : (http://s33.postimg.org/fsp6wdilr/Capture.jpg)

the problem is that i need to use a coroutine

Here is my Script so far :

Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2016. All rights reserved.
// Action Made By : DjayDino
/*--- __ECO__ __PLAYMAKER__ __ACTION__ ---*/

using UnityEngine;
using System.Collections;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("Web")]
[Tooltip("Saves highscore to Dreamlo website")]
public class DreamloAddScore : FsmStateAction
{
[RequiredField]
[Tooltip("Place Private Code from the Dreamlo website")]
public FsmString privateCode;

[RequiredField]
[Tooltip("Place Public Code from the Dreamlo website")]
public FsmString publicCode;

[RequiredField]
[Tooltip("Place Player Name Here. Player Name Must be urlfriendly (if player name exists it will change to the highest score and not add the name a 2nd time)")]
public FsmString PlayerName;

[RequiredField]
[Tooltip("Place Player Score Here")]
public FsmInt PlayerScore;

[Tooltip("Place Player Seconds left, Seconds done or any int value you need (level for example)")]
public FsmInt Secconds;

[Tooltip("Place any String here for example surname or rank (like Sergeant for example)")]
public FsmString text;

public FsmEvent isError;
[Tooltip("Where any errors thrown will be stored. Set this to a variable, or leave it blank.")]

public FsmString errorMessage = "";

private WWW www;

public override void Reset()
{
privateCode = null;
publicCode = null;
PlayerName = null;
PlayerScore = null;
Secconds = null;
errorMessage = "";
}

public override void OnEnter()
{
AddNewHighScore();

Finish();
}


public void AddNewHighScore()
{
if (text != null)
{
if (Secconds == null)
{
Secconds = 0;
}

www = new WWW("http://dreamlo.com/lb/" + privateCode.Value + "/add/" + WWW.EscapeURL(PlayerName.Value) + "/" + PlayerScore.Value + Secconds.Value + WWW.EscapeURL(text.Value));
Debug.Log("Has Text");
}

if (Secconds != null & text == null)
{
www = new WWW("http://dreamlo.com/lb/" + privateCode.Value + "/add/" + WWW.EscapeURL(PlayerName.Value) + "/" + PlayerScore.Value + Secconds.Value);
Debug.Log("Has Secconds");
}

if (text == null & Secconds == null)
{
www = new WWW("http://dreamlo.com/lb/" + privateCode.Value + "/add/" + WWW.EscapeURL(PlayerName.Value) + "/" + PlayerScore.Value);
Debug.Log("No Text No Secconds");
}
}
}
}

I am not using on awake, i only want a single score to be send each time i use the action.
Title: Re: coroutine in script
Post by: Alex Chouls on June 01, 2016, 02:43:13 PM
With 1.8.1 you can use Coroutines in actions.

Example usage:
https://hutonggames.fogbugz.com/default.asp?W1355

This should allow you to convert that script a lot easier.
Title: Re: coroutine in script
Post by: djaydino on June 01, 2016, 06:48:31 PM
Hi,
Thx i got it working now and indeed a lot easier :)

Is there a way to show or that this will only work on 1.8.1+ on the EcoSystem and/or when installed on a lower version?

(to jean) i want to have the actions i am making as a bundle, how can i do that or can i send them to you when i finish them?
Title: Re: coroutine in script
Post by: Alex Chouls on June 01, 2016, 09:36:00 PM
Playmaker 1.8.1 adds a PLAYMAKER_1_8_1 Scripting Define Symbol you could use.

Jean may also have methods in the Ecosystem to restrict access to certain Playmaker versions...
Title: Re: coroutine in script
Post by: djaydino on June 02, 2016, 05:00:43 AM
Hi,

I need to be able to have a selection list to select  xml/json/pipe and some others
just like you would have to select a variable type.

I think i saw it on a action before but i can't find it anymore
Title: Re: coroutine in script
Post by: djaydino on June 02, 2016, 06:52:30 AM
Also if possible,

It will have an option to choose to sort by name, by seconds or do not sort.
But i would like to to have a sub option then to choose ascending or descending.
Title: Re: coroutine in script
Post by: Alex Chouls on June 02, 2016, 10:09:24 AM
If you define Enums for your selections and declare a public field with that Enum you will get a selection popup. Is that what you're looking for?
Title: Re: coroutine in script
Post by: djaydino on June 03, 2016, 02:08:05 AM
Hi,
yes, but i 2 of the 4 selections need a sub selection.
how can i achieve that?

So when i select selection 2 and 4 it would pop up another selection with 2 options to choose from
Title: Re: coroutine in script
Post by: Alex Chouls on June 03, 2016, 10:41:50 AM
That sounds like you'd need to write a CustomActionEditor.

Or show the sub selections all the time, regardless of the first selection.

For examples of CustomActionEditors check out PlayMaker/Actions/Animator/Editor.

They're pretty easy to write and give you complete control over the UI.
Title: Re: coroutine in script
Post by: djaydino on June 03, 2016, 01:32:16 PM
Ok,
Thx i will check that out.
Title: Re: coroutine in script
Post by: jeanfabre on June 06, 2016, 02:53:00 AM
Hi,

 Catching up now after a great Unite :)

 so, where you able to get where you wanted? I am not sure what you mean to ask re distribution? can you rephrase? If you want me to send stuff for review, please do.

 Bye,

 Jean

Title: Re: coroutine in script
Post by: djaydino on June 06, 2016, 04:01:54 AM
Hi,
Yea i noticed to late that it was in amsterdam.
I could not get free anymore from my work :(

I am still working on a few actions, what i want is to have the actions i made into a package on the EcoSystem and not as single actions
Title: Re: coroutine in script
Post by: jeanfabre on June 06, 2016, 04:07:10 AM
Hi,

 That's cool. you know the procedure to publish packages to the Asset store right?

Bye,

 Jean
Title: Re: coroutine in script
Post by: djaydino on June 06, 2016, 04:09:13 AM
Hi,
No, i have not done that yet.
Thats what i was asking, how to do or if i can send the actions to you.
Title: Re: coroutine in script
Post by: jeanfabre on June 07, 2016, 03:23:17 AM
Hi,

 Ok, send it to me, I'll put in on the Ecosystem and then you'll see how it was done when you pull the rep on your end.

Bye,

 Jean
Title: Re: coroutine in script
Post by: djaydino on June 14, 2016, 11:48:07 AM
Hi jean,
Here are the actions
Title: Re: coroutine in script
Post by: jeanfabre on June 16, 2016, 03:40:12 AM
Hi,

 can you zip them or package them? the rar crashes when I want to unrar

Bye,

 Jean
Title: Re: coroutine in script
Post by: djaydino on June 18, 2016, 05:24:50 AM
Hi,
I placed them in a package, as i noticed that on github they are in a package also
together with a text file.
but i am not sure how to setup the file.

Code: [Select]
{
"__ECO__":"__PACKAGE__",
"Type":"Addon",          /*(the actions do not require an addon but they do need a codes from the website, so i am not sure what type to use)*/

"Version":"1.0.0",

"UnityMinimumVersion":"4.3.4",          /*(unsure what version is required)*/

"PlayMakerMinimumVersion":"1.8.1",          /*(i am using co-routine so 1.8.1 is required)*/

"unitypackage":"PlayMaker/Ecosystem/Custom Packages/Dreamlo/DreamloActions.unitypackage",

"pingAssetPath":"Assets/PlayMaker Dreamlo/readme.txt",

/* "YoutubeVideos":[""]            (video coming soon)*/
}
Title: Re: coroutine in script
Post by: jeanfabre on June 23, 2016, 03:55:39 AM
Hi,

 Since this is just actions, I am wondering why you want to make a package out of it?

also, your actions are in category "web", they should be in Category "Dreamlo" I would say no?

also, there is no read me and the path is wrong when you declare "pingAssetPath":"Assets/PlayMaker Dreamlo/readme.txt",

Let me know about the above, then I'l push

Bye,

 Jean
Title: Re: coroutine in script
Post by: djaydino on June 23, 2016, 02:58:12 PM
Hi,

I wanted them into a package because when you use this you need to use all actions anyway and then the user only needs to load one thing instead of 4 separately.

I placed them into web as they are used by a website but maybe it is better to set them into Dreamlo

There is no text message, i just copied and edited the code to ask how it works. so i guess the whole line is not needed the :)

Should i change "web" to Dreamlo?
and maybe add a read me saying that you need to go to the Dreamlo website to make a leaderboard?

I might update the package next week or the week after (i am on graveyard duty till half next week) with the promocode system from dreamlo.
Title: Re: coroutine in script
Post by: jeanfabre on June 24, 2016, 02:00:07 AM
Hi,

 ok, cool, Your explanations make sense, I would simply change the category to dreamlo indeed. For the rest it's cool.

let me know when you have a new package.

Bye,

 Jean