This repository has been archived by the owner on Jul 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
attributes.js
120 lines (114 loc) · 2.85 KB
/
attributes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
const modMetaAttributes = [
['name', 'Name', 'string', 'My name mod for translator'],
['displayName', 'Display Name', 'string', 'My name mod'],
['author', 'Author', 'string', 'Me'],
['description', 'Description', 'string', 'Provides new fun.'],
['version', 'Version', 'string', '1.0']
];
const blockCategories = [{
value: 'units',
name: 'Units'
}, {
value: 'crafting',
name:'Crafting'
}, {
value:'upgrade',
name:'Upgrade'
}, {
value:'effect',
name:'Effect'
}, {
value:'defense',
name:'Defense'
}, {
value:'power',
name:'Power'
}, {
value:'liquid',
name:'Liquid'
}, {
value:'distribution',
name:'Distribution'
}, {
value:'production',
name:'Production'
}, {
value:'turret',
name:'Turret'
} // indentifier, English name
]
const basicBlockAttributes = [
['id', 'id', 'string', 'my-special-building'],
['name', 'Name', 'string', 'My special building'], // identifier, English name, input type, palceholder, nullable (default: false)
['description', 'Description', 'string', 'Provides something special'],
['size', 'Size', 'number', 2],
['category', 'Category', 'select', blockCategories],
['requirements', 'Items used on build', 'addablePairList', [{
name: 'Item',
value: 'item',
type: 'string',
placeholder: 'silicon'
}, {
name: 'Amount',
value: 'amount',
type: 'number',
placeholder: '10'
}]]
];
const consumeBlockAttributes = [
['consumes', 'Consumption ', 'object', [
['power', 'Power consumption', 'number', '0.5 (30 power units/s)'],
['items', 'Items consumed', 'object', [
['items', 'Add consumed item', 'addablePairList', [{
name: 'Item',
value: 'item',
type: 'string',
placeholder: 'silicon'
}, {
name: 'Amount',
value: 'amount',
type: 'number',
placeholder: '10'
}]]
]]
]]
]
const blockAttributes = {
'UnitFactory': basicBlockAttributes.concat([ // Building type
['unitType', 'Unit type', 'string', 'chrome-wraith'],
['produceTime', 'Production time', 'number', '350']
]).concat(consumeBlockAttributes),
'GenericSmelter': basicBlockAttributes,
'Wall': basicBlockAttributes
}
const blockSprites = { // identifier, name, saveLocation
'UnitFactory': [
['icon', 'Icon', ''],
['top', 'Top', '-top']
],
'GenericSmelter': [
['icon', 'Icon', ''],
['top','Top','-top']
],
'Wall':[
['icon','Icon','']
]
}
function getBlock(type) {
var block = {}
basicBlockAttributes.forEach((attribute) => {
block[attribute[0]] = {
name: attribute[1],
type: attribute[2],
placeholder: attribute[3]
};
})
blockAttributes[type].forEach((attribute) => {
block[attribute[0]] = {
name: attribute[1],
type: attribute[2],
placeholder: attribute[3]
};
});
return block;
}