Author Topic: Creating random results with VCE?  (Read 933 times)

(not necessarily sure if this would be the correct place to put this, since it's not really a tech issue and thus wouldn't go in help, but oh well)

I'm trying to create a random result with VCE events but I can't seem to get it right. I'm trying to make it simply choose a random number from 1 - 3 and then play the appropriate sound depending on what's chose. The events I have right now are as follows:

What's the correct way to do this? As I have it now, once the events are triggered the game just stutters for a few seconds before reporting too many onVariableFalse events. I'm guessing I messed something up somewhere and it's just going through the whole thing a billion times before giving up.
I know a ton of you have a lot of good

Change your false variables into onItemPickup.

Note: I am rather new to VCE so I am not entirely certain if that will work, but just through common sense it seems that'll do the trick.

Also on The Modvariable space you need to use simply sound not <var:brick:sound> If it still doesn't work, try changing between OnVariable and Onvalue, because I always mix them up.

EDIT: at the end, when you definy which onVartrue or Onvarfalse events will be triggered, it is not a list. 4 5 doesnt mean use event line 4 and 5, it means use event line 4-5. This means you need to change 6 to 6 6.
« Last Edit: August 11, 2012, 04:17:55 PM by SgtDaemon »

yep, got it working now but it seems only capable of choosing between two sounds. if the third option is true the second one plays as well because it simply considers it larger. i also realized that this is really buggy and rather than choosing 1, 2, or 3, it just chooses a random ass decimal between 0 and 1? hell, it still works.

thanks for the help lads, though if anyone has ideas for a way to get it to work with 3 choices, that'd be nice.

put this line at the very top:onItemPickup > Self > VCE_ModVariable [ Brick ] [ sound ] [ set ] [ 0 ]

rather than choosing 1, 2, or 3, it just chooses a random ass decimal between 0 and 1? hell, it still works.

thanks for the help lads, though if anyone has ideas for a way to get it to work with 3 choices, that'd be nice.

Time for me to save the day.

Do as such:

Code: [Select]
[0] [Onitempickup] [self] [VCEmodvar] [player] [Sound] [Random]
[1] [Onvarupdate]*[self] [VCEifvalue] [<var:pl:Sound>] [<=] [.33] [2 4]
[2] [Onvartrue] [player] [playsound] [pickup1.wav]
[3] [Onvartrue] [player] [VCEmodvar] [Sound] [set] [ ]**
[4] [Onvarfalse] [self] [VCEifvalue]*** [<var:pl:Sound>] [>] [.33] [5 5]
[5] [Onvartrue] [self] [VCEifvalue] [<var:pl:Sound>] [<] [.66] [6 8]
[6] [Onvartrue] [player] [playsound] [pickup2.wav]
[7] [Onvartrue] [player] [VCEmodvar] [Sound] [set] [ ]
[8] [Onvarfalse] [self] [VCEifvalue] [<var:pl:Sound>] [>=] [.66] [9 10]
[9] [Onvartrue] [player] [playsound] [pickup3.wav]
[10] [Onvartrue] [player] [VCEmodvar] [Sound] [set] [ ]

*Onvariableupdate, if you didn't know, is the appropriate input for when a variable is modified or if a varlink is activated (still, a variable is modified).  This is a good choice to use when a single event, such as line 0 here, is the start for all of the other events on the brick.

**You see here that the box is empty.  This is how it should be set for when dealing with words, lists, or random numbers.  This way, an extra line of events doesn't need to be made to exclude 0 from the range.  Many people make mistakes here because they didn't know this simple fact.

***For future reference, ifvalue is generally for checking what a variable replacer is, such as <var:cl:posX>, usually these cannot be edited and are only for use for speed traps and such.  Variables you have set can also be checked with this and using ifvalue is generally more flexible than ifvariable, knowing when to use which comes with experience and is generally a preference.  Remember, ifvalue=<var:condition:variable>, while ifvariable=variable.  This is the way I like to explain it to those learning more advanced VCE.

Also, what I have written in the code box strays from my normal way of VCE eventing, as I like to use Retrocheck.  I decided to try this way so that Lugnut wouldn't start again about how Retrocheck is bad, which I still don't see why it is stuff.  Also, an earlier poster had suggested using onitempickup for every ifvalue output.  I advise against this, as you could encounter an error for multiple people picking up an item in a short amount of time-(yes, this does seem impossible, but I've been scarred a long time ago when I came across a problem similar to this).  I also used the Player condition in my example where you used Brick.  I advise against Brick for this for the same multiple person pickup reason, or even one person picking up several of the same item, because of a low item respawn time.

^overkill!!!1111
Time for me to save the day.
although i fondly remember myself doing almost this exact same thing a year ago...Scary.
I decided to try this way so that Lugnut wouldn't start again about how Retrocheck is bad, which I still don't see why it is stuff.

because it's depreciated and depreciated means it should die

^overkill!!!1111
ya, lol, I write a lot when I'm tired.

although i fondly remember myself doing almost this exact same thing a year ago...Scary.
what, saving the day?, or writing these events?

because it's depreciated and depreciated means it should die
interesting argument.

i actually once wrote "it looks like it's time for lugnut to save the day!" and then went on to make a wall of useful event text