Understanding DungeonScript

THINGS AND CHARMS

"Everything is a thing with charms"

In the world of DungeonScript, most things are called things. And each things can have charms. But note that only charms have names, where things do not. Things are more like mere collections of charms.

A thing may look like this:

{ weapon, short-sword, damage: 10, price: 80 }

Charms may or may not have value. Charms without value can be used to tag a thing, or even name the thing if the name of the charm is unique.


QUERYING AND MANIPULATING DATA

Since things do not have any name, you cannot simply pick one to manipulate it. Instead, you can query things to retrieve and manipulate things.

weapon, damage>5 { .rusted, .price: 0 }

Here we find every thing that is tagged as a weapon, and has a damage charm greater than 5. Then, tag those things as rusted, and make the price into 0. Note that with those dots at the head of charms, we can explicitly say that those charms belong to what we retrieved via query.

Ready, set, run!

Code of DungeonScript is divided into three sections: ready, set, and run.

In ready section, you can set or override meta data of a game, like title, author, or tick time.

Set section is for making things. Create every thing before make use of them in the next section.

Run section is for querying and manipulating things. Every game-game coding can sit here. The game executes queries line by line, sequencially, every tick.

DungeonScript Grammar

Use curly braces, have some charms separated by comma. Use colon to make charms have values.

{ equipment, weapon, dagger, damage: 8 }
{ equipment, armor, leather-armor, defense: 2 }


Charms can refer other thing, but it only refers to the first thing comes out of query.

{ player, order: 0, weapon: @dagger, armor: @leather-armor }


Every comma can be replaced by line break. Of course it's totally okay to use both.

{ monster
  goblin
  hp: 20,
  hp-max: 20 }


SIMPLE CHARMING

Write query conditions seperated by comma, then start curly block to access to query results. What is inside block is executed for every result.

Dot prefix means 'local', which explicitly indicates that the charm belongs to the thing that is being dealt with now. You can freely add and manipulate charms, and also can remove charms with remove token.

player, hp <= 0 {
  .hp: 0,
  .dead,
  .awesomeness: remove
}


PROMISED CHARMING

Sometimes, you want to change things without affecting other queries executing later on the same tick. Unlike simple charming that all the changes take place right away, there is a concept called promised charming, which also makes changes on things, but not right away.

After writing down query conditions, add <~ before opening curly braces. By doing this, any change that you make inside the curly braces will happen on start of next tick.

player, regeneration <~ { .hp: .hp-max }

Here, jesus repeats to be dead and not to be dead every tick.

jesus, !dead { jesus <~ { .dead } }
jesus, dead  { jesus <~ { .dead: remove } }

NESTED CHARMINGS

Any type of charmings can be nested. Other than . prefix, there also is ~ prefix to refer to one step upper thing.

player, hp <= 0 {
  .hp: 0,
  .dead,
  enemy, now-in-battle, hp>0 {
    .awesomeness: ~awesomeness,
  }
  gamephase <~ { .gamephase: 'gameover' }
}

Grammar for meta data is basically same as thing definition, without curly braces. There is a premade default meta data regardless of your code, and if you code something for meta data, you're overriding the data. So it's okay not to code anything, or if you omit something.

title: "Awesome Dungeon"
author: "Lord Awesomania"
tick: 300

If you want to do some math for values of a charm, you need to use parentheses and white spaces strictly. Any mathematical expression should be inside parentheses, and white spaces are required to seperate each values and operators.

moving-text, y<0.8 { .y: (.y + 0.01) }

Built-in Behaviors

DOCUMENTATION NOT READY   But it is very probable that the functionality is there. Look for sample code on coding page!
DOCUMENTATION NOT READY   But it is very probable that the functionality is there. Look for sample code on coding page!
DOCUMENTATION NOT READY   But it is very probable that the functionality is there. Look for sample code on coding page!
DOCUMENTATION NOT READY   But it is very probable that the functionality is there. Look for sample code on coding page!
DOCUMENTATION NOT READY   But it is very probable that the functionality is there. Look for sample code on coding page!
Start coding!