fungus

Open full view…

Help with custom Set Variable and Call code please

gs3
Tue, 23 Jan 2018 11:43:51 GMT

Hi, I have a codeless IAP button where once the transaction is complete, I'd like to set a variable (one from the flowchart) and also call a block. PartyBusiness wrote this code a couple years ago, but I can't figure out the correct tweaks. The errors are that the variable (already set up in the flowchart as recommended) don't change, and the onComplete, selectedBlock and parentBlock tages on lines 56-58, what goes there? Thanks, still learning, -gs ---using UnityEngine; using UnityEngine.Serialization; using System.Collections; using System.Collections.Generic; using System; namespace Fungus { [CommandInfo("Special", "Set Vars and Call", "Sets four variables and calls a block.")] [AddComponentMenu("")] public class VarsAndCall : Command { [Tooltip("Flowchart which contains the block to execute. If none is specified then the current Flowchart is used.")] public Flowchart targetFlowchart; [Tooltip("Block to start executing")] public String blockName; [Tooltip("Character name")] public String charName; [Tooltip("Height")] public int height; [Tooltip("Weight")] public int weight; [Tooltip("Age")] public int age; Flowchart flowchart; Block targetBlock; public override void OnEnter() { Flowchart flowchart = GetFlowchart(); //Set variables flowchart.SetStringVariable("Name", charName); flowchart.SetIntegerVariable("Height", height); flowchart.SetIntegerVariable("Weight", weight); flowchart.SetIntegerVariable("Age", age); if (targetFlowchart == null) targetFlowchart = flowchart; if (targetBlock == null) targetBlock = targetFlowchart.FindBlock(blockName); if (targetBlock != null) { Action onComplete = onComplete = delegate { flowchart.selectedBlock = parentBlock; Continue(); }; targetFlowchart.ExecuteBlock(targetBlock, onComplete); } } public override string GetSummary() { return blockName; } public override Color GetButtonColor() { return new Color32(235, 191, 217, 255); } } }---

gs3
Tue, 23 Jan 2018 17:07:47 GMT

Worked through the bugs, if anyone needs help setting up codeless IAP, I have some good scripts now.

ocol072
Tue, 01 Jan 2019 17:12:55 GMT

hey can you help me with codeless iap? i want to set the button to add variable value in fungus.

gs3
Tue, 01 Jan 2019 17:15:43 GMT

the best way I found was to go to inspector for the button and there is a command for completed purchase, then in there choose flowchart from scene as the gameobject, then function is executeBlock, and you put in the string for that block, and then in the block you set the variable and have the "thank you for the purchase" message. Test it a bunch.

ocol072
Tue, 01 Jan 2019 17:34:53 GMT

wow thank you so much. it works. But do you know if the user update my game ( android ), will the variable reset or saved in playerpref?

gs3
Tue, 01 Jan 2019 17:38:25 GMT

I could never get the restart button in the savegame UI to ignore a variable and not reset it. I tried a lot, it reset every time. I ended up reprogramming the restart button to go to a point just after the gamestart block.

ocol072
Tue, 01 Jan 2019 18:31:16 GMT

btw can you help me to show variable value ( lets say my variable value is 500 ) to Ui text? it will help me so much