GitHub - jcubic/gaiman: Gaiman: Text based game engine and programming language
source link: https://github.com/jcubic/gaiman
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Gaiman Engine and Programming Language
Gaiman: Storytelling Text Based Game Engine and Programming Language
Main part of Gaiman is a minimalist, Ruby inspired, programming language. The main purpose of it is to help creating Text Adventure Games. But it can also be used to create any interactive CLI applications (Web Based Terminal applications). It supports browser based CLI applications and in the future also native command line.
Installation
npm install -g gaiman@beta
Usage
gaiman -o directory input.gs
This will compile your source file and generate dir/index.html
and dir/index.js
files.
And you can open generated html file in browser and run the game.
Documentation
Examples
This is Hello world Gaiman DSL example:
echo get "https://gaiman.js.org/gaiman.txt"
echo* "Hi, What is your name?", 50 # Typing animation with 50ms delay
let name = ask "name? "
echo "Hello $name, nice to meet you."
More advanced example:
if cookie.visited then
if cookie.user then
let user = cookie.user
echo "Hello $user, welcome back"
else
ask_details("Welcome back stranger")
end
else
cookie.visited = true
ask_details("Welcome stranger")
end
def ask_details(msg)
echo msg
echo "Do you want me to contact you with updates?"
let confirm = ask "yes/no: ", lambda(answer)
return answer =~ /^(y|yes|n|no)$/i
end
if confirm =~ /y|yes/i then
echo "what is your name?"
let name = ask "name: ", lambda(name)
let valid = name != ""
if not valid then
echo "You need to type something"
end
return valid
end
cookie.user = name
let email = ask "email: ", lambda(email)
let valid = email =~ /^.+@.+\..+$/
if not valid then
echo "wrong email"
end
return valid
end
cookie.email = email
let response = post "/register", { "name" => name, "email" => email }
if response then
echo "Welcome $user. You're successfully registered"
end
else
echo "Ok, as you wish. Bye"
end
end
More examples in examples directory
See Reference Manual for details about the features
Live Demo
See Gaiman language Playground
Live Edit of Gaiman Code:
Live edit of style
Roadmap
See Wiki TODO & Roadmap.
Name and Origin
Name came from Neil Gaiman, Author of novels, comic books, graphic novels and films. Great storyteller.
You can read about the origin of the language in the beginning of the article:
Acknowledge
Logo use:
License
Released under GNU GPL v3 or later
Copyright (c) 2021-2022 Jakub T. Jankiewicz
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK