Skip to content

Commit 070d24d

Browse files
authored
Merge pull request #3 from TurboWarp/remove-variable-value-restrictions
Remove variable value restrictions
2 parents 326b4bc + af2e5b5 commit 070d24d

File tree

3 files changed

+119
-6
lines changed

3 files changed

+119
-6
lines changed

lib/sb3_definitions.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,7 @@
2929
{"type": "number"}
3030
]
3131
},
32-
"scalarVal": {
33-
"oneOf": [
34-
{"$ref":"#/definitions/stringOrNumber"},
35-
{"type": "boolean"}
36-
]
37-
},
32+
"scalarVal": {},
3833
"assetId": {
3934
"type": "string",
4035
"pattern": "^[a-fA-F0-9]{32}$"
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
{
2+
"targets": [
3+
{
4+
"isStage": true,
5+
"name": "Stage",
6+
"variables": {
7+
"8Ct!xBe$u3!.nz_Bh/]#": [
8+
"object",
9+
{
10+
"hello": "world"
11+
}
12+
]
13+
},
14+
"lists": {
15+
"u(}PhnFj*Oe*`Ka~{hhc": [
16+
"list of objects",
17+
[
18+
{
19+
"a": 1
20+
},
21+
{
22+
"b": 2
23+
}
24+
]
25+
]
26+
},
27+
"broadcasts": {},
28+
"blocks": {},
29+
"comments": {},
30+
"currentCostume": 0,
31+
"costumes": [
32+
{
33+
"name": "backdrop1",
34+
"dataFormat": "svg",
35+
"assetId": "cd21514d0531fdffb22204e0ec5ed84a",
36+
"md5ext": "cd21514d0531fdffb22204e0ec5ed84a.svg",
37+
"rotationCenterX": 240,
38+
"rotationCenterY": 180
39+
}
40+
],
41+
"sounds": [],
42+
"volume": 100,
43+
"layerOrder": 0,
44+
"tempo": 60,
45+
"videoTransparency": 50,
46+
"videoState": "on",
47+
"textToSpeechLanguage": null
48+
}
49+
],
50+
"monitors": [
51+
{
52+
"id": "8Ct!xBe$u3!.nz_Bh/]#",
53+
"mode": "default",
54+
"opcode": "data_variable",
55+
"params": {
56+
"VARIABLE": "object"
57+
},
58+
"spriteName": null,
59+
"value": 0,
60+
"width": 0,
61+
"height": 0,
62+
"x": 5,
63+
"y": 5,
64+
"visible": true,
65+
"sliderMin": 0,
66+
"sliderMax": 100,
67+
"isDiscrete": true
68+
},
69+
{
70+
"id": "u(}PhnFj*Oe*`Ka~{hhc",
71+
"mode": "list",
72+
"opcode": "data_listcontents",
73+
"params": {
74+
"LIST": "list of objects"
75+
},
76+
"spriteName": null,
77+
"value": [],
78+
"width": 0,
79+
"height": 0,
80+
"x": 5,
81+
"y": 32,
82+
"visible": true
83+
}
84+
],
85+
"extensions": [],
86+
"meta": {
87+
"semver": "3.0.0",
88+
"vm": "0.2.0",
89+
"agent": "",
90+
"platform": {
91+
"name": "TurboWarp",
92+
"url": "https://turbowarp.org/"
93+
}
94+
}
95+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const test = require('tap').test;
2+
const fs = require('fs');
3+
const path = require('path');
4+
const parser = require('../../index');
5+
6+
test('non scalar variables', function (t) {
7+
const fixture = fs.readFileSync(path.join(__dirname, '../fixtures/tw_non_scalar_variables.json'), 'utf-8');
8+
parser(fixture, false, function (err, result) {
9+
t.equal(err, null);
10+
t.same(result[0].targets[0].variables['8Ct!xBe$u3!.nz_Bh/]#'][1], {
11+
hello: 'world'
12+
});
13+
t.same(result[0].targets[0].lists['u(}PhnFj*Oe*`Ka~{hhc'][1], [
14+
{
15+
a: 1
16+
},
17+
{
18+
b: 2
19+
}
20+
]);
21+
t.end();
22+
});
23+
});

0 commit comments

Comments
 (0)