Author Topic: Add a boolean "random" choice  (Read 2512 times)

Malic

  • Full Member
  • ***
  • Posts: 105
Add a boolean "random" choice
« on: September 12, 2019, 03:04:56 PM »
Add a boolean "random" choice

AM trying to create a glitch effect and am having to create values and then have the Bool state look at them, would rather have a flip a coin style choice in the "set a value" screen


EDIT by Pfeil: Implemented.
« Last Edit: April 18, 2020, 12:43:34 PM by Pfeil »

TheThingIs

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 278
    • HCS Voicepacks
Re: Add a boolean "random" choice
« Reply #1 on: September 12, 2019, 05:01:07 PM »
I'm not sure any coding has a randomise boolean option but you can simply randomise an integer of 0 and 1 which is essentially what a boolean is.
The Singularity profile - One profile to rule them all and at HCS we bound them ;)

You see, TheThingIs, eventually you'll be allright.

Malic

  • Full Member
  • ***
  • Posts: 105
Re: Add a boolean "random" choice
« Reply #2 on: September 14, 2019, 08:50:05 PM »
Yes, but then you have it randomize, and then you have to reference the variable, then do the thing.  If you need 5 different coin flips for 5 different things, and that is three new lines mininum per thing, that is already 15 extra lines that I would rather not have to put in.

Am looking more for a reason to reduce the amount of lines needed so I can just call random on a single line.

Plugin that I am using requires that it be a Boolean operation, and I would rather not have to convert for every time.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Add a boolean "random" choice
« Reply #3 on: September 14, 2019, 09:16:14 PM »
Behind the scenes it'd require conversion anyway, you can't generate a random Boolean value directly.

You could do the same thing VoiceAttack would need to, in an inline function:
Code: [Select]
using System;

public class VAInline
{
public void main()
{
Random r = new Random();
VA.SetBoolean("~random", r.Next(2) == 0);
}
}

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: Add a boolean "random" choice
« Reply #4 on: September 14, 2019, 09:26:52 PM »
I was working in that screen tonight, so, I popped it in.  Be on the lookout for this in the next beta.


Only because I like you, Malic ;)



Edit - of course, at the rate that the current beta is going, that could be soon - or it could be in 3 years o_O

Malic

  • Full Member
  • ***
  • Posts: 105
Re: Add a boolean "random" choice
« Reply #5 on: September 16, 2019, 04:30:45 AM »
Thank you Gary <3

Will be on the lookout!