73
74
75
76
77
78
79
80
81
82
83
84
85
86
...
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
...
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
...
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
...
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
...
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
|
local name = wand.wood .. 'wood wand'
if wand.core ~= nil then name = wand.core .. '-core ' .. name end
if full then
if wand.gem ~= nil then name = wand.gem .. ' ' .. name end
if wand.wire ~= nil then name = wand.wire .. 'clad ' .. name end
end
return u.str.capitalize(name)
end;
wear = function(item)
local meta = item:get_meta()
local spell = meta:get_string('sorcery_wand_spell')
local proto = sorcery.wands.util.getproto(item)
if spell == "" then return 0 end
................................................................................
if kind.gem then
img.gem = u.image('sorcery_wand_' .. kind.gem .. '_tip.png')
img.whole = img.gem:blit(img.whole)
end
return img
end
local createstand = function(name, desc, tex, extra)
local hitbox = {
type = "fixed";
fixed = {
-0.5, -0.5, -0.3;
0.5, -0.1, 0.3;
};
}
................................................................................
sunlight_propagates = true;
paramtype = 'light';
paramtype2 = 'facedir';
tiles = images;
selection_box = hitbox;
collision_box = hitbox;
use_texture_alpha = true;
groups = {
sorcery_wand_stand = 1;
choppy = 2;
oddly_breakable_by_hand = 2;
};
}
minetest.register_node(name, u.tbl.merge(auto,extra))
end
for woodname, wood in pairs(sorcery.wands.materials.wood) do
local blank = u.image('doors_blank.png'); -- haaaaack
local name = 'sorcery:wand_stand_' .. woodname
createstand(name ,
u.str.capitalize(woodname .. 'wood wand stand'),
{ wood.tex; blank; blank; blank; }, {
on_construct = function(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
inv:set_size('wand', 1)
end;
on_rightclick = function(pos,node,user,stack)
local meta = minetest.get_meta(pos)
local stand = meta:get_inventory()
if minetest.get_item_group(stack:get_name(), 'sorcery_wand') ~= 0 then
stand:set_stack('wand',1,stack)
minetest.swap_node(pos, {
name = sorcery.wands.util.baseid(stack:get_definition()._proto) .. '_stand_' .. woodname;
param2 = node.param2;
})
stack = ItemStack(nil)
end
return stack
end
}
)
local plank = wood.plank or 'default:' .. woodname .. '_wood'
minetest.register_craft {
recipe = {
................................................................................
local gemimg = u.image('default_diamond_block.png')
if kind.gem
then gemimg = gemimg:multiply(u.color(sorcery.wands.materials.gem[kind.gem].tone))
else gemimg = gemimg:fade(1) end
createstand(
kind.id .. '_stand_' .. woodname,
u.str.capitalize(woodname) .. 'wood wand stand with ' .. string.lower(sorcery.wands.util.basename(kind,true)), {
wood.tex;
sorcery.wands.materials.wood[kind.wood].tex;
gemimg;
(kind.wire and sorcery.wands.materials.wire[kind.wire].tex) or u.image('doors_blank.png'); -- haaaaack
}, {
drop = 'sorcery:wand_stand_' .. woodname;
after_dig_node = function(pos,node,meta,digger)
local stack = meta.inventory.wand[1]
if stack and not stack:is_empty() then
-- luv 2 defensive coding
minetest.add_item(pos, stack)
................................................................................
else goto failure end
end
stand:set_stack('wand',1,ItemStack(nil))
minetest.swap_node(pos, {
name = 'sorcery:wand_stand_' .. woodname;
param2 = node.param2;
})
::failure:: return stack
end;
}
)
end
end
sorcery.wands.createkind = function(kind)
if sorcery.wands.kinds[kind.id] then return false end
................................................................................
local update_wand_description = function(stack)
local proto = sorcery.wands.util.getproto(stack)
local wm = stack:get_meta()
local spell = wm:get_string('sorcery_wand_spell')
if spell ~= "" then
local sd = sorcery.data.spells[spell]
wm:set_string('description', u.ui.tooltip {
title = u.str.capitalize(sd.name) .. ' wand';
desc = sorcery.wands.util.basedesc(proto);
props = {
{ color = u.color(sd.color); desc = sd.desc }
};
})
else
wm:set_string('description', u.ui.tooltip {
|
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
>
>
|
>
>
|
>
>
|
|
|
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
...
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
...
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
...
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
...
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
...
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
|
local name = wand.wood .. 'wood wand'
if wand.core ~= nil then name = wand.core .. '-core ' .. name end
if full then
if wand.gem ~= nil then name = wand.gem .. ' ' .. name end
if wand.wire ~= nil then name = wand.wire .. 'clad ' .. name end
end
return u.str.capitalize(name)
end;
fullname = function(stack)
local proto = sorcery.wands.util.getproto(stack)
local wm = stack:get_meta()
local spell = wm:get_string('sorcery_wand_spell')
if spell ~= '' then
local sd = sorcery.data.spells[spell]
return u.str.capitalize(sd.name) .. ' wand';
else
return sorcery.wands.util.basename(proto)
end
end;
wear = function(item)
local meta = item:get_meta()
local spell = meta:get_string('sorcery_wand_spell')
local proto = sorcery.wands.util.getproto(item)
if spell == "" then return 0 end
................................................................................
if kind.gem then
img.gem = u.image('sorcery_wand_' .. kind.gem .. '_tip.png')
img.whole = img.gem:blit(img.whole)
end
return img
end
local createstand = function(name, wood, desc, tex, extra)
local hitbox = {
type = "fixed";
fixed = {
-0.5, -0.5, -0.3;
0.5, -0.1, 0.3;
};
}
................................................................................
sunlight_propagates = true;
paramtype = 'light';
paramtype2 = 'facedir';
tiles = images;
selection_box = hitbox;
collision_box = hitbox;
use_texture_alpha = true;
_proto = {
wood = wood;
};
groups = {
sorcery_wand_stand = 1;
choppy = 2;
oddly_breakable_by_hand = 2;
};
}
minetest.register_node(name, u.tbl.merge(auto,extra))
end
local update_stand_info = function(pos)
local woodname = minetest.registered_nodes[minetest.get_node(pos).name]._proto.wood
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if inv:is_empty('wand') then
meta:set_string('infotext',u.str.capitalize(woodname) .. ' wand stand')
else
local stack = inv:get_stack('wand',1)
local spell = stack:get_meta():get_string('sorcery_wand_spell')
local color = u.color(127,127,127)
if spell ~= '' then
color = u.color(sorcery.data.spells[spell].color):readable()
end
local wand_proto = sorcery.wands.util.getproto(stack)
meta:set_string('infotext',color:fmt(sorcery.wands.util.fullname(stack) .. ' stand'))
end
end
for woodname, wood in pairs(sorcery.wands.materials.wood) do
local blank = u.image('sorcery_transparent.png'); -- haaaaack
local name = 'sorcery:wand_stand_' .. woodname
createstand(name, woodname,
u.str.capitalize(woodname .. 'wood wand stand'),
{ wood.tex; blank; blank; blank; }, {
on_construct = function(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
inv:set_size('wand', 1)
update_stand_info(pos)
end;
on_rightclick = function(pos,node,user,stack)
local meta = minetest.get_meta(pos)
local stand = meta:get_inventory()
local wand_proto = sorcery.wands.util.getproto(stack)
if minetest.get_item_group(stack:get_name(), 'sorcery_wand') ~= 0 then
stand:set_stack('wand',1,stack)
minetest.swap_node(pos, {
name = sorcery.wands.util.baseid(wand_proto) .. '_stand_' .. woodname;
param2 = node.param2;
})
stack = ItemStack(nil)
end
update_stand_info(pos)
return stack
end
}
)
local plank = wood.plank or 'default:' .. woodname .. '_wood'
minetest.register_craft {
recipe = {
................................................................................
local gemimg = u.image('default_diamond_block.png')
if kind.gem
then gemimg = gemimg:multiply(u.color(sorcery.wands.materials.gem[kind.gem].tone))
else gemimg = gemimg:fade(1) end
createstand(
kind.id .. '_stand_' .. woodname,
woodname,
u.str.capitalize(woodname) .. 'wood wand stand with ' .. string.lower(sorcery.wands.util.basename(kind,true)), {
wood.tex;
sorcery.wands.materials.wood[kind.wood].tex;
gemimg;
(kind.wire and sorcery.wands.materials.wire[kind.wire].tex) or u.image('sorcery_transparent.png'); -- haaaaack
}, {
drop = 'sorcery:wand_stand_' .. woodname;
after_dig_node = function(pos,node,meta,digger)
local stack = meta.inventory.wand[1]
if stack and not stack:is_empty() then
-- luv 2 defensive coding
minetest.add_item(pos, stack)
................................................................................
else goto failure end
end
stand:set_stack('wand',1,ItemStack(nil))
minetest.swap_node(pos, {
name = 'sorcery:wand_stand_' .. woodname;
param2 = node.param2;
})
::failure::
update_stand_info(pos)
return stack
end;
}
)
end
end
sorcery.wands.createkind = function(kind)
if sorcery.wands.kinds[kind.id] then return false end
................................................................................
local update_wand_description = function(stack)
local proto = sorcery.wands.util.getproto(stack)
local wm = stack:get_meta()
local spell = wm:get_string('sorcery_wand_spell')
if spell ~= "" then
local sd = sorcery.data.spells[spell]
wm:set_string('description', u.ui.tooltip {
title = sorcery.wands.util.fullname(stack);
desc = sorcery.wands.util.basedesc(proto);
props = {
{ color = u.color(sd.color); desc = sd.desc }
};
})
else
wm:set_string('description', u.ui.tooltip {
|