playMaker

Author Topic: [SOLVED] EasySave2/ArrayMaker actions bug  (Read 4049 times)

ermak

  • Junior Playmaker
  • **
  • Posts: 60
    • AL Games
[SOLVED] EasySave2/ArrayMaker actions bug
« on: November 09, 2014, 05:14:03 PM »
Hi,

I found bug in these actions:
https://hutonggames.fogbugz.com/default.asp?W715
ArrayMakerEasySave2.unitypackage

ArrayListEasyDownload
ArrayListEasyUpload
HashTableEasyDownload
HashTableEasyUpload


Error Message and Error Code, can't saving in variables:



This is very important for the game logic, for example to show in UI "error name and what kind is"...

This is code from EasySave v2.26 : Action "DownloadString"
And everything working fine:
(I can't paste actions from EasySave 2.51 because they are inside .DLL)

Quote
[ActionCategory("Easy Save 2")]
   [Tooltip("Downloads a string from MySQL Server via ES2.php file. See moodkie.com/easysave/WebSetup.php for how to set up MySQL.")]
   public class DownloadString: FsmStateAction
   {
      [RequiredField]
      [Tooltip("The variable we want to load our data into.")]
      public FsmString loadValue;
      [RequiredField]
      [Tooltip("The URL to our ES2.PHP file. See http://www.moodkie.com/easysave/WebSetup.php for more information on setting up ES2Web")]
      public FsmString urlToPHPFile = "http://www.mysite.com/ES2.php";
      [RequiredField]
      [Tooltip("The username that you have specified in your ES2.php file.")]
      public FsmString username = "ES2";
      [RequiredField]
      [Tooltip("The password that you have specified in your ES2.php file.")]
      public FsmString password = "65w84e4p994z3Oq";
      [RequiredField]
      [Tooltip("The unique tag for this save. For example, the object's name if no other objects use the same name.")]
      public FsmString uniqueTag = "";
      [RequiredField]
      public FsmString saveFile = "defaultES2File.txt";
      [Tooltip("The name of the local file we want to create to store our data. Leave blank if you don't want to store data locally.")]
      public FsmString localFile = "";
      [Tooltip("The Event to send if Download succeeded.")]
      public FsmEvent isDownloaded;
      [Tooltip("The event to send if Download failed.")]
      public FsmEvent isError;
      [Tooltip("Where any errors thrown will be stored. Set this to a variable, or leave it blank.")]
      public FsmString errorMessage = "";
      [Tooltip("Where any error codes thrown will be stored. Set this to a variable, or leave it blank.")]
      public FsmString errorCode = "";
      
      private ES2Web web = null;
      
      public override void Reset()
      {
         uniqueTag = "";
         saveFile = "defaultES2File.txt";
         loadValue = null;
         urlToPHPFile = "http://www.mysite.com/ES2.php";
         web = null;
         errorMessage = "";
         errorCode = "";
      }
      
      public override void OnEnter()
      {
         web = new ES2Web(urlToPHPFile+"?tag="+uniqueTag+"&webfilename="+saveFile+"&webpassword="+password+"&webusername="+username);
         this.Fsm.Owner.StartCoroutine(web.Download());
         Log("Downloading from "+urlToPHPFile+"?tag="+uniqueTag+"&webfilename="+saveFile);
      }
      
      public override void OnUpdate()
      {
         if(web.isError)
         {
            errorMessage.Value = web.error;
            errorCode.Value = web.errorCode;
            Fsm.Event(isError);
         }
         else if(web.isDone)
         {
            Fsm.Event(isDownloaded);
            loadValue.Value = web.Load<string>(uniqueTag.Value);
            if(localFile.Value != "")
               web.SaveToFile(localFile.Value);
         }
      }
   }

This is code from ArrayMakerEasySave2.unitypackage : Action "HashTableEasyDownload"
And "Error Message" and "Error Code", not working with variables:

Quote
//   (c) Jean Fabre, 2011-2013 All rights reserved.
//   http://www.fabrejean.net

// INSTRUCTIONS
// Drop a PlayMakerHashTableProxy script onto a GameObject, and define a unique name for reference if several PlayMakerHashTableProxy coexists on that GameObject.
// In this Action interface, link that GameObject in "hashTableObject" and input the reference name if defined.
// Note: You can directly reference that GameObject or store it in an Fsm variable or global Fsm variable

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

namespace HutongGames.PlayMaker.Actions
{
   [ActionCategory("Easy Save 2")]
   [Tooltip("Loads a PlayMaker HashTable Proxy component From MySQL Server via ES2.php file. See moodkie.com/easysave/WebSetup.php for how to set up MySQL.")]
   public class HashTableEasyDownload : HashTableActions
   {
      
      [ActionSection("Set up")]
      
      [RequiredField]
      [Tooltip("The gameObject with the PlayMaker HashTable Proxy component")]
      [CheckForComponent(typeof(PlayMakerHashTableProxy))]
      public FsmOwnerDefault gameObject;

      [Tooltip("Author defined Reference of the PlayMaker HashTable Proxy component ( necessary if several component coexists on the same GameObject")]
      [UIHint(UIHint.FsmString)]
      public FsmString reference;
      
      [Tooltip("A unique tag for this save. For example, the object's name if no other objects use the same name. Leave to none or empty, to use the GameObject Name + Fsm Name + hashtable Reference as tag.")]
      public FsmString uniqueTag = "";
      
      [RequiredField]
      [Tooltip("The name of the file that we'll create to store our data. Leave as default if unsure.")]
      public FsmString saveFile = "defaultES2File.txt";
      
      [Tooltip("The name of the local file we want to create to store our data. Leave blank if you don't want to store data locally.")]
      public FsmString localFile = "";
      
      
      [ActionSection("Upload Set up")]
      
      [RequiredField]
      [Tooltip("The URL to our ES2.PHP file. See http://www.moodkie.com/easysave/WebSetup.php for more information on setting up ES2Web")]
      public FsmString urlToPHPFile = "http://www.mysite.com/ES2.php";
      [RequiredField]
      [Tooltip("The username that you have specified in your ES2.php file.")]
      public FsmString username = "ES2";
      [RequiredField]
      [Tooltip("The password that you have specified in your ES2.php file.")]
      public FsmString password = "65w84e4p994z3Oq";
      
      
      [ActionSection("Result")]
      [Tooltip("The Event to send if Download succeeded.")]
      public FsmEvent isDownloaded;
      [Tooltip("The event to send if Download failed.")]
      public FsmEvent isError;
      [Tooltip("Where any errors thrown will be stored. Set this to a variable, or leave it blank.")]
      public FsmString errorMessage = "";
      [Tooltip("Where any error codes thrown will be stored. Set this to a variable, or leave it blank.")]
      public FsmString errorCode = "";
      
      private ES2Web web = null;
      
      private string _tag;
      
      public override void Reset()
      {
         gameObject = null;
         reference = null;
         
         uniqueTag = new FsmString(){UseVariable=true};
         localFile = "";
         saveFile = "defaultES2File.txt";
         urlToPHPFile = "http://www.mysite.com/ES2.php";
         web = null;
         errorMessage = "";
         errorCode = "";
      }
      
         
      
      public override void OnEnter()
      {
         if ( SetUpHashTableProxyPointer(Fsm.GetOwnerDefaultTarget(gameObject),reference.Value) )
         {
            DownloadHashTable();
         }
      }
      
      private void DownloadHashTable()
      {
         if (! isProxyValid() )
            return;
         
         
         _tag = uniqueTag.Value;
         if (string.IsNullOrEmpty(_tag))
         {
            _tag = Fsm.GameObjectName+"/"+Fsm.Name+"/hashTable/"+reference.Value;
         }
         
         
         
         web = new ES2Web(urlToPHPFile+"?tag="+_tag+"&webfilename="+saveFile.Value+"&webpassword="+password.Value+"&webusername="+username.Value);
         this.Fsm.Owner.StartCoroutine(web.Download());
         Log("Downloading from "+urlToPHPFile.Value+"?tag="+uniqueTag.Value+"&webfilename="+saveFile.Value);
      }
      
      public override void OnUpdate()
      {
         if(web.isError)
         {
            errorMessage = web.error;
            errorCode = web.errorCode;
            Fsm.Event(isError);
            Finish();
         }
         else if(web.isDone)
         {
            Fsm.Event(isDownloaded);
            
            Dictionary<string,string> _dict = web.LoadDictionary<string,string>(_tag);
         
            if(localFile.Value != "")
            {
               web.SaveToFile(localFile.Value);
            }
            
            Log("DownLoaded from "+saveFile.Value+"?tag="+_tag);
   
            proxy.hashTable.Clear();
            
            foreach(string key in _dict.Keys)
            {      
               proxy.hashTable[key] = PlayMakerUtils.ParseValueFromString(_dict[key]);
            }
            
            Finish();
         }
      }
      
   }
}

I am with:
Playmaker 1.7.7.2
Easy Save 2.51
ArrayMaker.unitypackage
ArrayMakerEasySave2.unitypackage
(from https://hutonggames.fogbugz.com/default.asp?W715)

Please, if anyone can help me :)
« Last Edit: June 09, 2015, 09:47:15 AM by ermak »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: EasySave2/ArrayMaker actions bug
« Reply #1 on: November 10, 2014, 12:49:27 AM »
Hi,

 Ah yes, I'll correct that, a silly mistake, thanks for spotting this.

 Bye,

 Jean

ermak

  • Junior Playmaker
  • **
  • Posts: 60
    • AL Games
Re: EasySave2/ArrayMaker actions bug
« Reply #2 on: December 07, 2014, 01:05:00 PM »
I fix manually these 4 files:

ArrayListEasyDownload
ArrayListEasyUpload
HashTableEasyDownload
HashTableEasyUpload

with this code:

errorMessage.Value = web.error;
errorCode.Value = web.errorCode;


But if you have free time, please update .unitypackage on the wiki too:
https://hutonggames.fogbugz.com/default.asp?W715

Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: EasySave2/ArrayMaker actions bug
« Reply #3 on: December 18, 2014, 02:59:31 AM »
Hi,

 Thank for this, I'll push with your changes.

 Bye,

 Jean

ermak

  • Junior Playmaker
  • **
  • Posts: 60
    • AL Games
Re: EasySave2/ArrayMaker actions bug
« Reply #4 on: May 30, 2015, 05:28:30 AM »
Hello,

I just check again here:
https://hutonggames.fogbugz.com/default.asp?W715

And these unity packages:
Unity 4 - ArrayMakerEasySave2.unitypackage
Unity 5 - ArrayMakerEasySave2.unitypackage


Are not fixed.

So, if anyone have problems with "Error Message" and "Error Code" saving in variables, these files must be edited:

ArrayListEasyDownload
ArrayListEasyUpload
HashTableEasyDownload
HashTableEasyUpload


From:
errorMessage = web.error;
errorCode = web.errorCode;


To:
errorMessage.Value = web.error;
errorCode.Value = web.errorCode;

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: EasySave2/ArrayMaker actions bug
« Reply #5 on: June 08, 2015, 08:03:29 AM »
Hi,

 This is now addressed, it's now also available directly on the Ecosystem :) just search for easy save



 Bye,

 Jean