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