Forum rules - please read before posting.

Emotional bar in 2d visual novel

I'm using adventure creator and love/heat, I want to make an emotional bar that goes up or down through the love/heat pad, but it doesn't detect it as local or global variables.

Through the modifications of the Pad I want to convert the numbers of happiness, pleasure, arousal and dominance into separate emotional bars.

Any suggestions.

Comments

  • edited January 2023

    To be clear: do you want AC to update its own Global Variables from Love/Heat's variables values?

    AC variable values can be modified through script - see the Manual's "Variable scripting" chapter, as well as the front page of the Scripting Guide.

    If you can provide the code necessary to read the Love/Hate values you want to convert to AC Variables (the asset's developer should be able to assist you with this), I can provide sample code that links them with AC.

  • edited January 2023

    With this script you can enter each variable of the pad, now you would have to choose a decision, review the variable and the emotion bar decreases or increases.
    Any suggestion would be good.
    The plugin is love/hate.

  • The "Input" menu element type can be used to enter in numeric values, and the Conversation object may be able to help provide a yes/no decision for the Player.

    In terms of having AC variables update love/hate variables however, I will still need to be provided with details of how that asset's data can be accessed. If you can share the code to be accessed from love/hate, I can assist with linking it to AC.

  • using UnityEngine;
    using UnityEngine.UI;
    using PixelCrushers.LoveHate;

    [RequireComponent(typeof(FactionMember))]
    public class PadBars : MonoBehaviour, IModifyPadDeedEventHandler
    {
    public Slider happiness;
    public Slider pleasure;
    public Slider arousal;
    public Slider dominance;

    private FactionMember factionMember;
    
    private void Awake() { factionMember = GetComponent<FactionMember>(); }
    
    public void OnModifyPad(float happinessChange, float pleasureChange, float arousalChange, float dominanceChange)
    {
        happiness.value = factionMember.pad.happiness;
        pleasure.value = factionMember.pad.pleasure;
        arousal.value = factionMember.pad.arousal;
        dominance.value = factionMember.pad.dominance;
    }
    

    }

    This is the code that the creator of the plugin gave me. I don't know if it will help you, I am attaching the message that he wrote to me.

    Making the emotions bar, I would already have all the mechanics of the visual novel.

    Sorry for the inconvenience.

  • No problem, thanks for the code.

    Here's that same script, modified to instead update AC variables:

    using UnityEngine;
    using UnityEngine.UI;
    using PixelCrushers.LoveHate;
    using AC;
    
    [RequireComponent(typeof(FactionMember))]
    public class PadBars : MonoBehaviour, IModifyPadDeedEventHandler
    {
    
        public string happinessVariableName = "Happiness";
        public string pleasureVariableName = "Pleasure";
        public string arousalVariableName = "Arousal";
        public string dominanceVariableName = "Dominance";
        public Variables variables;
    
        private FactionMember factionMember;
    
        private void Awake() { factionMember = GetComponent<FactionMember>(); }
    
        public void OnModifyPad(float happinessChange, float pleasureChange, float arousalChange, float dominanceChange)
        {
            UpdateGVar (happinessVariableName, factionMember.pad.happiness);
            UpdateGVar (pleasureVariableName, factionMember.pad.pleasure);
            UpdateGVar (arousalVariableName, factionMember.pad.arousal);
            UpdateGVar (dominanceVariableName, factionMember.pad.dominance);
        }
    
        private void UpdateGVar (string variableName, float newValue)
        {
            if (string.IsNullOrEmpty (variableName)) return;
    
            GVar variable = variables ? variables.GetVariable (variableName) : GlobalVariables.GetVariable (variableName);
            if (variable == null)
            {
                if (variables) ACDebug.LogWarning ("No variable named " + variableName + " found on " + variables.name, variables);
                else Debug.LogWarning ("No Globa variable named " + variableName + " found", this);
                return;
            }
            variable.FloatValue = newValue;
        }
    
    }
    

    The "Variables" Inspector field is optional - if set, it'll refer to Component variables. Unset, it'll assume the named variables are Global.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.