redscript-mc 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.yml +72 -0
  2. package/.github/ISSUE_TEMPLATE/feature_request.yml +57 -0
  3. package/.github/PULL_REQUEST_TEMPLATE.md +17 -25
  4. package/CHANGELOG.md +112 -0
  5. package/CONTRIBUTING.md +140 -0
  6. package/README.md +28 -19
  7. package/README.zh.md +28 -19
  8. package/dist/__tests__/cli.test.js +148 -10
  9. package/dist/__tests__/codegen.test.js +26 -1
  10. package/dist/__tests__/diagnostics.test.js +5 -5
  11. package/dist/__tests__/e2e.test.js +336 -17
  12. package/dist/__tests__/formatter.test.d.ts +1 -0
  13. package/dist/__tests__/formatter.test.js +40 -0
  14. package/dist/__tests__/lexer.test.js +12 -2
  15. package/dist/__tests__/lowering.test.js +200 -12
  16. package/dist/__tests__/mc-integration.test.js +370 -31
  17. package/dist/__tests__/mc-syntax.test.js +3 -3
  18. package/dist/__tests__/nbt.test.js +2 -2
  19. package/dist/__tests__/optimizer-advanced.test.js +5 -5
  20. package/dist/__tests__/parser.test.js +80 -0
  21. package/dist/__tests__/runtime.test.js +9 -9
  22. package/dist/__tests__/typechecker.test.js +158 -0
  23. package/dist/ast/types.d.ts +40 -3
  24. package/dist/cli.js +25 -7
  25. package/dist/codegen/mcfunction/index.d.ts +1 -1
  26. package/dist/codegen/mcfunction/index.js +38 -3
  27. package/dist/codegen/structure/index.js +32 -1
  28. package/dist/compile.d.ts +10 -0
  29. package/dist/compile.js +36 -5
  30. package/dist/events/types.d.ts +35 -0
  31. package/dist/events/types.js +59 -0
  32. package/dist/formatter/index.d.ts +1 -0
  33. package/dist/formatter/index.js +26 -0
  34. package/dist/index.js +3 -2
  35. package/dist/ir/builder.d.ts +2 -1
  36. package/dist/ir/types.d.ts +11 -2
  37. package/dist/ir/types.js +1 -1
  38. package/dist/lexer/index.d.ts +1 -1
  39. package/dist/lexer/index.js +2 -0
  40. package/dist/lowering/index.d.ts +34 -1
  41. package/dist/lowering/index.js +622 -23
  42. package/dist/mc-test/runner.d.ts +2 -2
  43. package/dist/mc-test/runner.js +3 -3
  44. package/dist/mc-test/setup.js +2 -2
  45. package/dist/parser/index.d.ts +4 -0
  46. package/dist/parser/index.js +153 -16
  47. package/dist/typechecker/index.d.ts +17 -0
  48. package/dist/typechecker/index.js +343 -17
  49. package/docs/COMPILATION_STATS.md +24 -24
  50. package/docs/ENTITY_TYPE_SYSTEM.md +242 -0
  51. package/docs/IMPLEMENTATION_GUIDE.md +1 -1
  52. package/docs/STRUCTURE_TARGET.md +1 -1
  53. package/editors/vscode/.vscodeignore +1 -0
  54. package/editors/vscode/CHANGELOG.md +9 -0
  55. package/editors/vscode/icons/mcrs.svg +7 -0
  56. package/editors/vscode/icons/redscript-icons.json +10 -0
  57. package/editors/vscode/out/extension.js +1295 -80
  58. package/editors/vscode/package-lock.json +2 -2
  59. package/editors/vscode/package.json +10 -3
  60. package/editors/vscode/src/hover.ts +55 -2
  61. package/editors/vscode/src/symbols.ts +42 -0
  62. package/package.json +1 -1
  63. package/src/__tests__/cli.test.ts +176 -10
  64. package/src/__tests__/codegen.test.ts +28 -1
  65. package/src/__tests__/diagnostics.test.ts +5 -5
  66. package/src/__tests__/e2e.test.ts +335 -17
  67. package/src/__tests__/fixtures/event-test.mcrs +13 -0
  68. package/src/__tests__/fixtures/impl-test.mcrs +46 -0
  69. package/src/__tests__/fixtures/interval-test.mcrs +11 -0
  70. package/src/__tests__/fixtures/is-check-test.mcrs +20 -0
  71. package/src/__tests__/fixtures/timeout-test.mcrs +7 -0
  72. package/src/__tests__/lexer.test.ts +14 -2
  73. package/src/__tests__/lowering.test.ts +226 -12
  74. package/src/__tests__/mc-integration.test.ts +421 -31
  75. package/src/__tests__/mc-syntax.test.ts +3 -3
  76. package/src/__tests__/nbt.test.ts +2 -2
  77. package/src/__tests__/optimizer-advanced.test.ts +5 -5
  78. package/src/__tests__/parser.test.ts +91 -5
  79. package/src/__tests__/runtime.test.ts +9 -9
  80. package/src/__tests__/typechecker.test.ts +171 -0
  81. package/src/ast/types.ts +44 -3
  82. package/src/cli.ts +10 -10
  83. package/src/codegen/mcfunction/index.ts +40 -3
  84. package/src/codegen/structure/index.ts +35 -1
  85. package/src/compile.ts +54 -6
  86. package/src/events/types.ts +69 -0
  87. package/src/examples/capture_the_flag.mcrs +208 -0
  88. package/src/examples/{counter.rs → counter.mcrs} +1 -1
  89. package/src/examples/hunger_games.mcrs +301 -0
  90. package/src/examples/new_features_demo.mcrs +193 -0
  91. package/src/examples/parkour_race.mcrs +233 -0
  92. package/src/examples/rpg.mcrs +13 -0
  93. package/src/examples/{shop.rs → shop.mcrs} +1 -1
  94. package/src/examples/{showcase_game.rs → showcase_game.mcrs} +3 -3
  95. package/src/examples/{turret.rs → turret.mcrs} +1 -1
  96. package/src/examples/zombie_survival.mcrs +314 -0
  97. package/src/index.ts +4 -3
  98. package/src/ir/builder.ts +3 -1
  99. package/src/ir/types.ts +12 -2
  100. package/src/lexer/index.ts +3 -1
  101. package/src/lowering/index.ts +684 -24
  102. package/src/mc-test/runner.ts +3 -3
  103. package/src/mc-test/setup.ts +2 -2
  104. package/src/parser/index.ts +170 -19
  105. package/src/stdlib/README.md +178 -140
  106. package/src/stdlib/bossbar.mcrs +68 -0
  107. package/src/stdlib/{cooldown.rs → cooldown.mcrs} +1 -1
  108. package/src/stdlib/effects.mcrs +64 -0
  109. package/src/stdlib/interactions.mcrs +195 -0
  110. package/src/stdlib/inventory.mcrs +38 -0
  111. package/src/stdlib/mobs.mcrs +99 -0
  112. package/src/stdlib/particles.mcrs +52 -0
  113. package/src/stdlib/sets.mcrs +20 -0
  114. package/src/stdlib/spawn.mcrs +41 -0
  115. package/src/stdlib/tags.mcrs +951 -0
  116. package/src/stdlib/teams.mcrs +68 -0
  117. package/src/stdlib/timer.mcrs +72 -0
  118. package/src/stdlib/world.mcrs +92 -0
  119. package/src/typechecker/index.ts +404 -18
  120. package/src/examples/rpg.rs +0 -13
  121. package/src/stdlib/mobs.rs +0 -99
  122. package/src/stdlib/timer.rs +0 -51
  123. /package/src/examples/{arena.rs → arena.mcrs} +0 -0
  124. /package/src/examples/{pvp_arena.rs → pvp_arena.mcrs} +0 -0
  125. /package/src/examples/{quiz.rs → quiz.mcrs} +0 -0
  126. /package/src/examples/{stdlib_demo.rs → stdlib_demo.mcrs} +0 -0
  127. /package/src/examples/{world_manager.rs → world_manager.mcrs} +0 -0
  128. /package/src/stdlib/{combat.rs → combat.mcrs} +0 -0
  129. /package/src/stdlib/{math.rs → math.mcrs} +0 -0
  130. /package/src/stdlib/{player.rs → player.mcrs} +0 -0
  131. /package/src/stdlib/{strings.rs → strings.mcrs} +0 -0
  132. /package/src/templates/{combat.rs → combat.mcrs} +0 -0
  133. /package/src/templates/{economy.rs → economy.mcrs} +0 -0
  134. /package/src/templates/{mini-game-framework.rs → mini-game-framework.mcrs} +0 -0
  135. /package/src/templates/{quest.rs → quest.mcrs} +0 -0
  136. /package/src/test_programs/{zombie_game.rs → zombie_game.mcrs} +0 -0
@@ -0,0 +1,72 @@
1
+ name: 🐛 Bug Report
2
+ description: Report a bug in RedScript
3
+ labels: ["bug"]
4
+ body:
5
+ - type: markdown
6
+ attributes:
7
+ value: |
8
+ Thanks for reporting a bug! Please fill out the sections below.
9
+
10
+ - type: textarea
11
+ id: description
12
+ attributes:
13
+ label: Description
14
+ description: What happened?
15
+ placeholder: A clear description of the bug
16
+ validations:
17
+ required: true
18
+
19
+ - type: textarea
20
+ id: reproduction
21
+ attributes:
22
+ label: Code to Reproduce
23
+ description: Minimal RedScript code that triggers the bug
24
+ render: rust
25
+ placeholder: |
26
+ fn example() {
27
+ // your code here
28
+ }
29
+ validations:
30
+ required: true
31
+
32
+ - type: textarea
33
+ id: expected
34
+ attributes:
35
+ label: Expected Behavior
36
+ description: What should have happened?
37
+ validations:
38
+ required: true
39
+
40
+ - type: textarea
41
+ id: actual
42
+ attributes:
43
+ label: Actual Behavior
44
+ description: What actually happened?
45
+ validations:
46
+ required: true
47
+
48
+ - type: input
49
+ id: version
50
+ attributes:
51
+ label: RedScript Version
52
+ description: Run `redscript --version`
53
+ placeholder: "1.0.0"
54
+ validations:
55
+ required: true
56
+
57
+ - type: dropdown
58
+ id: os
59
+ attributes:
60
+ label: Operating System
61
+ options:
62
+ - macOS
63
+ - Windows
64
+ - Linux
65
+ validations:
66
+ required: true
67
+
68
+ - type: textarea
69
+ id: context
70
+ attributes:
71
+ label: Additional Context
72
+ description: Any other relevant information (error messages, stack traces, etc.)
@@ -0,0 +1,57 @@
1
+ name: ✨ Feature Request
2
+ description: Suggest a new feature for RedScript
3
+ labels: ["enhancement"]
4
+ body:
5
+ - type: markdown
6
+ attributes:
7
+ value: |
8
+ Thanks for your feature idea! Please describe it below.
9
+
10
+ - type: textarea
11
+ id: problem
12
+ attributes:
13
+ label: Problem
14
+ description: What problem does this feature solve?
15
+ placeholder: I'm always frustrated when...
16
+ validations:
17
+ required: true
18
+
19
+ - type: textarea
20
+ id: solution
21
+ attributes:
22
+ label: Proposed Solution
23
+ description: How would you like RedScript to solve this?
24
+ placeholder: |
25
+ I'd like a syntax like:
26
+ ```rs
27
+ // example code
28
+ ```
29
+ validations:
30
+ required: true
31
+
32
+ - type: textarea
33
+ id: alternatives
34
+ attributes:
35
+ label: Alternatives Considered
36
+ description: Any alternative solutions or workarounds you've considered?
37
+
38
+ - type: dropdown
39
+ id: category
40
+ attributes:
41
+ label: Category
42
+ options:
43
+ - Language Feature
44
+ - Builtin Function
45
+ - Standard Library
46
+ - CLI / Tooling
47
+ - VSCode Extension
48
+ - Documentation
49
+ - Other
50
+ validations:
51
+ required: true
52
+
53
+ - type: textarea
54
+ id: context
55
+ attributes:
56
+ label: Additional Context
57
+ description: Any other context, examples, or screenshots
@@ -1,34 +1,26 @@
1
- ## What does this PR do?
1
+ ## Description
2
2
 
