Search Unity

API Calls Needed for Functions in My Game

Discussion in 'Scripting' started by jailbar, Nov 15, 2018.

  1. jailbar

    jailbar

    Joined:
    Nov 21, 2012
    Posts:
    49
    Alright,

    So I have a Roulette game that needs to have an API that can be called so that data can be sent to a Twitch bots server. My game functionality is pretty simple. This is my function to begin a roulette spin. I need a way to call this function from an API. I have a twitch streamer that is interested in being able to do this through an API so that they can call spins through their server.

    I also need to send the last winning number to their twitch bots server. Thanks.

    Code (CSharp):
    1. public bool SpinInProgress;
    2.  
    3.     public void SpinStart()
    4.     {
    5.         if(SpinInProgress == false)
    6.         {
    7.             bTracker.WIN_BOX.SetActive(false);
    8.         bTracker.ResetWinnings();  
    9.         bBetting.Balance -= bBetting.PendingWager;
    10.         bBetting.FinalWager = bBetting.PendingWager;
    11.         bBetting.PendingWager = 0;
    12.  
    13.         WinningOutcomes.text = "";
    14.         SpinSound.Play();
    15.         SpinSound.volume = 0.17f;
    16.         SpinInProgress = true;
    17.         RouletteBall.SetActive(true);
    18.         RouletteBall.transform.position = new Vector3(-4.27f, -3.61f, 11.645f);
    19.         NegativeSpin = !NegativeSpin;
    20.  
    21.         if(NegativeSpin)
    22.         {
    23.             RandomSpinSpeed = Random.Range(-433f, -333f);
    24.             RouletteWheel.rotateDegreesPerSecond.value.y = Random.Range(60f,90f);
    25.         }
    26.         else
    27.         {
    28.             RandomSpinSpeed = Random.Range(333f, 433f);
    29.             RouletteWheel.rotateDegreesPerSecond.value.y = Random.Range(-90f,-60f);
    30.         }
    31.  
    32.         SpinSpeed = RandomSpinSpeed;
    33.  
    34.         BounceUsed = false;
    35.         BounceSoundUsed = false;
    36.         LockedBall = false;
    37.         Orbiting = true;
    38.         Spinning = true;
    39.  
    40.         }
    41.     }
    Does anyone know if this is possible?