A downloadable Script

This is the flower script for Baldi's Funner Newer School. You can use it in your mod as long you credit me! Credits: Mystman12: Original Baldi's Basics. Baldi's Son: This Script.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Sprites;
public class FlowerScript : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        this.audioDevice = base.GetComponent<audiosource>(); // Get the Audio Device
    }
    // Update is called once per frame
    void Update()
    {
        if (this.stepcooldown > 0f) // If the step cooldown is more than 0
        {
            this.stepcooldown -= Time.deltaTime; // Decrease the cooldown
        }
        else // If not
        {
            this.UnStep(); // Do the "UnStep" Function
        }
    }
    private void OnTriggerEnter(Collider other)
    {
        if (other.name == "Player" & !this.stepped) // If the Player touches the flower while it's not stepped
            this.StepDo(); // Get stepped
    }
    private void StepDo()
    {
        if (!this.stepped) // If the flower isn't stepped
      this.audioDevice.PlayOneShot(this.aud_FlowerStepped, 1f); // Play the audio
      this.Baldi.Hear(base.transform.position, 3f);//Baldi hears the flower with a priority of 3.
      this.stepped = true; //Get stepped, Being unable to make noise for a while
      this.stepcooldown = 30; // A 30 second cooldown begins
      this.spritething.sprite = this.steppedSprite; // Switch the sprite to the stepped sprite
    }
    public void UnStep()
    {
        this.stepped = false; // Get unstepped, being able to make noise until it gets stepped, which triggers the cooldown
        this.spritething.sprite = this.unsteppedSprite; // Switch the sprite back to the unstepped sprite
    }
    public bool stepped;
    private AudioSource audioDevice;
    public AudioClip aud_FlowerStepped;
    public BaldiScript Baldi;
    public float stepcooldown;
    public SpriteRenderer spritething;
    public Sprite unsteppedSprite;
    public Sprite steppedSprite;
}

Leave a comment

Log in with itch.io to leave a comment.