BVE WorldWide
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Randomize objects

3 posters

Go down

Randomize objects Empty Randomize objects

Post by Rakago Wed Jun 23, 2021 5:48 pm

Hello!

Recently I've been working on the Class 321 for openBVE. The model is basically done, so I'm making small details for a better model overall.
So, I decided to start with the front numeration and I wonder, Is there any way to make them change every time you enter a route?

Ex: when you enter a route for the first time it shows this number...

Randomize objects 401
and if you enter a second time it shows this other number...
Randomize objects 402

Any ways to do it? Thanks in advance! Very Happy
Rakago
Rakago

Posts : 64
Join date : 2019-10-30
Age : 17
Location : Spain

https://openbveiberia.blogspot.com/

SP1900 likes this post

Back to top Go down

Randomize objects Empty Re: Randomize objects

Post by leezer3 Thu Jun 24, 2021 12:08 pm

Animated objects:
Use a separate object state for each of the desired numbers, and switch between them using a function with RandomInt
Not sure when this was added off the top of my head, but at least three years ago.

Rotefiles:
Use separate .FreeObj numbers and the $Rnd command to switch between them.
This should work all the way back to BVE4.


There's no way I can think of to sequentially number upwards, you'd just have to have a few different number models and switch between them Smile

leezer3

Posts : 1960
Join date : 2011-08-23

http://www.bvecornwall.co.uk

Rakago likes this post

Back to top Go down

Randomize objects Empty Re: Randomize objects

Post by Rakago Thu Jun 24, 2021 4:32 pm

Thanks! Although I'm not very good at animating files, can you tell me how I am supposed to write it correctly? (I've read the documentation too, but it didn't gave much info)
Randomize objects Nums
Thanks again!
Rakago
Rakago

Posts : 64
Join date : 2019-10-30
Age : 17
Location : Spain

https://openbveiberia.blogspot.com/

Back to top Go down

Randomize objects Empty Re: Randomize objects

Post by Midnight Express Ginga81 Thu Jun 24, 2021 6:26 pm

I think that you should write such as below:
Code:
[object]
states = nums/401.csv, nums/402.csv
StateFunction = randomInt[0, 1]
RotateYFunction = 3.141593653589793
I think that the 'randomInt' means recieve integer number.

Midnight Express Ginga81

Posts : 143
Join date : 2016-09-25

Back to top Go down

Randomize objects Empty Re: Randomize objects

Post by Rakago Fri Jun 25, 2021 11:33 am

Midnight Express Ginga81 wrote:I think that you should write such as below:
Code:
[object]
states = nums/401.csv, nums/402.csv
StateFunction = randomInt[0, 1]
RotateYFunction = 3.141593653589793
I think that the 'randomInt' means recieve integer number.
I've tried that, but the number doesn't change...
I also tried to write StateFunction = randomInt[0, 2] but then this happens:
https://drive.google.com/file/d/1UclzB7ob6_ILLchhcW0Bd9l8lJdR3g7x/view?usp=sharing


I don't know what to do, please help.
Rakago
Rakago

Posts : 64
Join date : 2019-10-30
Age : 17
Location : Spain

https://openbveiberia.blogspot.com/

Back to top Go down

Randomize objects Empty Re: Randomize objects

Post by Midnight Express Ginga81 Fri Jun 25, 2021 3:54 pm

Code:
[object]
states = test1.csv,test2.csv

;work correctly
;But these functions are ignored value 0. It is enable from 1.

;StateFunction = abs[ randomInt[0, 2] ]
;StateFunction = ceiling[ randomInt[0, 2] ]
StateFunction = randomInt[0, 2]
;I do not know why so not start from 0.
;And I don't know why randomInt cannot use directly.

;do not work. only test1.csv show
;StateFunction = randomInt[0, 1]

I tested create these csv and animated.
These commands can change randomly by 'randomInt'.
But, these animated cannot change at only the start of the game.
There are always change.
I don't know how to only change the when the start the game only one time change rondomly.
If someone wants these sample file, I create the new issue to github, and upload.

Midnight Express Ginga81

Posts : 143
Join date : 2016-09-25

Back to top Go down

Randomize objects Empty Re: Randomize objects

Post by Rakago Fri Jun 25, 2021 5:21 pm

Nevermind, I finally sorted it out thanks to a guy I have contacts with. The solution is to write RefreshRate = 1000000 after the RandomInt command.

Like this: 

[object]
states = nums/401.csv, nums/402.csv
StateFunction = randomInt[0, 2]
RefreshRate = 1000000

Thanks everyone for the help anyway! Smile Smile
Rakago
Rakago

Posts : 64
Join date : 2019-10-30
Age : 17
Location : Spain

https://openbveiberia.blogspot.com/

Midnight Express Ginga81 likes this post

Back to top Go down

Randomize objects Empty Re: Randomize objects

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum