Random List Rule

Pendolino

Cab mode weirdo
I am trying to build a demonstration "layout" and I want a train coming out of a portal to randomly take one of two diverging lines.

I set up a trigger (trigger0) about 100 meters before the junction (junction0), then I added the following rules to the session:

- Check trackside (settings = when any train enters trigger0; runs repeatedly)
-- Random list
--- Set junctions (settings = set junction0 to left; unlocked)
--- Set junctions (settings = set junction0 to right; unlocked)

I thought, by reading the Sessions & Rules Guide, that following a Random List rule one of the its child rules, chosen at random, is executed together with its children rules (if any are present). The harsh reality, however, is different.

This set of rules works for the first train coming out of the portal. All the subsequent trains activate the trigger (I put a "Flash HUD Panel to be sure) but Random list does not activate and all the trains follow the direction of the first one. It seems that Random List works only once.

Can someone please help me to find where I am wrong? I'm almost sure I'm doing something wrong, but I have been unable to identify the error.
 
Have you tried putting the random list indented in a reset list?

Never tried it, but it might be just the ticket.
 
Another thing you might try is generating a random number, and dividing it by two, and choosing the rule using "case" statements. Using your exampe:


- Check trackside (settings = when any train enters trigger0; runs repeatedly)
-- Generate random number; divide by two
---case remainder 0 set junctions (settings = set junction0 to left; unlocked)
---case remainder 1 set junctions (settings = set junction0 to right; unlocked)


ns
 
I didn't know you could make rules using Basic-like statements such as "Case" and "Remainder". Where is the documentation for that?
Thanks,
Mick Berg.
 
I didn't know you could make rules using Basic-like statements such as "Case" and "Remainder". Where is the documentation for that?
Thanks,
Mick Berg.

There may not be support for such statements. I am new enough that I'm still fighting through the script API and the rules and sessions guide, and I may have not remembered as well as I though I did. However, my intent in the example I posted was not so much to provide a bit of code, as to outline the logic I was trying to propose, which may not be all that much different from the logic of the OP.

ms
 
There may not be support for such statements. I am new enough that I'm still fighting through the script API and the rules and sessions guide, and I may have not remembered as well as I though I did. However, my intent in the example I posted was not so much to provide a bit of code, as to outline the logic I was trying to propose, which may not be all that much different from the logic of the OP.

ms

I think he's trying to create sessions by stringing existing session rules together not scripting. This is the way most users do it. Programming isn't for everyone.
 
First, let me thank you all for your replies.

I tried to indent the Random List rule and its "Set Junctions" under a "Reset List", as suggested by Mr. Den but unfortunately it didn't work :( . The whole set of rules continues to make a single random selection, then sticks to it and the trains always follow the initial path.

As DLevine99 said in his post "Programming isn't for everyone". My last programming attempts were made in BASIC in the mid-'80s :D : I tried to understand how to make scripts for Trainz but all I obtained in return of my effort is a very, very vague understanding of the matter.

Basically, however, I'm trying to implement what stated by Mjolnir: the Random List rule should randomly select one of its "Set Junction" child rules according to the result of a random number generation process embedded in that rule. This arrangement works, but only once, and I have not been able to understand why: it looks like the trigger is not triggered by subsequent trains, but only by the first one. The line of the "Check Trackside" rule in the "Edit Session" drop-down menu, however, clearly states "Runs repeatedly". I'm puzzled...

I also thought about replacing the Random List rule with a "Wait" rule, and to use the random value generated as a session variable. Then I could use a series of "Check variable" to activate the "Set Junctions" rules.
 
Hi,

What about placing trackmarks down either leg of the junction. Then create two copies of each consist you want to appear from the portal. Say 1a and 1b. Train 1a is ordered to drive via the left trackmark and 1b is ordered to drive via the right trackmark. Let the portal pick a consist at random. Since the trains look the same except for the driver orders then it would appear that they are taking a random path.

Of course, this might not be what you are trying to demo.

Just a thought,

William
 
Thanks, William, the method you proposed will surely work and probably I will use it so as to proceed with this demo layout.

Anyway, I'm intrigued by the possibilities offered by the "Random List" rule. If I manage to have it working according to my ideas, it could be a great way to add some variation to sessions. I think that a session with changes every time you play it could be much more interesting than one following a fixed set of pre-arranged events. Imagine a layout consisting of a classification yard where some freights only stop for a crew change, while others terminate their run (i.e. are randomly directed to the arrival yard). The session could turn into a quiet railfanning session (perhaps taking some pictures on the main line :) ) or into frantic switching, trying to free the arrival yard before the main line becomes clogged with trains waiting to enter.
 
Back
Top