redscript-mc 1.2.21 → 1.2.24
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.
- package/.github/workflows/publish-extension-on-ci.yml +99 -0
- package/dist/__tests__/entity-types.test.d.ts +1 -0
- package/dist/__tests__/entity-types.test.js +203 -0
- package/dist/__tests__/var-allocator.test.d.ts +1 -0
- package/dist/__tests__/var-allocator.test.js +69 -0
- package/dist/ast/types.d.ts +2 -1
- package/dist/cli.js +17 -6
- package/dist/codegen/mcfunction/index.d.ts +2 -0
- package/dist/codegen/mcfunction/index.js +47 -43
- package/dist/codegen/structure/index.d.ts +4 -1
- package/dist/codegen/structure/index.js +8 -12
- package/dist/codegen/var-allocator.d.ts +28 -0
- package/dist/codegen/var-allocator.js +74 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -6
- package/dist/lowering/index.d.ts +2 -0
- package/dist/lowering/index.js +62 -3
- package/dist/parser/index.js +22 -1
- package/dist/typechecker/index.js +30 -0
- package/dist/types/entity-hierarchy.d.ts +29 -0
- package/dist/types/entity-hierarchy.js +107 -0
- package/editors/vscode/package-lock.json +6 -4
- package/editors/vscode/package.json +3 -3
- package/package.json +1 -1
- package/src/__tests__/entity-types.test.ts +236 -0
- package/src/__tests__/var-allocator.test.ts +75 -0
- package/src/ast/types.ts +8 -4
- package/src/cli.ts +20 -6
- package/src/codegen/mcfunction/index.ts +55 -48
- package/src/codegen/structure/index.ts +9 -14
- package/src/codegen/var-allocator.ts +71 -0
- package/src/examples/capture_the_flag.mcrs +34 -34
- package/src/examples/hunger_games.mcrs +59 -59
- package/src/examples/new_features_demo.mcrs +32 -32
- package/src/examples/parkour_race.mcrs +58 -58
- package/src/index.ts +10 -6
- package/src/lowering/index.ts +73 -8
- package/src/parser/index.ts +20 -1
- package/src/typechecker/index.ts +30 -0
- package/src/types/entity-hierarchy.ts +120 -0
- package/dist/data/arena/function/__load.mcfunction +0 -6
- package/dist/data/arena/function/__tick.mcfunction +0 -2
- package/dist/data/arena/function/announce_leaders/else_1.mcfunction +0 -3
- package/dist/data/arena/function/announce_leaders/foreach_0/merge_2.mcfunction +0 -1
- package/dist/data/arena/function/announce_leaders/foreach_0/then_0.mcfunction +0 -3
- package/dist/data/arena/function/announce_leaders/foreach_0.mcfunction +0 -7
- package/dist/data/arena/function/announce_leaders/foreach_1/merge_2.mcfunction +0 -1
- package/dist/data/arena/function/announce_leaders/foreach_1/then_0.mcfunction +0 -4
- package/dist/data/arena/function/announce_leaders/foreach_1.mcfunction +0 -6
- package/dist/data/arena/function/announce_leaders/merge_2.mcfunction +0 -1
- package/dist/data/arena/function/announce_leaders/then_0.mcfunction +0 -4
- package/dist/data/arena/function/announce_leaders.mcfunction +0 -6
- package/dist/data/arena/function/arena_tick/merge_2.mcfunction +0 -1
- package/dist/data/arena/function/arena_tick/then_0.mcfunction +0 -4
- package/dist/data/arena/function/arena_tick.mcfunction +0 -11
- package/dist/data/counter/function/__load.mcfunction +0 -5
- package/dist/data/counter/function/__tick.mcfunction +0 -2
- package/dist/data/counter/function/counter_tick/merge_2.mcfunction +0 -1
- package/dist/data/counter/function/counter_tick/then_0.mcfunction +0 -3
- package/dist/data/counter/function/counter_tick.mcfunction +0 -11
- package/dist/data/minecraft/tags/function/load.json +0 -5
- package/dist/data/minecraft/tags/function/tick.json +0 -5
- package/dist/data/quiz/function/__load.mcfunction +0 -16
- package/dist/data/quiz/function/__tick.mcfunction +0 -6
- package/dist/data/quiz/function/__trigger_quiz_a_dispatch.mcfunction +0 -4
- package/dist/data/quiz/function/__trigger_quiz_b_dispatch.mcfunction +0 -4
- package/dist/data/quiz/function/__trigger_quiz_c_dispatch.mcfunction +0 -4
- package/dist/data/quiz/function/__trigger_quiz_start_dispatch.mcfunction +0 -4
- package/dist/data/quiz/function/answer_a.mcfunction +0 -4
- package/dist/data/quiz/function/answer_b.mcfunction +0 -4
- package/dist/data/quiz/function/answer_c.mcfunction +0 -4
- package/dist/data/quiz/function/ask_question/else_1.mcfunction +0 -5
- package/dist/data/quiz/function/ask_question/else_4.mcfunction +0 -5
- package/dist/data/quiz/function/ask_question/else_7.mcfunction +0 -4
- package/dist/data/quiz/function/ask_question/merge_2.mcfunction +0 -1
- package/dist/data/quiz/function/ask_question/merge_5.mcfunction +0 -2
- package/dist/data/quiz/function/ask_question/merge_8.mcfunction +0 -2
- package/dist/data/quiz/function/ask_question/then_0.mcfunction +0 -4
- package/dist/data/quiz/function/ask_question/then_3.mcfunction +0 -4
- package/dist/data/quiz/function/ask_question/then_6.mcfunction +0 -4
- package/dist/data/quiz/function/ask_question.mcfunction +0 -7
- package/dist/data/quiz/function/finish_quiz.mcfunction +0 -6
- package/dist/data/quiz/function/handle_answer/else_1.mcfunction +0 -5
- package/dist/data/quiz/function/handle_answer/else_10.mcfunction +0 -3
- package/dist/data/quiz/function/handle_answer/else_16.mcfunction +0 -3
- package/dist/data/quiz/function/handle_answer/else_4.mcfunction +0 -3
- package/dist/data/quiz/function/handle_answer/else_7.mcfunction +0 -5
- package/dist/data/quiz/function/handle_answer/merge_11.mcfunction +0 -2
- package/dist/data/quiz/function/handle_answer/merge_14.mcfunction +0 -2
- package/dist/data/quiz/function/handle_answer/merge_17.mcfunction +0 -2
- package/dist/data/quiz/function/handle_answer/merge_2.mcfunction +0 -8
- package/dist/data/quiz/function/handle_answer/merge_5.mcfunction +0 -2
- package/dist/data/quiz/function/handle_answer/merge_8.mcfunction +0 -2
- package/dist/data/quiz/function/handle_answer/then_0.mcfunction +0 -5
- package/dist/data/quiz/function/handle_answer/then_12.mcfunction +0 -5
- package/dist/data/quiz/function/handle_answer/then_15.mcfunction +0 -6
- package/dist/data/quiz/function/handle_answer/then_3.mcfunction +0 -6
- package/dist/data/quiz/function/handle_answer/then_6.mcfunction +0 -5
- package/dist/data/quiz/function/handle_answer/then_9.mcfunction +0 -6
- package/dist/data/quiz/function/handle_answer.mcfunction +0 -11
- package/dist/data/quiz/function/start_quiz.mcfunction +0 -5
- package/dist/data/shop/function/__load.mcfunction +0 -7
- package/dist/data/shop/function/__tick.mcfunction +0 -3
- package/dist/data/shop/function/__trigger_shop_buy_dispatch.mcfunction +0 -4
- package/dist/data/shop/function/complete_purchase/else_1.mcfunction +0 -5
- package/dist/data/shop/function/complete_purchase/else_4.mcfunction +0 -5
- package/dist/data/shop/function/complete_purchase/else_7.mcfunction +0 -3
- package/dist/data/shop/function/complete_purchase/merge_2.mcfunction +0 -2
- package/dist/data/shop/function/complete_purchase/merge_5.mcfunction +0 -2
- package/dist/data/shop/function/complete_purchase/merge_8.mcfunction +0 -2
- package/dist/data/shop/function/complete_purchase/then_0.mcfunction +0 -4
- package/dist/data/shop/function/complete_purchase/then_3.mcfunction +0 -4
- package/dist/data/shop/function/complete_purchase/then_6.mcfunction +0 -4
- package/dist/data/shop/function/complete_purchase.mcfunction +0 -7
- package/dist/data/shop/function/handle_shop_trigger.mcfunction +0 -3
- package/dist/data/turret/function/__load.mcfunction +0 -5
- package/dist/data/turret/function/__tick.mcfunction +0 -4
- package/dist/data/turret/function/__trigger_deploy_turret_dispatch.mcfunction +0 -4
- package/dist/data/turret/function/deploy_turret.mcfunction +0 -8
- package/dist/data/turret/function/turret_tick/at_1.mcfunction +0 -2
- package/dist/data/turret/function/turret_tick/foreach_0.mcfunction +0 -2
- package/dist/data/turret/function/turret_tick/foreach_2.mcfunction +0 -2
- package/dist/data/turret/function/turret_tick/tick_body.mcfunction +0 -3
- package/dist/data/turret/function/turret_tick/tick_skip.mcfunction +0 -1
- package/dist/data/turret/function/turret_tick.mcfunction +0 -5
- package/dist/pack.mcmeta +0 -6
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entity Type Hierarchy
|
|
3
|
+
*
|
|
4
|
+
* Closed inheritance tree mapping to Minecraft's entity registry.
|
|
5
|
+
* Used for type narrowing (is checks), selector<T> annotations,
|
|
6
|
+
* and W_IMPOSSIBLE_AS warnings.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export interface EntityTypeNode {
|
|
10
|
+
name: string
|
|
11
|
+
mcId: string | null // null for abstract types
|
|
12
|
+
abstract: boolean
|
|
13
|
+
parent: string | null // null for root "Entity"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const ENTITY_TYPES: EntityTypeNode[] = [
|
|
17
|
+
// Root
|
|
18
|
+
{ name: 'Entity', mcId: null, abstract: true, parent: null },
|
|
19
|
+
|
|
20
|
+
// Direct children of Entity
|
|
21
|
+
{ name: 'Player', mcId: 'minecraft:player', abstract: false, parent: 'Entity' },
|
|
22
|
+
{ name: 'ArmorStand', mcId: 'minecraft:armor_stand', abstract: false, parent: 'Entity' },
|
|
23
|
+
{ name: 'Item', mcId: 'minecraft:item', abstract: false, parent: 'Entity' },
|
|
24
|
+
{ name: 'Arrow', mcId: 'minecraft:arrow', abstract: false, parent: 'Entity' },
|
|
25
|
+
|
|
26
|
+
// Mob hierarchy
|
|
27
|
+
{ name: 'Mob', mcId: null, abstract: true, parent: 'Entity' },
|
|
28
|
+
|
|
29
|
+
// Hostile mobs
|
|
30
|
+
{ name: 'HostileMob', mcId: null, abstract: true, parent: 'Mob' },
|
|
31
|
+
{ name: 'Zombie', mcId: 'minecraft:zombie', abstract: false, parent: 'HostileMob' },
|
|
32
|
+
{ name: 'Skeleton', mcId: 'minecraft:skeleton', abstract: false, parent: 'HostileMob' },
|
|
33
|
+
{ name: 'Creeper', mcId: 'minecraft:creeper', abstract: false, parent: 'HostileMob' },
|
|
34
|
+
{ name: 'Spider', mcId: 'minecraft:spider', abstract: false, parent: 'HostileMob' },
|
|
35
|
+
{ name: 'Enderman', mcId: 'minecraft:enderman', abstract: false, parent: 'HostileMob' },
|
|
36
|
+
{ name: 'Blaze', mcId: 'minecraft:blaze', abstract: false, parent: 'HostileMob' },
|
|
37
|
+
{ name: 'Witch', mcId: 'minecraft:witch', abstract: false, parent: 'HostileMob' },
|
|
38
|
+
{ name: 'Slime', mcId: 'minecraft:slime', abstract: false, parent: 'HostileMob' },
|
|
39
|
+
{ name: 'ZombieVillager', mcId: 'minecraft:zombie_villager', abstract: false, parent: 'HostileMob' },
|
|
40
|
+
{ name: 'Husk', mcId: 'minecraft:husk', abstract: false, parent: 'HostileMob' },
|
|
41
|
+
{ name: 'Drowned', mcId: 'minecraft:drowned', abstract: false, parent: 'HostileMob' },
|
|
42
|
+
{ name: 'Stray', mcId: 'minecraft:stray', abstract: false, parent: 'HostileMob' },
|
|
43
|
+
{ name: 'WitherSkeleton', mcId: 'minecraft:wither_skeleton', abstract: false, parent: 'HostileMob' },
|
|
44
|
+
{ name: 'CaveSpider', mcId: 'minecraft:cave_spider', abstract: false, parent: 'HostileMob' },
|
|
45
|
+
|
|
46
|
+
// Passive mobs
|
|
47
|
+
{ name: 'PassiveMob', mcId: null, abstract: true, parent: 'Mob' },
|
|
48
|
+
{ name: 'Pig', mcId: 'minecraft:pig', abstract: false, parent: 'PassiveMob' },
|
|
49
|
+
{ name: 'Cow', mcId: 'minecraft:cow', abstract: false, parent: 'PassiveMob' },
|
|
50
|
+
{ name: 'Sheep', mcId: 'minecraft:sheep', abstract: false, parent: 'PassiveMob' },
|
|
51
|
+
{ name: 'Chicken', mcId: 'minecraft:chicken', abstract: false, parent: 'PassiveMob' },
|
|
52
|
+
{ name: 'Villager', mcId: 'minecraft:villager', abstract: false, parent: 'PassiveMob' },
|
|
53
|
+
{ name: 'WanderingTrader', mcId: 'minecraft:wandering_trader', abstract: false, parent: 'PassiveMob' },
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
/** Map from lowercase name → EntityTypeNode */
|
|
57
|
+
export const ENTITY_TYPE_MAP: Map<string, EntityTypeNode> = new Map(
|
|
58
|
+
ENTITY_TYPES.map(t => [t.name.toLowerCase(), t])
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
/** Map from mcId (without namespace) → EntityTypeNode */
|
|
62
|
+
export const ENTITY_TYPE_BY_MCID: Map<string, EntityTypeNode> = new Map(
|
|
63
|
+
ENTITY_TYPES
|
|
64
|
+
.filter(t => t.mcId !== null)
|
|
65
|
+
.map(t => [t.mcId!.replace('minecraft:', ''), t])
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
/** Check if typeA is a subtype of typeB (recursive ancestry) */
|
|
69
|
+
export function isSubtype(typeA: string, typeB: string): boolean {
|
|
70
|
+
if (typeA === typeB) return true
|
|
71
|
+
const node = ENTITY_TYPE_MAP.get(typeA.toLowerCase())
|
|
72
|
+
if (!node || !node.parent) return false
|
|
73
|
+
return isSubtype(node.parent, typeB)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** True if one type is a subtype of the other (in either direction) */
|
|
77
|
+
export function areCompatibleTypes(outerType: string, innerType: string): boolean {
|
|
78
|
+
return isSubtype(outerType, innerType) || isSubtype(innerType, outerType)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Get all non-abstract leaf types under a given node */
|
|
82
|
+
export function getConcreteSubtypes(typeName: string): EntityTypeNode[] {
|
|
83
|
+
const results: EntityTypeNode[] = []
|
|
84
|
+
for (const node of ENTITY_TYPES) {
|
|
85
|
+
if (!node.abstract && isSubtype(node.name, typeName)) {
|
|
86
|
+
results.push(node)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return results
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Parse "type=zombie" from a selector string, return the entity type name or null */
|
|
93
|
+
export function getSelectorEntityType(selector: string): string | null {
|
|
94
|
+
const match = selector.match(/type=(?:minecraft:)?([a-z_]+)/)
|
|
95
|
+
if (!match) return null
|
|
96
|
+
const mcId = match[1]
|
|
97
|
+
const node = ENTITY_TYPE_BY_MCID.get(mcId)
|
|
98
|
+
return node ? node.name : null
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Determine the base entity type from a selector kind:
|
|
102
|
+
* @a/@p/@r → "Player", @e → "Entity" or from type filter, @s → null */
|
|
103
|
+
export function getBaseSelectorType(selector: string): string | null {
|
|
104
|
+
const trimmed = selector.trim()
|
|
105
|
+
|
|
106
|
+
// Check for type filter first (works for any selector)
|
|
107
|
+
const typeFromFilter = getSelectorEntityType(trimmed)
|
|
108
|
+
|
|
109
|
+
if (trimmed.startsWith('@a') || trimmed.startsWith('@p') || trimmed.startsWith('@r')) {
|
|
110
|
+
return typeFromFilter ?? 'Player'
|
|
111
|
+
}
|
|
112
|
+
if (trimmed.startsWith('@e')) {
|
|
113
|
+
return typeFromFilter ?? 'Entity'
|
|
114
|
+
}
|
|
115
|
+
// @s — context-dependent, we don't know unless there's a type filter
|
|
116
|
+
if (trimmed.startsWith('@s')) {
|
|
117
|
+
return typeFromFilter ?? null
|
|
118
|
+
}
|
|
119
|
+
return null
|
|
120
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# block: merge_2
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# block: entry
|
|
2
|
-
execute store result score $t0 rs run scoreboard players get @s kills
|
|
3
|
-
scoreboard players operation $kills rs = $t0 rs
|
|
4
|
-
scoreboard players set $t1 rs 0
|
|
5
|
-
execute if score $t0 rs > $top_kills rs run scoreboard players set $t1 rs 1
|
|
6
|
-
execute if score $t1 rs matches 1.. run function arena:announce_leaders/foreach_0/then_0
|
|
7
|
-
execute if score $t1 rs matches ..0 run function arena:announce_leaders/foreach_0/merge_2
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# block: merge_2
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
# block: entry
|
|
2
|
-
execute store result score $t0 rs run scoreboard players get @s kills
|
|
3
|
-
scoreboard players set $t1 rs 0
|
|
4
|
-
execute if score $t0 rs = $top_kills rs run scoreboard players set $t1 rs 1
|
|
5
|
-
execute if score $t1 rs matches 1.. run function arena:announce_leaders/foreach_1/then_0
|
|
6
|
-
execute if score $t1 rs matches ..0 run function arena:announce_leaders/foreach_1/merge_2
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# block: merge_2
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
# block: entry
|
|
2
|
-
execute as @a run function arena:announce_leaders/foreach_0
|
|
3
|
-
scoreboard players set $t0 rs 0
|
|
4
|
-
execute if score $const_0 rs > $const_0 rs run scoreboard players set $t0 rs 1
|
|
5
|
-
execute if score $t0 rs matches 1.. run function arena:announce_leaders/then_0
|
|
6
|
-
execute if score $t0 rs matches ..0 run function arena:announce_leaders/else_1
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# block: merge_2
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# block: entry
|
|
2
|
-
execute store result score $t0 rs run scoreboard players get arena ticks
|
|
3
|
-
scoreboard players operation $t1 rs = $t0 rs
|
|
4
|
-
scoreboard players operation $t1 rs += $const_1 rs
|
|
5
|
-
execute store result score arena ticks run scoreboard players get $t2 rs
|
|
6
|
-
scoreboard players operation $t3 rs = $t1 rs
|
|
7
|
-
scoreboard players operation $t3 rs %= $const_200 rs
|
|
8
|
-
scoreboard players set $t4 rs 0
|
|
9
|
-
execute if score $t3 rs = $const_0 rs run scoreboard players set $t4 rs 1
|
|
10
|
-
execute if score $t4 rs matches 1.. run function arena:arena_tick/then_0
|
|
11
|
-
execute if score $t4 rs matches ..0 run function arena:arena_tick/merge_2
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# block: merge_2
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# block: entry
|
|
2
|
-
execute store result score $t0 rs run scoreboard players get counter ticks
|
|
3
|
-
scoreboard players operation $t1 rs = $t0 rs
|
|
4
|
-
scoreboard players operation $t1 rs += $const_1 rs
|
|
5
|
-
execute store result score counter ticks run scoreboard players get $t2 rs
|
|
6
|
-
scoreboard players operation $t3 rs = $t1 rs
|
|
7
|
-
scoreboard players operation $t3 rs %= $const_100 rs
|
|
8
|
-
scoreboard players set $t4 rs 0
|
|
9
|
-
execute if score $t3 rs = $const_0 rs run scoreboard players set $t4 rs 1
|
|
10
|
-
execute if score $t4 rs matches 1.. run function counter:counter_tick/then_0
|
|
11
|
-
execute if score $t4 rs matches ..0 run function counter:counter_tick/merge_2
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# RedScript runtime init
|
|
2
|
-
scoreboard objectives add rs dummy
|
|
3
|
-
scoreboard objectives add quiz_start trigger
|
|
4
|
-
scoreboard players enable @a quiz_start
|
|
5
|
-
scoreboard objectives add quiz_a trigger
|
|
6
|
-
scoreboard players enable @a quiz_a
|
|
7
|
-
scoreboard objectives add quiz_b trigger
|
|
8
|
-
scoreboard players enable @a quiz_b
|
|
9
|
-
scoreboard objectives add quiz_c trigger
|
|
10
|
-
scoreboard players enable @a quiz_c
|
|
11
|
-
scoreboard players set $const_1 rs 1
|
|
12
|
-
scoreboard players set $const_2 rs 2
|
|
13
|
-
scoreboard players set $const_3 rs 3
|
|
14
|
-
scoreboard players set $const_1 rs 1
|
|
15
|
-
scoreboard players set $const_2 rs 2
|
|
16
|
-
scoreboard players set $const_3 rs 3
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
# RedScript tick dispatcher
|
|
2
|
-
# Trigger checks
|
|
3
|
-
execute as @a[scores={quiz_start=1..}] run function quiz:__trigger_quiz_start_dispatch
|
|
4
|
-
execute as @a[scores={quiz_a=1..}] run function quiz:__trigger_quiz_a_dispatch
|
|
5
|
-
execute as @a[scores={quiz_b=1..}] run function quiz:__trigger_quiz_b_dispatch
|
|
6
|
-
execute as @a[scores={quiz_c=1..}] run function quiz:__trigger_quiz_c_dispatch
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# block: else_1
|
|
2
|
-
scoreboard players set $t2 rs 0
|
|
3
|
-
execute if score $question rs = $const_2 rs run scoreboard players set $t2 rs 1
|
|
4
|
-
execute if score $t2 rs matches 1.. run function quiz:ask_question/then_3
|
|
5
|
-
execute if score $t2 rs matches ..0 run function quiz:ask_question/else_4
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# block: else_4
|
|
2
|
-
scoreboard players set $t3 rs 0
|
|
3
|
-
execute if score $question rs = $const_3 rs run scoreboard players set $t3 rs 1
|
|
4
|
-
execute if score $t3 rs matches 1.. run function quiz:ask_question/then_6
|
|
5
|
-
execute if score $t3 rs matches ..0 run function quiz:ask_question/else_7
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# block: merge_2
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# block: entry
|
|
2
|
-
execute store result score $t0 rs run scoreboard players get @s quiz_question
|
|
3
|
-
scoreboard players operation $question rs = $t0 rs
|
|
4
|
-
scoreboard players set $t1 rs 0
|
|
5
|
-
execute if score $t0 rs = $const_1 rs run scoreboard players set $t1 rs 1
|
|
6
|
-
execute if score $t1 rs matches 1.. run function quiz:ask_question/then_0
|
|
7
|
-
execute if score $t1 rs matches ..0 run function quiz:ask_question/else_1
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
# block: entry
|
|
2
|
-
execute store result score $t0 rs run scoreboard players get @s quiz_score
|
|
3
|
-
title @s title {"text":"Quiz Complete"}
|
|
4
|
-
tellraw @s {"text":"Your final quiz score is recorded in quiz_score."}
|
|
5
|
-
scoreboard players set @s quiz_question 0
|
|
6
|
-
execute store result score @s quiz_score run scoreboard players get $t1 rs
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# block: else_1
|
|
2
|
-
scoreboard players set $t5 rs 0
|
|
3
|
-
execute if score $question rs = $const_2 rs run scoreboard players set $t5 rs 1
|
|
4
|
-
execute if score $t5 rs matches 1.. run function quiz:handle_answer/then_6
|
|
5
|
-
execute if score $t5 rs matches ..0 run function quiz:handle_answer/else_7
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# block: else_7
|
|
2
|
-
scoreboard players set $t8 rs 0
|
|
3
|
-
execute if score $question rs = $const_3 rs run scoreboard players set $t8 rs 1
|
|
4
|
-
execute if score $t8 rs matches 1.. run function quiz:handle_answer/then_12
|
|
5
|
-
execute if score $t8 rs matches ..0 run function quiz:handle_answer/merge_14
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# block: merge_2
|
|
2
|
-
execute store result score @s quiz_score run scoreboard players get $t11 rs
|
|
3
|
-
scoreboard players operation $t12 rs = $question rs
|
|
4
|
-
scoreboard players operation $t12 rs += $const_1 rs
|
|
5
|
-
scoreboard players operation $question rs = $t12 rs
|
|
6
|
-
execute store result score @s quiz_question run scoreboard players get $t13 rs
|
|
7
|
-
function quiz:ask_question
|
|
8
|
-
scoreboard players operation $t14 rs = $ret rs
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# block: then_0
|
|
2
|
-
scoreboard players set $t3 rs 0
|
|
3
|
-
execute if score $choice rs = $const_1 rs run scoreboard players set $t3 rs 1
|
|
4
|
-
execute if score $t3 rs matches 1.. run function quiz:handle_answer/then_3
|
|
5
|
-
execute if score $t3 rs matches ..0 run function quiz:handle_answer/else_4
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# block: then_12
|
|
2
|
-
scoreboard players set $t9 rs 0
|
|
3
|
-
execute if score $choice rs = $const_2 rs run scoreboard players set $t9 rs 1
|
|
4
|
-
execute if score $t9 rs matches 1.. run function quiz:handle_answer/then_15
|
|
5
|
-
execute if score $t9 rs matches ..0 run function quiz:handle_answer/else_16
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# block: then_6
|
|
2
|
-
scoreboard players set $t6 rs 0
|
|
3
|
-
execute if score $choice rs = $const_2 rs run scoreboard players set $t6 rs 1
|
|
4
|
-
execute if score $t6 rs matches 1.. run function quiz:handle_answer/then_9
|
|
5
|
-
execute if score $t6 rs matches ..0 run function quiz:handle_answer/else_10
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# block: entry
|
|
2
|
-
scoreboard players operation $choice rs = $p0 rs
|
|
3
|
-
scoreboard players operation $choice rs = $p0 rs
|
|
4
|
-
execute store result score $t0 rs run scoreboard players get @s quiz_question
|
|
5
|
-
scoreboard players operation $question rs = $t0 rs
|
|
6
|
-
execute store result score $t1 rs run scoreboard players get @s quiz_score
|
|
7
|
-
scoreboard players operation $score rs = $t1 rs
|
|
8
|
-
scoreboard players set $t2 rs 0
|
|
9
|
-
execute if score $t0 rs = $const_1 rs run scoreboard players set $t2 rs 1
|
|
10
|
-
execute if score $t2 rs matches 1.. run function quiz:handle_answer/then_0
|
|
11
|
-
execute if score $t2 rs matches ..0 run function quiz:handle_answer/else_1
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# block: else_1
|
|
2
|
-
scoreboard players set $t2 rs 0
|
|
3
|
-
execute if score $choice rs = $const_2 rs run scoreboard players set $t2 rs 1
|
|
4
|
-
execute if score $t2 rs matches 1.. run function shop:complete_purchase/then_3
|
|
5
|
-
execute if score $t2 rs matches ..0 run function shop:complete_purchase/else_4
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# block: else_4
|
|
2
|
-
scoreboard players set $t3 rs 0
|
|
3
|
-
execute if score $choice rs = $const_3 rs run scoreboard players set $t3 rs 1
|
|
4
|
-
execute if score $t3 rs matches 1.. run function shop:complete_purchase/then_6
|
|
5
|
-
execute if score $t3 rs matches ..0 run function shop:complete_purchase/else_7
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# block: entry
|
|
2
|
-
execute store result score $t0 rs run scoreboard players get @s shop_choice
|
|
3
|
-
scoreboard players operation $choice rs = $t0 rs
|
|
4
|
-
scoreboard players set $t1 rs 0
|
|
5
|
-
execute if score $t0 rs = $const_1 rs run scoreboard players set $t1 rs 1
|
|
6
|
-
execute if score $t1 rs matches 1.. run function shop:complete_purchase/then_0
|
|
7
|
-
execute if score $t1 rs matches ..0 run function shop:complete_purchase/else_1
|