Page 1 of 1
[EOS/Code]
Posted: Thu Dec 05, 2024 2:21 pm
by kneeling_gentleman
Hello.
To my understanding EOS uses a subset of javascript.
Is there a reference of available structures / functions, and most importantly a way to see the debug? I tried using a class to store variables but the code seems to break, and I'm lost since I don't see any error message or log.
Thanks
Re: [EOS/Code]
Posted: Fri Dec 06, 2024 2:55 am
by Zer0_0reZ
Yes EOS uses a subset of java-script, specifically of ECMAScript 5 (classes are ES6)
I don't think there is a list of what features are available but there is an
api reference for all the extra things EOS adds.
To debug you can use console.log (or .info, .error, .warn).
These write into the DevTools Console (opened with Ctrl+Shift+I or F12 or right-click & inspect(Q)).
Any error messages should also appear there.
Alternatively many other Creators use a Say-Action in a IF-Action and a variable 'debug'.
After doing some testing here is what's available:
- Spoiler: show
- keywords:
if, else,
while, do, for, break, continue,
function, return,
switch, case, default,
throw, try, catch, finally,
new, delete, void, this,
in,
typeof, instanceof,
true, false, null, NaN, Infinity
Types:
Function, Object, Array, String, Boolean, Number, Date, RegExp (+ some types of Errors)
helper functions:
eval,
parseInt, parseFloat, isNaN, isFinite,
escape, unescape, decodeURI, decodeURIComponent, encodeURI, encodeURIComponent
Objects
Math, JSON, console,
pages, Sound, Notification, teaseStorage, EventTarget
need to be enabled instance must to be obtained with .get instance must be created with new
if you want to use something like classes just use objects:
- Spoiler: show
Code: Select all
var player = {
name:"PLAYER",
age:23,
greet:function (greeting){console.log(greeting, this.name)}
}
if(player.age > 20){
player.greet("Hello")
}
Re: [EOS/Code]
Posted: Fri Dec 06, 2024 10:07 pm
by kneeling_gentleman
Perfect, pretty much all I needed, thanks!
Re: [EOS/Code]
Posted: Fri Dec 06, 2024 11:02 pm
by kneeling_gentleman
One more question, is there any way to write the actual code somewhere instead of using the graphic interface?
Or, alternatively, to programmatically invoke the commands through the "eval" prompt (in which case, is there a reference on how to call the various commands like "say", etc and their parameters)?
Re: [EOS/Code]
Posted: Sat Dec 07, 2024 9:58 pm
by PlayfulGuy
kneeling_gentleman wrote: Fri Dec 06, 2024 11:02 pm
One more question, is there any way to write the actual code somewhere instead of using the graphic interface?
Or, alternatively, to programmatically invoke the commands through the "eval" prompt (in which case, is there a reference on how to call the various commands like "say", etc and their parameters)?
The answer to your question is sort of, but not really.
The
API reference shows you what EOS specific functions are usable in javascript.
The basic commands like Say, Image etc can't be used in javascript, but if you understand the structure of JSON files you can export a tease or partial tease (see Backup in the EOS editor menu), edit and add to it in a text editor, then import the updated json (through Restore). It's a handy way to duplicate a page a bunch of times, then make minor changes to the pages, but it's very easy to miss a comma or other punctuation that prevents you from importing it, until you figure out what's missing and fix it.
PG
Re: [EOS/Code]
Posted: Mon Dec 09, 2024 6:55 pm
by kneeling_gentleman
Alright, thanks!