123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- void_chest = {
- show_particles = (minetest.settings:get("void_chest.show_particles") ~= "false")
- }
- minetest.register_node("void_chest:void_chest", {
- description = "" ..core.colorize("#660099","Void Chest\n") ..core.colorize("#FFFFFF", "Use the power of the void to store your items."),
- tiles = {"void_chest_top.png", "void_chest_top.png", "void_chest_side.png",
- "void_chest_side.png", "void_chest_side.png", "void_chest_front.png"},
- paramtype2 = "facedir",
- groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,},
- legacy_facedir_simple = true,
- sounds = default.node_sound_wood_defaults(),
- on_construct = function(pos)
- if void_chest.show_particles then
- local timer = minetest.get_node_timer(pos)
- timer:start(.1)
- end
- local meta = minetest.get_meta(pos)
- meta:set_string("formspec",
- "size[8,9]"..
- default.gui_bg ..
- default.gui_bg_img ..
- default.gui_slots ..
- "list[current_player;void_chest:void_chest;0,0.0;16,8;]"..
- "list[current_player;main;0,9.0;16,2;]" ..
- "list[current_player;main;0,9.0;0,16;1]" ..
- "listring[current_player;void_chest:void_chest]" ..
- "listring[current_player;main]" ..
- default.get_hotbar_bg(0,9.0))
- meta:set_string("infotext", "Void Chest")
- end,
- on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
- minetest.log("action", player:get_player_name()..
- " moves stuff in void chest at "..minetest.pos_to_string(pos))
- end,
- on_metadata_inventory_put = function(pos, listname, index, stack, player)
- minetest.log("action", player:get_player_name()..
- " moves stuff to void chest at "..minetest.pos_to_string(pos))
- end,
- on_metadata_inventory_take = function(pos, listname, index, stack, player)
- minetest.log("action", player:get_player_name()..
- " takes stuff from void chest at "..minetest.pos_to_string(pos))
- end,
- on_timer = function(pos)
- if void_chest.show_particles then
-
- for i=1,2 do
- local spin_speed = math.random(80,175)/1000
- local vel_scalar = math.random(0,5)/10
- local accel_scalar = math.random(1,5)/10
- local expir = math.random(1,5)
- local particle_pos = {x=pos.x + ((math.random(-15,15)/10)*(math.random(6,15)/10)), y=pos.y + ((math.random(-15,15)/10)*(math.random(6,15)/10)), z=pos.z+ ((math.random(-15,15)/10)*(math.random(6,15)/10))}
- local part_vel = vector.direction(particle_pos, pos)
- part_vel = {x= vel_scalar*part_vel.x, y= vel_scalar*part_vel.y, z= vel_scalar*part_vel.z}
- local part_accel = vector.direction(particle_pos, pos)
- part_accel = {x= accel_scalar*part_accel.x, y= accel_scalar*part_accel.y, z= accel_scalar*part_accel.z}
- minetest.add_particle({
- pos = particle_pos,
- velocity = part_vel,
- acceleration = part_accel,
- expirationtime = expir,
- size = math.random(5,15)/10,
- collisiondetection = true,
- collision_removal = true,
- vertical = false,
- texture = "void_chest_void_particle.png",
- animation = {
- type = "vertical_frames",
- aspect_w = 16,
- aspect_h = 16,
- length = spin_speed,
- },
- glow = 5,
- })
- end
- end
- return true
- end,
- })
- if minetest.get_modpath("magic_materials") then
- minetest.register_craft({
- output = 'void_chest:void_chest',
- recipe = {
- {'default:steelblock','magic_materials:void_rune','default:steelblock'},
- {'magic_materials:void_rune','default:chest_locked','magic_materials:void_rune'},
- {'default:steelblock','magic_materials:void_rune','default:steelblock'}
- }
- })
- else
- minetest.register_craft({
- output = 'void_chest:void_chest',
- recipe = {
- {'default:stone','default:coalblock','default:stone'},
- {'default:coalblock','default:furnace','default:coalblock'},
- {'default:stone','default:coalblock','default:stone'}
- }
- })
- end
- minetest.register_on_joinplayer(function(player)
- local inv = player:get_inventory()
- inv:set_size("void_chest:void_chest", 16*11)
- end)
|