jcubic / gaiman Goto Github PK
View Code? Open in Web Editor NEWGaiman: Text based game engine and programming language
Home Page: https://gaiman.js.org
License: GNU General Public License v3.0
Gaiman: Text based game engine and programming language
Home Page: https://gaiman.js.org
License: GNU General Public License v3.0
Dictionaries should be created using Map
or {}
decided on runtime which is supported.
let dict_1 = {}
let dict_2 = {
"ten" => 10,
"twenty" => 20
}
// access Adapter
function access(object, arg, ...rest) {
let first;
if (object instanceof Map) {
first = object.get(arg);
} else {
first = object[arg];
}
return access(firt, ...rest);
}
mapping:
location.href.baz
==> access(location, 'href', 'baz')
location.replace("about:blank")
=> access(location, 'repalce')('about:blank')
.location.href = "about:blank"
==> location.href = "about:blank"
foo.bar.baz = 10
=> set(foo, 'bar', 'baz', 10)
.function set(object, ...rest) {
let result = object;
while (rest.length > 2) {
const prop = rest.shift();
if (object instanceof Map) {
object = object.get(prop);
} else {
object = object[prop]
}
}
const prop = rest.shift();
const value = rest.shift();
if (object instanceof Map) {
object.set(prop, value);
} else {
object[prop] = value;
}
}
let x = {
"foo" => 10
}
let y = {
"bar" => 20
}
let z = {}
z[x] = "hello"
z[y] = "world"
z[x] + ", " + z[y]
# hello, world
for key, value in {"hello" => 10, "world" => 20} do
echo "$key => $value"
end
Add way to customize output html with custom CSS.
Allow to add:
:root {
--color: black;
--background: white;
}
Consider adding tab with custom style, with default colors, that User can change. Similar to config files on Linux.
Add to Wiki or Readme.
Include XML formatting and add video-tag support.
There should be easy way to translate the output game. Maybe add gettext support.
It may require adding modules.
import "i18n"
import "gettext"
and use:
echo _("Welcome to Gaiman game")
Create an interesting example that will showcase the library.
It should:
Add syntax:
let list = {
hello => lambda()
echo "HELLO FROM LAMBDA"
end
}
list["hello"]()
This is important if "hello" is variable:
let cmd = ask "? "
if type list[cmd] == "function" then
list[cmd]()
end
The command will modify existing line by index.
Parse string from ask
into array of arguments. Possible parse
and parse*
.
Allow forking the code like on CodePen.
do
as opening tokenThere should be a way to call:
let factorial = eval(<<<CODE
(function(n) {
return Array.from({length: n}, (_, i) => i + 1).reduce((a,b) => a * b, 1);
})
CODE)
this works:
let code = <<<CODE
(function(n) {
return Array.from({length: n}, (_, i) => i + 1).reduce((a,b) => a * b, 1);
})
CODE
let factorial = eval(code)
Allow to use floating point numbers in code.
let x = 10
while x > 0 do
echo "NUM: $x"
x = x - 1
end
Travis need to go.
let x = 0
while true do
x = x + 1
if x > 10 then
break
end
echo x
end
for i in [1, 2, 3, 4, 5, 6, 7] do
if i % 2 == 0 then
continue
end
echo x
end
function calls should return Thunk that should be resolved with the trampoline so you will be able to create real infinite loops. This is important for cases like inn demo:
def ask_color()
echo "Pick color?"
let color = ask "color? "
if color ~= /red/i then
echo "I like red, it remiding me of sun at sunset"
else if color ~= /blue/i then
echo "I like blue, it remind me of sky"
else if color ~= /black/i then
echo "I like black it remind me of the darkest night"
else
echo "sorry I only know red, blue and black colors"
end
echo "Do you want to check another color?"
let confirm = ask "yes/no? "
if confirm ~= /yes/i then
ask_color() # here recursive call should be returned in a thunk
else
echo "Ok, have a nice day"
end
end
There will be no standard for C loop. So to interate over numbers there is need to have range function from Python.
"foo".split("")
"foo".match(/fo{2}/)
After updating Array::map
and Array::filter
there is need to make reduce work with async functions.
Add support for:
for item in iterator do
echo* item
end
Make a better homepage that will show the features of the language that showcase examples (saved in Firebase).
echo "${await gaiman.ask('? ')}"
This is valid and it's interpreted by gaiman, and it's executed. This is potential XSS.
Reported upstream estools/escodegen#448
Use code from P5.
I would be easier to refresh the iframe and rerun the terminal. Right now you need to update something in the code (e.g. add and remove space).
You should be able to check if something is
Best if it's command type
that return type but it's not typeof
that is not infinitive.
Add more examples to the playground.
<dropdown>
jQuery detect mime type of the response and return XML root element, Object or string. THe function do the right thing. It will simplify things, if get
and post
just return Object if the response is JSON.
some()
sort()
flatMap()
find()
every()
forEach()
The js code can add terminal to #term
and there can be different themes that user can pick.
Vintage, Forest, Dracula, etc.
There also should be a way to pick window version. There can be modules that will be combined into one CSS and HTML.
There should be a way to run exec and play the game without interaction.
Either as animation or as unit tests.
Splat should be compiled to rest operator
def sum(*args)
let result = 0
for i in args
result += i
end
return result
end
Using current syntax. It should be able to use array.map
in the future.
This doesn't work:
echo "<white>" + (ask "? ") + "</white>"
it should parse command inside parentheses as part of expression.
The same
echo* (get "https://jcubic.pl/file.txt"), 100
This may be the same kind of expression
Allow playing sound and music.
For better SEO there should be h1 that that's always visible. Gaiman Logo with alt text.
Maybe move config section into navbar.
Doesn't work:
input "hello"
part of "in" keyword
def define()
end
define part of def
keyword
Whole keyword check need to be refactored. Probably using assertion to test if the final name is a keyword.
Based on code from P5, but in JavaScript.
Those will be special case of get and post that will get output as text even if the response is JSON or XML.
After #18 and #26 are done. There should be documentation link that will open "in page browser", like at JavaScript REPL with Wiki page.
There should be some kind of guard jus for playground, that will stop long running loops.
Just made mistake and wrote:
let x = 10
while x > 0 do
echo "NUM: $x"
x = x + 1 # there should be minus here
end
and it frozen the browser.
Create dist directory with a file that can be used in the browser (for the playground).
[1, 0, 2, 3, 0, 4].map(square).filter(identity)
arr.map(square).filter(identity)
let sum = lambda(a, b)
return a + b
end
There should be CSS/Gaiman combo on the GitHub pages and it should load the code from URL.
https://gaiman.js.org/?css=matrix.css&gaiman=hello.gs
css files should be in examples/css
and should load the files. URL should take precedence over IndexedDB.
location.replace("htttp://jcubic.pl")
Add a way to set completion. Came up with a nice API.
Maybe:
completion ["foo", "bar", "baz"]
let commands = ["foo", "bar", "baz"]
completion lambda(string)
return commands
end
The output HTML should use ES Modules with code as-is and files compiled to ES5 for old browsers.
The goal is to make the game work in IE11. Not many people use it, but some other browsers may not support all the features, like old smartphones. There will be not that much work to support IE11, since jQuery Terminal works in IE11.
<script type="module"
in htmlIt would be nice to have a code editor on one side and a game on the other.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.