Git Product home page Git Product logo

zorkscript's Introduction

ZorkScript

An esoteric scripting language based on text-based game commands.

Notes

Some notes via the conversation topic in our Slack channel:

Commands

Some basic command aliases:

  • print "string" -> say "string"
  • new String() -> craft String named $var
  • $var = "value" -> put "value" in $var

Arrays

If arrays are treated like all other standard object types (Int, String, etc.), then creating an array would look something like this:

craft Array named $array
craft String named $string

put "test" in $string
put $string in $array

With this structure, the same concept could be applied to create multidimentional arrays:

craft Array named $array1
craft Array named $array2

put $array1 in $array2

Functions

In ZorkScript, functions are structured like "spells." For example, the following pseudocode:

function echo($string) {
  print($string);
}

Would look like this in ZorkScript:

spell Echo
  component $string
  say "#{$string}"

Execution

Calling a function is accomplished using the cast command, like so:

cast Echo with "Hi!"

Classes

Classes follow a similar structure, but are structured like physical objects. For example:

class Point {
  private $x;
  private $y;
  
  public function Echo() {
    print("$x, $y");
  }
}

Would be structured like this:

blueprint Point
  component $x
  component $y
  
  casts Echo with "#{$x}, #{$y}"

Function definitions are generally global, however they can be localized within an object similarly to how the Go programming language handles object orientation.

Instantiation

Instantiating a class can be accomplished using the craft command, like so:

craft Point with 1 and 1 named $point

This would instantiate the Point class defined above, using 1 and 1 for $x and $y respectively, and assign it to the $point variable.

As a note, an interpreter might tokenize that command like this:

Token(Keyword) "craft"
Token(Identifier) "Point"
Token(ArgList) "with"
    Token(Number) 1
    Token(Seperator) "and"
    Token(Number) 1
Token(Keyword) "named"
Token(VarIdentifier) "$point"

Instance Methods

Instance methods are called similarly to how global methods are called:

cast Echo using $point

As you can see, the Echo method is called, but within the context of the $point class.

Dependencies

Dependencies can be imported using the summon command:

summon utilities

zorkscript's People

Contributors

zachflower avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.