Page 1 of 1

[EOS] Can't "say" a variable

Posted: Thu Jul 13, 2023 9:52 am
by matschbirne
Hey
i want to say the contents of a variable. I've used an eval tag in the say command, but it just freezes. I've defined te var by using let x=0; . I've tried to convert it to a string, I've even tried the tease storage... This seems really simple so why doesn't it work? I'm not that familiar with jscript, learned a bit java at school, so maybe I've done a mistake correlated to that?
Thanks for your help

Re: [EOS] Can't "say" a variable

Posted: Thu Jul 13, 2023 9:56 am
by matschbirne
I've found out, let is local and not global.... I need to use var to define the variable

Re: [EOS] Can't "say" a variable

Posted: Thu Jul 13, 2023 4:39 pm
by Roblsforbobls
matschbirne wrote: Thu Jul 13, 2023 9:52 am I've defined te var by using let x=0
I usually just use "x = 0" and don't bother with var or let or anything like that. Idk, maybe I'm doing it horribly wrong, but it works for me lol

Re: [EOS] Can't "say" a variable

Posted: Thu Jul 13, 2023 6:20 pm
by Thamrill
matschbirne wrote: Thu Jul 13, 2023 9:56 am I've found out, let is local and not global.... I need to use var to define the variable
Also, if I remember correctly, EOS doesn't support the let keyword

Re: [EOS] Can't "say" a variable

Posted: Fri Jul 14, 2023 12:24 pm
by kerkersklave
Roblsforbobls wrote: Thu Jul 13, 2023 4:39 pm I usually just use "x = 0" and don't bother with var or let or anything like that. Idk, maybe I'm doing it horribly wrong, but it works for me lol
Javascript does not require you to initialize or declare variables. It has advantages to do that in the global script though. Declaring variables makes it clear, which variables exist, and initializing them ensures that they always have a valid value and avoids completely unexpected and hard to debug behavior. That's why in professional software development it is often a rule to do that.

Some other points:
- EOS only supports an older version of Javascript as it does use an interpreter written in Javascript for security reasons. (Basically, authors should not be able to break out of EOS limited functionality and maybe even access other user data like the milovana password or interact with the site in different ways. So let is not supported, this should be, why it does not work.
- The difference between let is: var is scoped to the surrounding function, let is scoped to the block. If used top-leven in the global script, they should both declare global variables. So it would work, if it was supported.