Define a Variable to RANDOMLY select a number?

Learn how to use AAO by reading tutorials, and seek help from the AAO community.

Moderator: EN - Forum Moderators

Post Reply
Mosy
Posts: 76
Joined: Thu Aug 02, 2018 12:01 am
Gender: Male
Spoken languages: English

Define a Variable to RANDOMLY select a number?

Post by Mosy »

It's such a simple thing but I haven't gotten it to work.

What I'm looking for is to define a variable number between 1 and 5, COMPLETELY random. So each time the variable is defined it picks out a random number between 1 and 5.

One small question; Which coding language do Variables take in? (JS, Python, etc?)
Probably something everyone already knows (I don't, I'm sorry xD)

(TIMEAXIS TO THE RESCUE, WHERES MY BOY)

Thank you. <3
Live life as you enjoy it, pal!- :objection:
I guess not...
Image
User avatar
Enthalpy
Community Manager
Posts: 5172
Joined: Wed Jan 04, 2012 4:40 am
Gender: Male
Spoken languages: English, limited Spanish

Re: Define a Variable to RANDOMLY select a number?

Post by Enthalpy »

Go into advanced mode and mark the variable value as a runtime expression. Then set the variable value to

Code: Select all

f:random_int(1, 5)
.
[D]isordered speech is not so much injury to the lips that give it forth, as to the disproportion and incoherence of things in themselves, so negligently expressed. ~ Ben Jonson
Mosy
Posts: 76
Joined: Thu Aug 02, 2018 12:01 am
Gender: Male
Spoken languages: English

Re: Define a Variable to RANDOMLY select a number?

Post by Mosy »

Oh, that's way easier than I thought it would be, thank you Enthalpy my friend!
(So PHP it is)

Enthalpy wrote: Fri Sep 15, 2023 3:55 pm Go into advanced mode and mark the variable value as a runtime expression. Then set the variable value to

Code: Select all

f:random_int(1, 5)
.
Live life as you enjoy it, pal!- :objection:
I guess not...
Image
User avatar
TimeAxis
Posts: 392
Joined: Fri Jan 01, 2021 8:27 pm
Spoken languages: English
Contact:

Re: Define a Variable to RANDOMLY select a number?

Post by TimeAxis »

For your other question, it’s all technically within javascript, not PHP, but the expression system is sort of a custom scripting language designed by Unas, so you can’t necessarily rely on any knowledge of existing languages.

This thread, particularly the “Henke’s explanation of the expression engine” part, lists all the functions you can use. I recommend bookmarking it or something cause it’s a really useful thread.
Image
Question Arcs (Threads Coming Eventually)
ImageImageImageImage
Gaiden Episodes
Champion of Turnabouts ★
HALLOWEEN HERO
Other
Phoenix Wright: Ace Attornauts
The Curious Case of the Phantom Limousine (Coming Eventually)
The Imposter's Turnabout (Coming Maybe)
User avatar
Enthalpy
Community Manager
Posts: 5172
Joined: Wed Jan 04, 2012 4:40 am
Gender: Male
Spoken languages: English, limited Spanish

Re: Define a Variable to RANDOMLY select a number?

Post by Enthalpy »

TimeAxis wrote: Fri Sep 15, 2023 8:53 pm For your other question, it’s all technically within javascript, not PHP, but the expression system is sort of a custom scripting language designed by Unas, so you can’t necessarily rely on any knowledge of existing languages.

This thread, particularly the “Henke’s explanation of the expression engine” part, lists all the functions you can use. I recommend bookmarking it or something cause it’s a really useful thread.
I can heartily endorse that tutorial.

And yes, the expression system is a custom scripting language. Unas thought that letting users execute arbitrary code might be a security problem.
[D]isordered speech is not so much injury to the lips that give it forth, as to the disproportion and incoherence of things in themselves, so negligently expressed. ~ Ben Jonson
Mosy
Posts: 76
Joined: Thu Aug 02, 2018 12:01 am
Gender: Male
Spoken languages: English

Re: Define a Variable to RANDOMLY select a number?

Post by Mosy »

I SERIOUSLY never knew that! Ty for the link! Unas is one heck of a cool guy-
Oh my goodness. Thanks you two, that explains alot! <3
Enthalpy wrote: Sat Sep 16, 2023 4:10 am
TimeAxis wrote: Fri Sep 15, 2023 8:53 pm For your other question, it’s all technically within javascript, not PHP, but the expression system is sort of a custom scripting language designed by Unas, so you can’t necessarily rely on any knowledge of existing languages.

This thread, particularly the “Henke’s explanation of the expression engine” part, lists all the functions you can use. I recommend bookmarking it or something cause it’s a really useful thread.
I can heartily endorse that tutorial.

And yes, the expression system is a custom scripting language. Unas thought that letting users execute arbitrary code might be a security problem.
Live life as you enjoy it, pal!- :objection:
I guess not...
Image
Post Reply