-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
manual: working on command design (#34)
* add a few commands * update some commands * add ITEM_PARSE
- Loading branch information
1 parent
630153d
commit 931516f
Showing
14 changed files
with
3,252 additions
and
2 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Item specifier: | ||
|
||
``` | ||
ItemListForAdd -> NumberedItem+ | ||
ItemListForRemove -> AllableItem+ | ||
ItemListForArea -> InfableItem+ | ||
NumberedItem -> NUMBER Item | ||
InfableItem -> NumOrInf Item | ||
AllableItem -> NumOrAll Item | ||
NumOrInf -> NUMBER | "infinite" | ||
NumOrAll -> NUMBER | "all" | ||
Item -> ItemName ItemMeta? | ||
ItemMeta -> [ ItemMetaEntry (OpComma ItemMetaEntry)* ] | ||
ItemMetaEntry -> ItemMetaKey (OpAssign ItemMetaValue)? | ||
ItemMetaKey -> WORD | ||
ItemMetaValue -> WORD | NUMBER | BOOL | ||
ItemName -> WORD+ | < WORD > | ||
ItemSlot -> ( OpSlotSpec "slot" NUMBER ) | ||
OpSlotSpec -> "from" | "in" | "to" | ||
OpAssign -> = | : | ||
OpComma -> , | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
# Summary | ||
|
||
- [Chapter 1](./chapter_1.md) | ||
- [Scopes](./scope.md) | ||
- [Game Scope]() | ||
- [Inventory Scope]() | ||
- [Dialog Scope]() | ||
- [Actions](./action.md) | ||
- [`get`](./action/get.md) | ||
- [Commands]() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Actions | ||
|
||
Actions map to actions you can do in the game |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Get | ||
|
||
## Syntax | ||
``` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,50 @@ | ||
# Chapter 1 | ||
|
||
This is a placeholder... | ||
Test 2 3 4 5 6 7 8 9 10 | ||
|
||
```rust | ||
fn main() { | ||
println!("Hello, World!"); | ||
} | ||
``` | ||
|
||
```admonish info | ||
Test | ||
``` | ||
|
||
```admonish note | ||
Test | ||
``` | ||
|
||
```admonish warning | ||
Test | ||
``` | ||
|
||
```admonish danger | ||
Test | ||
``` | ||
|
||
```admonish tip | ||
Test | ||
``` | ||
|
||
```admonish important | ||
Test | ||
``` | ||
|
||
```admonish caution | ||
Test | ||
``` | ||
|
||
```admonish error | ||
Test | ||
``` | ||
|
||
```admonish hint | ||
Test | ||
``` | ||
|
||
```admonish attention | ||
Test | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# Scopes | ||
|
||
Scope is a concept that the simulator runtime uses to enforce | ||
the validity of the setup, and automatically update | ||
different parts of the simulation. For example: | ||
|
||
- You cannot use an item while talking to a NPC | ||
- GDT Inventory is synced when closing inventory | ||
- If the game crashes, you can't do anything until you restart it | ||
|
||
Currently, there are three scopes in the simulator: | ||
- Game Scope: The game is running, and the player has control of Link | ||
- Inventory Scope: The player is looking at the inventory (pressed `+`) | ||
- Dialog Scope: The player doesn't have control of Link (for example, talking to an NPC) | ||
|
||
## Automatic Scope Management | ||
For the most part, scopes are managed automatically by the simulator runtime | ||
based on the command, so you don't have to worry about them. | ||
|
||
For example, | ||
consider the following script | ||
|
||
``` | ||
get 1 apple | ||
eat 1 apple | ||
get 1 wood | ||
``` | ||
|
||
At first, the simulation state is not in any scope. | ||
To get an item, you must have control of Link, so the `get` action requires `game, !paused` scope, so the simulator automatically | ||
activate the `game` scope by starting a new game. | ||
|
||
The next `eat` action requires `game, inventory` scope because you need | ||
to be in the inventory to eat an item. The simulator infers | ||
that you want to pause the game to eat the item, so it automatically | ||
activates the `inventory` scope. | ||
|
||
Finally, the last `get` action requires the game to be not paused, | ||
so the simulator automatically deactivates the `inventory` scope to allow | ||
the action to be performed. | ||
|
||
## Manual Scope Management | ||
Certain actions like `pause` can be used to change the scope manually. | ||
When the scope is activated manually, the simulator will not automatically | ||
change the scope until the manual scope is deactivated. | ||
|
||
For example, consider the following script, which is the same as above except | ||
that it manually pauses the game before `eat` | ||
``` | ||
get 1 apple | ||
pause | ||
eat 1 apple | ||
get 1 wood # Error! | ||
``` | ||
|
||
Now the simulator will not automatically deactivate the `inventory` scope | ||
for `get 1 wood`. Instead, it will give an error saying you cannot get new | ||
item while paused. | ||
|
||
## Scope Conflict | ||
Another error that the scope system checks for is conflicting scopes. | ||
For example, you cannot access inventory while talking to an NPC. | ||
This is implemented by you cannot activate `inventory` scope | ||
while the `dialog` scope is active. | ||
|
||
The following script is valid: | ||
``` | ||
sell 1 apple | ||
eat 1 apple | ||
``` | ||
Here, `sell` activates the `dialog` scope, and `eat` deactivates it to | ||
activate the `inventory` scope. | ||
|
||
However, if you manually activate the `inventory` scope before `sell`, | ||
you will have an error because the `dialog` scope cannot be automatically | ||
activated while `inventory` scope is in use. | ||
|
||
``` | ||
talk-to shopkeeper | ||
sell 1 apple | ||
eat 1 apple # Error! | ||
``` | ||
|
||
## Crashes | ||
Most commands require the `game` scope, which can be automatically activated. | ||
The only exception is when the game crashes. In this case, you must | ||
manually activate the `game` scope with an action like `new-game` or `reload` | ||
|
||
## Testing | ||
Scope can be tested using the `!assert-scope` command. The special `not-paused` | ||
keyword can be used to test that `game` is the top-level scope | ||
|
||
``` | ||
!assert-scope game | ||
!assert-scope inventory | ||
!assert-scope game not-paused | ||
``` |
Oops, something went wrong.