3
- <!-- Brief description -->
3
+ <!-- What does this PR do? -->
4
4
 
5
- ## Type of change
5
+ ## Type of Change
6
6
 
7
- - [ ] Bug fix
8
- - [ ] New language feature
9
- - [ ] New builtin / stdlib
10
- - [ ] Optimizer improvement
11
- - [ ] Tooling / CLI
12
- - [ ] Docs
7
+ - [ ] 🐛 Bug fix
8
+ - [ ] New feature
9
+ - [ ] 📝 Documentation
10
+ - [ ] ♻️ Refactor
11
+ - [ ] 🧪 Tests
13
12
 
14
- ## Checklist
15
-
16
- - [ ] `npm run build` passes
17
- - [ ] `npm test` passes (all existing tests green)
18
- - [ ] New tests added for new behavior
19
- - [ ] If adding a builtin: added to `docs/LANGUAGE_REFERENCE.md` and wiki Builtins page
20
- - [ ] If changing syntax: updated `docs/LANGUAGE_REFERENCE.md`
13
+ ## Related Issues
21
14
 
22
- ## Test coverage
15
+ <!-- Link related issues: Fixes #123 -->
23
16
 
24
- <!-- Which test file(s) cover this change? -->
17
+ ## Checklist
25
18
 
26
- ## Example
19
+ - [ ] `npm run build` passes
20
+ - [ ] `npm test` passes
21
+ - [ ] Tests added for new features
22
+ - [ ] Documentation updated (if applicable)
27
23
 
