Skip to content

Commit ff18b2e

Browse files
committed
2 parents 793ff97 + f3b5e0f commit ff18b2e

File tree

5 files changed

+81
-14
lines changed

5 files changed

+81
-14
lines changed

examples/Loading Bar.nys

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
dec str number: "-1";
1+
dec int number: 0;
22
dec str loading: "";
3-
loop(7) {
3+
loop(6) {
44
loading: "";
55
loop(number) {
66
loading: loading "#";

examples/Odd or Even.nys

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
log("Hi this is the odd or even example type a number");
2+
dec int number: input();
3+
if (math(number%2) == "0") {
4+
log("even");
5+
}
6+
else {
7+
log("odd");
8+
}

examples/Rock Paper Scissors.nys

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
log("This is rock paper scissors pick one (R/P/S)");
2+
dec int picked: round(math(random*2));
3+
dec str picked_player: input();
4+
if (picked == "0") {
5+
log("it was a draw");
6+
}
7+
if (picked == "1") {
8+
log("you lost");
9+
}
10+
if (picked == "2") {
11+
log("you won");
12+
}

src/run.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ pub fn run(
192192
func_par.clone(),
193193
func_code.clone(),
194194
);
195-
if number_of_times > 0 as f32 {
195+
if number_of_times > 0 as f64 {
196196
let mut n = 0;
197197
let mut reached = false;
198198
let mut loc1 = 0;

src/run/functions.rs

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,21 @@ pub fn getstring(
771771
}
772772
skips = leng;
773773
} else if vec[y] == "timeh" {
774-
imput_s.push_str(time_readable().to_string().as_str());
774+
imput_s.push_str(
775+
time_readable(
776+
y,
777+
vec.to_vec(),
778+
memory_names.clone(),
779+
memory_values.clone(),
780+
memory_types.clone(),
781+
func_names.clone(),
782+
func_par.clone(),
783+
func_code.clone(),
784+
dev,
785+
)
786+
.to_string()
787+
.as_str(),
788+
);
775789
let mut leng = 0;
776790
let mut n2 = 0;
777791
let mut skip1 = false;
@@ -1537,7 +1551,7 @@ pub fn math(
15371551
_func_names: Vec<String>,
15381552
_func_par: Vec<String>,
15391553
_func_code: Vec<String>,
1540-
) -> f32 {
1554+
) -> f64 {
15411555
meval::eval_str(
15421556
getstring(
15431557
x,
@@ -1558,7 +1572,7 @@ pub fn math(
15581572
)
15591573
.unwrap()
15601574
.to_string()
1561-
.parse::<f32>()
1575+
.parse::<f64>()
15621576
.unwrap()
15631577
}
15641578

@@ -1597,14 +1611,47 @@ pub fn trim(
15971611
};
15981612
}
15991613

1600-
pub fn time_readable() -> String {
1601-
let time = time();
1602-
let d = UNIX_EPOCH + Duration::from_millis(time as u64);
1603-
// Create DateTime from SystemTime
1604-
let datetime = DateTime::<Utc>::from(d);
1605-
// Formats the combined date and time with the specified format string.
1606-
let timestamp_str = datetime.format("%Y-%m-%d %H:%M:%S.%f").to_string();
1607-
timestamp_str
1614+
pub fn time_readable(
1615+
x: usize,
1616+
contents: Vec<String>,
1617+
memory_names: Vec<String>,
1618+
memory_values: Vec<String>,
1619+
memory_types: Vec<String>,
1620+
func_names: Vec<String>,
1621+
func_par: Vec<String>,
1622+
func_code: Vec<String>,
1623+
dev: bool,
1624+
) -> String {
1625+
let getstirng = getstring(
1626+
x,
1627+
contents,
1628+
memory_names,
1629+
memory_values,
1630+
memory_types,
1631+
func_names,
1632+
func_par,
1633+
func_code,
1634+
dev,
1635+
0,
1636+
);
1637+
if !getstirng.is_empty() {
1638+
let time: f64 = getstirng.first().unwrap().parse().unwrap();
1639+
println!("{}", time);
1640+
let d = UNIX_EPOCH + Duration::from_millis(time as u64);
1641+
// Create DateTime from SystemTime
1642+
let datetime = DateTime::<Utc>::from(d);
1643+
// Formats the combined date and time with the specified format string.
1644+
let timestamp_str = datetime.format("%Y-%m-%d %H:%M:%S.%f").to_string();
1645+
timestamp_str
1646+
} else {
1647+
let time = time();
1648+
let d = UNIX_EPOCH + Duration::from_millis(time as u64);
1649+
// Create DateTime from SystemTime
1650+
let datetime = DateTime::<Utc>::from(d);
1651+
// Formats the combined date and time with the specified format string.
1652+
let timestamp_str = datetime.format("%Y-%m-%d %H:%M:%S.%f").to_string();
1653+
timestamp_str
1654+
}
16081655
}
16091656

16101657
pub fn get_line(x: usize, contents: Vec<String>) -> i32 {

0 commit comments

Comments
 (0)