Forum rules - please read before posting.

Timed Choices Setting in Options?

Hello,

Is there a way to control the speed of the timer for timed choices in the settings? I would like to include an option to be able to turn them off or change the speeds. I thought I would be able to just put in [var:10] into the timer and change it in the options menu but that doesn't seem to be the case. (I included this option in a previous game I made in Ren'py after it was requested by a couple of players with disabilities).

Sorry for the newbie question; I'm not very familiar with Unity yet.

Comments

  • Welcome to the community, @Eldritch.

    To be clear: are you referring to the "Is timed?" option for Conversations?

    A Conversation's timer can be modified, but only through script.  Inside Conversation.cs, it's the timer float variable.  A custom script could therefore store this initial value, and multiply it by a factor:

    http://pasteall.org/965367/csharp

    If you then use a Global float Variable to act as the factor (between 0 and 1), you can then read its value and update all such scripts:

    float factor = GlobalVariables.GetFloatValue (2); // Global float variable ID = 2
    ConvTimerChanger[] allTimeChangers = FindObjectsOfType <ConvTimerChanger>();
    foreach (ConvTimerChanger convTimeChanger in allTimeChangers)
    {
        convTimeChanger.SetTimerFactor (factor);
    }

    Any Global Variable can have its Link to field set to Options Data, which means its value will be stored in your game's PlayerPrefs, as opposed to individual save files.  A Slider menu element can be mapped to a variable, and a custom Action or event can then be used to run the above code when it is changed by the user.

    A tutorial on creating custom options can be found here.
  • The pasteall.org link no longer works?

  • I believe this was it:

    using UnityEngine;
    using AC;
    
    [RequireComponent (typeof (Conversation))]
    public class ConvTimerChanger : MonoBehaviour
    {
    
        private float initialTimer = -1f;
        private Conversation conversation;
    
    
        public void SetTimerFactor (int factor)
        {
            if (initialTimer < 0f)
            {
                conversation = GetComponent <Conversation>();   
                initialTimer = conversation.timer;
            }
            conversation.timer = initialTimer * factor;
            conversation.isTimed = (conversation.timer > 0f);
        }
    
    }
    
  • Took me a while to realize that Conv Timer Changer had to be attached to every conversation that had a timer. (Even after a year, when this was originally posted, I'm still terrible with the code side of Unity...)

    Thank you for all your help.

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.