forked from AbleScript/ablescript
44 lines
1.8 KiB
Rust
44 lines
1.8 KiB
Rust
//! Number constants.
|
|
|
|
use crate::variables::{Value, Variable};
|
|
use std::collections::HashMap;
|
|
|
|
pub const ANSWER: isize = 42;
|
|
|
|
/// Initialize a HashMap between the constant names and values
|
|
/// accessible from within AbleScript.
|
|
pub fn ablescript_consts() -> HashMap<String, Variable> {
|
|
use Value::*;
|
|
|
|
[
|
|
("TAU", Int(6)), // Circumference / radius
|
|
("PI", Int(3)), // Deprecated, do not use
|
|
("EULER", Int(3)), // Mathematical constant e
|
|
("MASS", Int(70)), // @Kev#6900's weight in kilograms
|
|
("PHI", Int(2)), // Golden ratio
|
|
("WUA", Int(1)), // 1
|
|
("EULERS_CONSTANT", Int(0)), // ???
|
|
("GRAVITY", Int(10)), // Earth surface gravity, m/s
|
|
("RNG", Int(12)), // Kixiron#5289 Randomly rolled dice
|
|
("STD_RNG", Int(4)), // The standard random number is 4 (https://xkcd.com/221/)
|
|
("INF", Int(isize::max_value())), // The biggest number
|
|
("INTERESSANT", Int(114514)), // HTGAzureX1212.#5959 intéressant number
|
|
("FUNNY", Int(69)), // HTGAzureX1212.#5959 funny number
|
|
(
|
|
// Never gonna let you down
|
|
"NEVERGONNAGIVEYOUUP",
|
|
Str("1452251871514141792252515212116".to_owned()),
|
|
),
|
|
("OCTOTHORPE", Str("#".to_owned())), // It's an octothorpe
|
|
("AMOGUS", Str("ඞ".to_owned())), // Amogus
|
|
("ANSWER", Int(ANSWER)),
|
|
("nul", Nul),
|
|
("always", Abool(crate::variables::Abool::Always)),
|
|
("sometimes", Abool(crate::variables::Abool::Sometimes)),
|
|
("never", Abool(crate::variables::Abool::Never)),
|
|
]
|
|
.into_iter()
|
|
.map(|(name, value)| (name.to_owned(), Variable::from_value(value)))
|
|
.collect()
|
|
}
|