Skip to content

Commit 25d1d43

Browse files
committedJun 6, 2017
Update colors.txt
1 parent 4f7d2a5 commit 25d1d43

File tree

2 files changed

+72
-50
lines changed

2 files changed

+72
-50
lines changed
 

‎autogenerating-colors.txt

+38-42
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
==FILE== mods/dumpnodes/init.lua
22
local function nd_get_tiles(nd)
3-
if nd.tiles then
4-
return nd.tiles
5-
elseif nd.tile_images then
6-
return nd.tile_images
3+
return nd.tiles or nd.tile_images
4+
end
5+
6+
local function nd_get_tile(nd, n)
7+
local tile = nd_get_tiles(nd)[n]
8+
if type(tile) == 'table' then
9+
tile = tile.name
710
end
8-
return nil
11+
return tile
912
end
1013

1114
local function pairs_s(dict)
@@ -20,40 +23,37 @@ end
2023
minetest.register_chatcommand("dumpnodes", {
2124
params = "",
2225
description = "",
23-
func = function(plname, param)
26+
func = function(player, param)
2427
local n = 0
2528
local ntbl = {}
2629
for _, nn in pairs_s(minetest.registered_nodes) do
2730
local nd = minetest.registered_nodes[nn]
2831
local prefix, name = nn:match('(.*):(.*)')
29-
if prefix == nil or name == nil or prefix == '' or name == '' then
32+
if prefix == nil or name == nil then
3033
print("ignored(1): " .. nn)
3134
else
3235
if ntbl[prefix] == nil then
3336
ntbl[prefix] = {}
3437
end
35-
ntbl[prefix][name] = nd
38+
ntbl[prefix][name] = true
3639
end
3740
end
3841
local out, err = io.open('nodes.txt', 'wb')
3942
if not out then
4043
return true, "io.open(): " .. err
4144
end
4245
for _, prefix in pairs_s(ntbl) do
43-
local nodes = ntbl[prefix]
4446
out:write('# ' .. prefix .. '\n')
45-
for _, name in pairs_s(nodes) do
46-
local nd = nodes[name]
47-
if nd.drawtype ~= 'airlike' and nd_get_tiles(nd) ~= nil then
48-
local tl = nd_get_tiles(nd)[1]
49-
if type(tl) == 'table' then
50-
tl = tl.name
51-
end
52-
tl = (tl .. '^'):match('(.-)^')
53-
out:write(prefix .. ':' .. name .. ' ' .. tl .. '\n')
54-
n = n + 1
47+
for _, name in pairs_s(ntbl[prefix]) do
48+
local nn = prefix .. ":" .. name
49+
local nd = minetest.registered_nodes[nn]
50+
if nd.drawtype == 'airlike' or nd_get_tiles(nd) == nil then
51+
print("ignored(2): " .. nn)
5552
else
56-
print("ignored(2): " .. prefix .. ':' .. name)
53+
local tl = nd_get_tile(nd, 1)
54+
tl = (tl .. '^'):match('(.-)^') -- strip modifiers
55+
out:write(nn .. ' ' .. tl .. '\n')
56+
n = n + 1
5757
end
5858
end
5959
out:write('\n')
@@ -67,56 +67,52 @@ minetest.register_chatcommand("dumpnodes", {
6767
import sys
6868
from PIL import Image
6969

70-
def tsum(a, b):
70+
def tadd(a, b):
7171
return tuple(sum(e) for e in zip(a, b))
7272

7373
if len(sys.argv) < 2:
7474
print("Prints average color (RGB) of input image")
7575
print("Usage: %s <input>" % sys.argv[0])
7676
exit(1)
7777

78-
inp = Image.open(sys.argv[1])
79-
inp = inp.convert('RGBA')
78+
inp = Image.open(sys.argv[1]).convert('RGBA')
8079
ind = inp.load()
8180

8281
cl = (0, 0, 0)
8382
counted = 0
8483
for x in range(inp.size[0]):
8584
for y in range(inp.size[1]):
8685
px = ind[x, y]
87-
if px[3] < 128:
88-
continue
89-
cl = tsum(cl, px[:3])
90-
counted = counted + 1
86+
if px[3] < 128: continue # alpha
87+
cl = tadd(cl, px[:3])
88+
counted += 1
9189

9290
if counted == 0:
93-
sys.stderr.write("didn't find avg. color for %s\n" % sys.argv[1])
91+
sys.stderr.write("did not find avg color for %s\n" % sys.argv[1])
9492
print("0 0 0")
95-
exit(0)
96-
97-
cl = tuple(int(n / counted) for n in cl)
98-
print("%d %d %d" % cl)
93+
else:
94+
cl = tuple(int(n / counted) for n in cl)
95+
print("%d %d %d" % cl)
9996
==SCRIPT==
10097
#!/bin/bash -e
101-
10298
AVGCOLOR_PATH=/path/to/avgcolor.py
103-
MTGAME_PATH=/path/to/minetest_game
99+
GAME_PATH=/path/to/minetest_game
100+
MODS_PATH= # path to "mods" folder, only set if you have loaded mods
104101
NODESTXT_PATH=./nodes.txt
105102
COLORSTXT_PATH=./colors.txt
106103

107104
while read -r line; do
108-
set -- junk $line
109-
shift
105+
set -- junk $line; shift
110106
if [[ -z "$1" || $1 == "#" ]]; then
111-
echo $line
112-
continue
107+
echo "$line"; continue
113108
fi
114-
tex=$(find $MTGAME_PATH -type f -name "$2")
109+
tex=$(find $GAME_PATH -type f -name "$2")
110+
[[ -z "$tex" && -n "$MODS_PATH" ]] && tex=$(find $MODS_PATH -type f -name "$2")
115111
if [ -z "$tex" ]; then
116112
echo "skip $1: texture not found" >&2
117113
continue
118114
fi
119-
echo $1 $(python $AVGCOLOR_PATH "$tex")
115+
echo "$1" $(python $AVGCOLOR_PATH "$tex")
120116
echo "ok $1" >&2
121117
done < $NODESTXT_PATH > $COLORSTXT_PATH
122118
# Use nicer colors for water and lava:
@@ -128,8 +124,8 @@ sed -re 's/^doors:(.*glass[^ ]*) ([0-9 ]+)$/doors:\1 \2 64 16/g' $COLORSTXT_PATH
128124
# Fix xpanes color:
129125
sed -re 's/^xpanes:((pane|bar)(_flat)?) [0-9 ]+$/xpanes:\1 194 194 227 64 16/g' $COLORSTXT_PATH -i
130126
==INSTRUCTIONS==
131-
1) Make sure avgcolors.py outputs the usage instructions
127+
1) Make sure avgcolors.py works (outputs the usage instructions when run)
132128
2) Add the dumpnodes mod to Minetest
133129
3) Create a world and load dumpnodes & all mods you want to generate colors for
134130
4) Execute /dumpnodes ingame
135-
5) Run the script to generate colors.txt (make sure to replace /path/to/... with the actual paths)
131+
5) Run the script to generate colors.txt (make sure to adjust the PATH variables at the top)

‎colors.txt

+34-8
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,28 @@ carts:rail 143 123 90
1414

1515
# default
1616
default:acacia_bush_leaves 90 124 55
17+
default:acacia_bush_sapling 85 118 58
1718
default:acacia_bush_stem 84 76 69
1819
default:acacia_leaves 108 147 67
1920
default:acacia_sapling 87 116 61
2021
default:acacia_tree 188 109 90
2122
default:acacia_wood 146 60 37
2223
default:apple 145 20 9
23-
default:aspen_leaves 66 89 38
24+
default:aspen_leaves 70 104 27
2425
default:aspen_sapling 82 110 43
2526
default:aspen_tree 218 197 166
2627
default:aspen_wood 209 198 169
2728
default:bookshelf 128 99 55
2829
default:brick 117 71 69
2930
default:bronzeblock 185 110 15
3031
default:bush_leaves 34 52 29
32+
default:bush_sapling 65 60 40
3133
default:bush_stem 45 33 23
3234
default:cactus 52 116 15
3335
default:chest 140 108 65
3436
default:chest_locked 140 108 65
37+
default:chest_locked_open 140 108 65
38+
default:chest_open 140 108 65
3539
default:clay 182 182 182
3640
default:cloud 255 255 255
3741
default:coalblock 57 57 57
@@ -42,6 +46,9 @@ default:coral_orange 191 62 12
4246
default:coral_skeleton 235 230 214
4347
default:desert_cobble 146 95 76
4448
default:desert_sand 206 165 98
49+
default:desert_sandstone 195 152 92
50+
default:desert_sandstone_block 192 151 94
51+
default:desert_sandstone_brick 191 151 94
4552
default:desert_stone 129 79 60
4653
default:desert_stone_block 130 79 60
4754
default:desert_stonebrick 129 79 60
@@ -50,7 +57,8 @@ default:dirt 95 64 39
5057
default:dirt_with_dry_grass 187 148 77
5158
default:dirt_with_grass 66 112 31
5259
default:dirt_with_grass_footsteps 66 112 31
53-
default:dirt_with_snow 223 224 236
60+
default:dirt_with_rainforest_litter 74 38 8
61+
default:dirt_with_snow 224 225 238
5462
default:dry_grass_1 208 172 87
5563
default:dry_grass_2 210 174 87
5664
default:dry_grass_3 210 174 87
@@ -84,6 +92,7 @@ default:lava_flowing 255 100 0
8492
default:lava_source 255 100 0
8593
default:leaves 34 52 29
8694
default:mese 220 220 0
95+
default:mese_post_light 131 102 57
8796
default:meselamp 211 213 139
8897
default:mossycobble 86 90 68
8998
default:obsidian 19 21 24
@@ -105,8 +114,11 @@ default:sapling 65 59 40
105114
default:sign_wall_steel 144 144 144
106115
default:sign_wall_wood 145 101 64
107116
default:silver_sand 193 191 179
108-
default:snow 223 224 236
109-
default:snowblock 223 224 236
117+
default:silver_sandstone 195 192 181
118+
default:silver_sandstone_block 192 190 179
119+
default:silver_sandstone_brick 190 188 178
120+
default:snow 224 225 238
121+
default:snowblock 224 225 238
110122
default:steelblock 194 194 194
111123
default:stone 97 94 93
112124
default:stone_block 99 96 95
@@ -116,7 +128,9 @@ default:stone_with_diamond 97 94 93
116128
default:stone_with_gold 97 94 93
117129
default:stone_with_iron 97 94 93
118130
default:stone_with_mese 97 94 93
131+
default:stone_with_tin 97 94 93
119132
default:stonebrick 99 96 95
133+
default:tinblock 149 149 149
120134
default:torch 120 98 67
121135
default:torch_ceiling 120 98 67
122136
default:torch_wall 120 98 67
@@ -190,10 +204,6 @@ flowers:tulip 130 99 36
190204
flowers:viola 106 60 159
191205
flowers:waterlily 102 158 61
192206