28
- ```rs
29
- // Show a RedScript snippet demonstrating the new feature
30
- ```
24
+ ## Screenshots / Examples
31
25
 
32
- ```mcfunction
33
- # Show the expected compiled output
34
- ```
26
+ <!-- If applicable, show before/after or example output -->
package/CHANGELOG.md ADDED
@@ -0,0 +1,112 @@
1
+ # Changelog
2
+
3
+ All notable changes to RedScript will be documented in this file.
4
+
5
+ ## [1.2.0] - 2026-03-12
6
+
7
+ ### Added
8
+ - `is` type narrowing for entity checks (`if (e is Player)`)
9
+ - `impl` blocks for struct methods
10
+ - Static method calls (`Type::method()`)
11
+ - Timer OOP API in stdlib
12
+ - `setTimeout(delay, callback)` builtin
13
+ - `setInterval(delay, callback)` builtin
14
+ - `clearInterval(id)` builtin
15
+ - `@on(Event)` static event system
16
+ - PlayerDeath, PlayerJoin, BlockBreak, EntityKill, ItemUse
17
+ - Automatic namespace prefixing for scoreboard objectives
18
+ - Comprehensive MC tag constants (313 tags)
19
+
20
+ ### Changed
21
+ - Stdlib timer functions now use OOP API
22
+
23
+ ## [1.1.0] - 2026-03-12
24
+
25
+ ### Language Features
26
+ - **Variable selector syntax**: `execute if entity p[x_rotation=-90..-45]` now works in foreach loops
27
+ - **New selector filters**: `x_rotation`, `y_rotation`, `x`, `y`, `z` for rotation and position checks
28
+ - **Duplicate binding detection**: Error when redeclaring foreach variables
29
+
30
+ ### Builtins
31
+ - `effect_clear(target, [effect])` — Clear all or specific effects
32
+ - `data_merge(target, nbt)` — Merge NBT data into entities
33
+
34
+ ### Standard Library
35
+ - `effects.mcrs` — Effect shortcuts (speed, strength, regen, buff_all...)
36
+ - `world.mcrs` — World/gamerule helpers (set_day, weather_clear, enable_keep_inventory...)
37
+ - `inventory.mcrs` — Inventory management (give_kit_warrior, clear_inventory...)
38
+ - `particles.mcrs` — Particle effects (hearts_at, flames, sparkles_at...)
39
+ - `spawn.mcrs` — Teleport utilities (teleport_to, gather_all, goto_lobby...)
40
+ - `teams.mcrs` — Team management (create_red_team, setup_two_teams...)
41
+ - `bossbar.mcrs` — Bossbar helpers (create_progress_bar, update_bar...)
42
+ - `interactions.mcrs` — Input detection (check_look_up, on_right_click, on_sneak_click...)
43
+
44
+ ### Bug Fixes
45
+ - Negative coordinates in summon/tp/particle now work correctly
46
+ - Stdlib particles use coordinates instead of selectors
47
+
48
+ ### Documentation
49
+ - Added tutorials: Zombie Survival, Capture the Flag, Parkour Race
50
+ - Added local debugging guide
51
+ - Added stdlib reference page
52
+ - Added Paper server testing guide
53
+
54
+ ### Community
55
+ - CONTRIBUTING.md with development guide
56
+ - GitHub issue/PR templates
57
+ - CHANGELOG.md
58
+
59
+ ## [1.0.0] - 2026-03-12
60
+
61
+ ### 🎉 Initial Release
62
+
63
+ #### Language Features
64
+ - Variables with type inference: `let x = 5;`
65
+ - Functions with typed parameters and return types
66
+ - Control flow: `if`/`else`, `while`, `for i in 0..10`
67
+ - `foreach` for entity iteration
68
+ - Structs and Enums
69
+ - Lambda expressions: `(x: int) => x * 2`
70
+ - NBT structured parameters
71
+ - `@load` decorator for datapack initialization
72
+ - Global variables (compile to scoreboard fake players)
73
+ - `#mc_name` syntax for bare Minecraft identifiers
74
+ - Match expressions with pattern matching
75
+
76
+ #### Builtins (34+)
77
+ - Player: `say`, `tell`, `title`, `actionbar`, `give`, `kill`, `tp`, `effect`
78
+ - Scoreboard: `scoreboard_get`, `scoreboard_set`, `scoreboard_add`
79
+ - World: `setblock`, `fill`, `summon`, `weather`, `time_set`, `gamerule`
80
+ - Data: `data_get`, `data_merge`
81
+ - Runtime Sets: `set_new`, `set_add`, `set_contains`, `set_remove`
82
+ - And more...
83
+
84
+ #### Standard Library
85
+ - `math.mcrs` - `abs`, `min`, `max`, `clamp`, `sign`
86
+ - `player.mcrs` - `heal`, `feed`, `teleport_spawn`
87
+ - `cooldown.mcrs` - Cooldown management
88
+ - `timer.mcrs` - Timer utilities
89
+ - `combat.mcrs` - Combat helpers
90
+ - `mobs.mcrs` - Mob spawning utilities
91
+ - `sets.mcrs` - Set operations
92
+ - `strings.mcrs` - String formatting
93
+
94
+ #### CLI
95
+ - `redscript compile` - Compile to datapack
96
+ - `redscript watch` - Watch mode with hot reload
97
+ - `redscript check` - Type checking
98
+ - `redscript fmt` - Code formatter
99
+ - `redscript repl` - Interactive REPL
100
+ - Output targets: datapack, cmdblock, structure
101
+
102
+ #### Tooling
103
+ - VSCode Extension (v0.8.2) with syntax highlighting, autocomplete, go-to-definition, rename
104
+ - Online IDE: https://redscript-ide.pages.dev
105
+ - Documentation: https://redscript-docs.pages.dev
106
+ - Paper plugin for integration testing
107
+
108
+ #### Optimizer
109
+ - Dead code elimination
110
+ - Constant folding
111
+ - Inline simple functions
112
+ - Remove redundant scoreboard operations
@@ -0,0 +1,140 @@
1
+ # Contributing to RedScript
2
+
3
+ Thanks for your interest in contributing to RedScript! 🎮
4
+
5
+ ## Getting Started
6
+
7
+ ### Prerequisites
8
+
9
+ - Node.js 18+
10
+ - npm or pnpm
11
+
12
+ ### Setup
13
+
14
+ ```bash
15
+ git clone https://github.com/bkmashiro/redscript.git
16
+ cd redscript
17
+ npm install
18
+ npm run build
19
+ npm test
20
+ ```
21
+
22
+ ### Project Structure
23
+
24
+ ```
25
+ redscript/
26
+ ├── src/
27
+ │ ├── parser/ # Lexer & Parser (grammar → AST)
28
+ │ ├── lowering/ # AST → mcfunction code generation
29
+ │ ├── cli.ts # CLI entry point
30
+ │ ├── stdlib/ # Standard library (.mcrs files)
31
+ │ ├── examples/ # Example datapacks
32
+ │ └── __tests__/ # Jest tests
33
+ ├── redscript-vscode/ # VSCode extension
34
+ └── docs/ # Documentation
35
+ ```
36
+
37
+ ## Development Workflow
38
+
39
+ ### Building
40
+
41
+ ```bash
42
+ npm run build # Compile TypeScript
43
+ npm run watch # Watch mode
44
+ ```
45
+
46
+ ### Testing
47
+
48
+ ```bash
49
+ npm test # Run all tests
50
+ npm test -- --watch # Watch mode
51
+ npm test -- -t "foreach" # Run specific test
52
+ ```
53
+
54
+ ### Code Style
55
+
56
+ - TypeScript with strict mode
57
+ - No semicolons (handled by prettier)
58
+ - 2-space indentation
59
+
60
+ ## Making Changes
61
+
62
+ ### Adding a New Builtin Function
63
+
64
+ 1. Add to `BUILTINS` map in `src/lowering/index.ts`:
65
+
66
+ ```typescript
67
+ my_builtin: ([arg1, arg2]) => `my command ${arg1} ${arg2}`,
68
+ ```
69
+
70
+ 2. For complex builtins (returning values), add special handling in `lowerCall()`.
71
+
72
+ 3. Add tests in `src/__tests__/`:
73
+
74
+ ```typescript
75
+ it('compiles my_builtin', () => {
76
+ const source = `fn test() { my_builtin("a", "b"); }`
77
+ const files = compile(source)
78
+ expect(getFunction(files, 'test')).toContain('my command a b')
79
+ })
80
+ ```
81
+
82
+ 4. Add documentation in docs.
83
+
84
+ ### Adding Language Features
85
+
86
+ 1. Update grammar in `src/parser/` (lexer + parser)
87
+ 2. Add AST types if needed
88
+ 3. Update lowering in `src/lowering/`
89
+ 4. Add comprehensive tests
90
+ 5. Update VSCode extension syntax highlighting
91
+
92
+ ### Stdlib Contributions
93
+
94
+ Add utility functions to `src/stdlib/`:
95
+
96
+ ```mcrs
97
+ // src/stdlib/my_utils.mcrs
98
+
99
+ /// Useful helper function
100
+ fn my_helper(target: selector) {
101
+ // implementation
102
+ }
103
+ ```
104
+
105
+ ## Pull Request Process
106
+
107
+ 1. Fork the repo
108
+ 2. Create a feature branch: `git checkout -b feat/my-feature`
109
+ 3. Make changes with tests
110
+ 4. Run `npm run build && npm test`
111
+ 5. Commit with clear message: `feat: add X` / `fix: resolve Y`
112
+ 6. Push and open PR
113
+
114
+ ### Commit Convention
115
+
116
+ - `feat:` New feature
117
+ - `fix:` Bug fix
118
+ - `docs:` Documentation
119
+ - `test:` Tests
120
+ - `refactor:` Code refactoring
121
+ - `chore:` Maintenance
122
+
123
+ ## Testing on Real Server
124
+
125
+ For integration testing with a real Minecraft server:
126
+
127
+ 1. Set up Paper 1.21.4 server with [testharness plugin](https://github.com/bkmashiro/redscript-testharness)
128
+ 2. Run: `npm run test:mc`
129
+
130
+ See [Testing Guide](https://redscript-docs.pages.dev/en/guide/testing) for details.
131
+
132
+ ## Need Help?
133
+
134
+ - Open an issue for bugs or feature requests
135
+ - Check existing issues before creating new ones
136
+ - Join discussions in GitHub Discussions
137
+
138
+ ## License
139
+
140
+ By contributing, you agree that your contributions will be licensed under the MIT License.
package/README.md CHANGED
@@ -7,11 +7,16 @@
7
7
  Write clean game logic. RedScript handles the scoreboard spaghetti.
8
8
 
9
9
  [![CI](https://github.com/bkmashiro/redscript/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/bkmashiro/redscript/actions/workflows/ci.yml)
10
+ [![Tests](https://img.shields.io/badge/tests-510%20passing-brightgreen)](https://github.com/bkmashiro/redscript)
10
11
  [![npm](https://img.shields.io/npm/v/redscript-mc?color=cb3837)](https://www.npmjs.com/package/redscript-mc)
12
+ [![npm downloads](https://img.shields.io/npm/dm/redscript-mc?color=cb3837)](https://www.npmjs.com/package/redscript-mc)
13
+ [![VSCode](https://img.shields.io/badge/VSCode-Extension-007ACC?logo=visualstudiocode)](https://marketplace.visualstudio.com/items?itemName=bkmashiro.redscript-vscode)
14
+ [![Online IDE](https://img.shields.io/badge/Try-Online%20IDE-orange)](https://redscript-ide.pages.dev)
11
15
  [![license](https://img.shields.io/badge/license-MIT-blue)](./LICENSE)
12
- [![tests](https://img.shields.io/badge/tests-423%20passing-brightgreen)](./src/__tests__)
13
16
 
14
- [中文版](./README.zh.md) · [Wiki](https://github.com/bkmashiro/redscript/wiki) · [Quick Start](#quick-start)
17
+ [中文版](./README.zh.md) · [Quick Start](#quick-start) · [Docs](https://redscript-docs.pages.dev) · [Contributing](./CONTRIBUTING.md)
18
+
19
+ ### 🚀 [Try it online — no install needed!](https://redscript-ide.pages.dev)
15
20
 
16
21
  </div>
17
22
 
@@ -24,8 +29,8 @@ You want to make a Minecraft mini-game. You need a countdown timer, kill counter
24
29
  With RedScript, it's this:
25
30
 
26
31
  ```rs
27
- // pvp_game.rs
28
- import "stdlib/player.rs"
32
+ // pvp_game.mcrs
33
+ import "stdlib/player.mcrs"
29
34
 
30
35
  const GAME_TIME: int = 300;
31
36
 
@@ -67,20 +72,24 @@ One file. Compiles to a ready-to-use datapack in seconds.
67
72
 
68
73
  ### Quick Start
69
74
 
70
- #### Install
75
+ #### Option 1: Online IDE (No Install)
71
76
 
72
- ```bash
73
- npm install -g redscript
74
- ```
77
+ **[→ redscript-ide.pages.dev](https://redscript-ide.pages.dev)** — Write code, see output instantly.
78
+
79
+ #### Option 2: VSCode Extension
80
+
81
+ 1. Install [RedScript for VSCode](https://marketplace.visualstudio.com/items?itemName=bkmashiro.redscript-vscode)
82
+ 2. Get syntax highlighting, auto-complete, hover docs, and more
75
83
 
76
- #### Compile
84
+ #### Option 3: CLI
77
85
 
78
86
  ```bash
79
- redscript compile pvp_game.rs -o ./my-datapack
87
+ npm install -g redscript-mc
88
+ redscript compile game.mcrs -o ./my-datapack
80
89
  ```
81
90
 
82
91
  ```
83
- ✓ Compiled pvp_game.rs
92
+ ✓ Compiled pvp_game.mcrs
84
93
  Namespace : pvp_game
85
94
  Functions : 7
86
95
  Commands : 34 → 28 (optimizer: −18%)
@@ -230,11 +239,11 @@ redscript validate <file> Validate MC commands
230
239
  ### Standard Library
231
240
 
232
241
  ```rs
233
- import "stdlib/math.rs" // abs, min, max, clamp
234
- import "stdlib/player.rs" // is_alive, in_range, get_health
235
- import "stdlib/timer.rs" // start_timer, tick_timer, has_elapsed
236
- import "stdlib/cooldown.rs" // set_cooldown, check_cooldown
237
- import "stdlib/mobs.rs" // ZOMBIE, SKELETON, CREEPER, ... (60+ constants)
242
+ import "stdlib/math.mcrs" // abs, min, max, clamp
243
+ import "stdlib/player.mcrs" // is_alive, in_range, get_health
244
+ import "stdlib/timer.mcrs" // start_timer, tick_timer, has_elapsed
245
+ import "stdlib/cooldown.mcrs" // set_cooldown, check_cooldown
246
+ import "stdlib/mobs.mcrs" // ZOMBIE, SKELETON, CREEPER, ... (60+ constants)
238
247
  ```
239
248
 
240
249
  ---
@@ -244,10 +253,10 @@ import "stdlib/mobs.rs" // ZOMBIE, SKELETON, CREEPER, ... (60+ constants)
244
253
  | | |
245
254
  |---|---|
246
255
  | 📖 [Language Reference](docs/LANGUAGE_REFERENCE.md) | Full syntax & type system |
247
- | 🔧 [Builtins](https://github.com/bkmashiro/redscript/wiki/Builtins) | All 34+ MC builtin functions |
248
- | ⚡ [Optimizer](https://github.com/bkmashiro/redscript/wiki/Optimizer) | How the optimizer works |
256
+ | 🔧 [Builtins](https://redscript-docs.pages.dev/Builtins) | All 34+ MC builtin functions |
257
+ | ⚡ [Optimizer](https://redscript-docs.pages.dev/Optimizer) | How the optimizer works |
249
258
  | 🧱 [Structure Target](docs/STRUCTURE_TARGET.md) | Compile to NBT command block structures |
250
- | 🧪 [Integration Testing](https://github.com/bkmashiro/redscript/wiki/Integration-Testing) | Test against a real Paper server |
259
+ | 🧪 [Integration Testing](https://redscript-docs.pages.dev/Integration-Testing) | Test against a real Paper server |
251
260
  | 🏗 [Implementation Guide](docs/IMPLEMENTATION_GUIDE.md) | Compiler internals |
252
261
 
253
262
  ---
package/README.zh.md CHANGED
@@ -7,11 +7,16 @@
7
7
  写干净的游戏逻辑,把记分板的面条代码交给 RedScript 处理。
8
8
 
9
9
  [![CI](https://github.com/bkmashiro/redscript/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/bkmashiro/redscript/actions/workflows/ci.yml)
10
+ [![Tests](https://img.shields.io/badge/tests-510%20passing-brightgreen)](https://github.com/bkmashiro/redscript)
10
11
  [![npm](https://img.shields.io/npm/v/redscript-mc?color=cb3837)](https://www.npmjs.com/package/redscript-mc)
12
+ [![npm downloads](https://img.shields.io/npm/dm/redscript-mc?color=cb3837)](https://www.npmjs.com/package/redscript-mc)
13
+ [![VSCode](https://img.shields.io/badge/VSCode-插件-007ACC?logo=visualstudiocode)](https://marketplace.visualstudio.com/items?itemName=bkmashiro.redscript-vscode)
14
+ [![在线 IDE](https://img.shields.io/badge/试用-在线IDE-orange)](https://redscript-ide.pages.dev)
11
15
  [![license](https://img.shields.io/badge/license-MIT-blue)](./LICENSE)
12
- [![tests](https://img.shields.io/badge/tests-423%20passing-brightgreen)](./src/__tests__)
13
16
 
14
- [English](./README.md) · [Wiki](https://github.com/bkmashiro/redscript/wiki) · [快速开始](#快速开始)
17
+ [English](./README.md) · [快速开始](#快速开始) · [文档](https://redscript-docs.pages.dev) · [贡献指南](./CONTRIBUTING.md)
18
+
19
+ ### 🚀 [在线试用 — 无需安装!](https://redscript-ide.pages.dev)
15
20
 
16
21
  </div>
17
22
 
@@ -24,8 +29,8 @@
24
29
  用 RedScript,就是这样:
25
30
 
26
31
  ```rs
27
- // pvp_game.rs
28
- import "stdlib/player.rs"
32
+ // pvp_game.mcrs
33
+ import "stdlib/player.mcrs"
29
34
 
30
35
  const GAME_TIME: int = 300;
31
36
 
@@ -67,20 +72,24 @@ fn on_kill() {
67
72
 
68
73
  ### 快速开始
69
74
 
70
- #### 安装
75
+ #### 方式 1:在线 IDE(无需安装)
71
76
 
72
- ```bash
73
- npm install -g redscript
74
- ```
77
+ **[→ redscript-ide.pages.dev](https://redscript-ide.pages.dev)** — 写代码,实时看输出。
78
+
79
+ #### 方式 2:VSCode 插件
80
+
81
+ 1. 安装 [RedScript for VSCode](https://marketplace.visualstudio.com/items?itemName=bkmashiro.redscript-vscode)
82
+ 2. 获得语法高亮、自动补全、悬停文档等功能
75
83
 
76
- #### 编译
84
+ #### 方式 3:命令行
77
85
 
78
86
  ```bash
79
- redscript compile pvp_game.rs -o ./my-datapack
87
+ npm install -g redscript-mc
88
+ redscript compile game.mcrs -o ./my-datapack
80
89
  ```
81
90
 
82
91
  ```
83
- ✓ 已编译 pvp_game.rs
92
+ ✓ 已编译 pvp_game.mcrs
84
93
  命名空间 : pvp_game
85
94
  函数数量 : 7
86
95
  命令数量 : 34 → 28 (优化器节省了 18%)
@@ -230,11 +239,11 @@ redscript validate <file> 验证 MC 命令语法
230
239
  ### 标准库
231
240
 
232
241
  ```rs
233
- import "stdlib/math.rs" // abs, min, max, clamp
234
- import "stdlib/player.rs" // is_alive, in_range, get_health
235
- import "stdlib/timer.rs" // start_timer, tick_timer, has_elapsed
236
- import "stdlib/cooldown.rs" // set_cooldown, check_cooldown
237
- import "stdlib/mobs.rs" // ZOMBIE, SKELETON, CREEPER ... (60+ 实体常量)
242
+ import "stdlib/math.mcrs" // abs, min, max, clamp
243
+ import "stdlib/player.mcrs" // is_alive, in_range, get_health
244
+ import "stdlib/timer.mcrs" // start_timer, tick_timer, has_elapsed
245
+ import "stdlib/cooldown.mcrs" // set_cooldown, check_cooldown
246
+ import "stdlib/mobs.mcrs" // ZOMBIE, SKELETON, CREEPER ... (60+ 实体常量)
238
247
  ```
239
248
 
240
249
  ---
@@ -244,10 +253,10 @@ import "stdlib/mobs.rs" // ZOMBIE, SKELETON, CREEPER ... (60+ 实体常量
244
253
  | | |
245
254
  |---|---|
246
255
  | 📖 [语言参考](docs/LANGUAGE_REFERENCE.md) | 完整语法与类型系统 |
247
- | 🔧 [内置函数](https://github.com/bkmashiro/redscript/wiki/Builtins) | 所有 34+ MC 内置函数 |
248
- | ⚡ [优化器](https://github.com/bkmashiro/redscript/wiki/Optimizer) | 各优化 Pass 说明 |
256
+ | 🔧 [内置函数](https://redscript-docs.pages.dev/Builtins) | 所有 34+ MC 内置函数 |
257
+ | ⚡ [优化器](https://redscript-docs.pages.dev/Optimizer) | 各优化 Pass 说明 |
249
258
  | 🧱 [结构体目标](docs/STRUCTURE_TARGET.md) | 编译到 NBT 命令方块结构体 |
250
- | 🧪 [集成测试](https://github.com/bkmashiro/redscript/wiki/Integration-Testing) | 在真实 Paper 服务器上测试 |
259
+ | 🧪 [集成测试](https://redscript-docs.pages.dev/Integration-Testing) | 在真实 Paper 服务器上测试 |
251
260
  | 🏗 [实现指南](docs/IMPLEMENTATION_GUIDE.md) | 编译器内部原理 |
252
261
 
253
262
  ---