193-
# nyancat
194-
nyancat:nyancat 198 111 167
195-
nyancat:nyancat_rainbow 123 100 94
196-
197207
# stairs
198208
stairs:slab_acacia_wood 146 60 37
199209
stairs:slab_aspen_wood 209 198 169
@@ -202,10 +212,14 @@ stairs:slab_bronzeblock 185 110 15
202212
stairs:slab_cobble 88 84 82
203213
stairs:slab_copperblock 192 126 63
204214
stairs:slab_desert_cobble 146 95 76
215+
stairs:slab_desert_sandstone 195 152 92
216+
stairs:slab_desert_sandstone_block 192 151 94
217+
stairs:slab_desert_sandstone_brick 191 151 94
205218
stairs:slab_desert_stone 129 79 60
206219
stairs:slab_desert_stone_block 130 79 60
207220
stairs:slab_desert_stonebrick 129 79 60
208221
stairs:slab_goldblock 230 201 29
222+
stairs:slab_ice 167 206 247
209223
stairs:slab_junglewood 54 37 11
210224
stairs:slab_mossycobble 86 90 68
211225
stairs:slab_obsidian 19 21 24
@@ -215,6 +229,10 @@ stairs:slab_pine_wood 221 184 128
215229
stairs:slab_sandstone 197 193 143
216230
stairs:slab_sandstone_block 195 190 141
217231
stairs:slab_sandstonebrick 193 189 140
232+
stairs:slab_silver_sandstone 195 192 181
233+
stairs:slab_silver_sandstone_block 192 190 179
234+
stairs:slab_silver_sandstone_brick 190 188 178
235+
stairs:slab_snowblock 224 225 238
218236
stairs:slab_steelblock 194 194 194
219237
stairs:slab_stone 97 94 93
220238
stairs:slab_stone_block 99 96 95
@@ -228,10 +246,14 @@ stairs:stair_bronzeblock 185 110 15
228246
stairs:stair_cobble 88 84 82
229247
stairs:stair_copperblock 192 126 63
230248
stairs:stair_desert_cobble 146 95 76
249+
stairs:stair_desert_sandstone 195 152 92
250+
stairs:stair_desert_sandstone_block 192 151 94
251+
stairs:stair_desert_sandstone_brick 191 151 94
231252
stairs:stair_desert_stone 129 79 60
232253
stairs:stair_desert_stone_block 130 79 60
233254
stairs:stair_desert_stonebrick 129 79 60
234255
stairs:stair_goldblock 230 201 29
256+
stairs:stair_ice 167 206 247
235257
stairs:stair_junglewood 54 37 11
236258
stairs:stair_mossycobble 86 90 68
237259
stairs:stair_obsidian 19 21 24
@@ -241,6 +263,10 @@ stairs:stair_pine_wood 221 184 128
241263
stairs:stair_sandstone 197 193 143
242264
stairs:stair_sandstone_block 195 190 141
243265
stairs:stair_sandstonebrick 193 189 140
266+
stairs:stair_silver_sandstone 195 192 181
267+
stairs:stair_silver_sandstone_block 192 190 179
268+
stairs:stair_silver_sandstone_brick 190 188 178
269+
stairs:stair_snowblock 224 225 238
244270
stairs:stair_steelblock 194 194 194
245271
stairs:stair_stone 97 94 93
246272
stairs:stair_stone_block 99 96 95

0 commit comments

Comments
 (0)
Please sign in to comment.