--[[ Register the question mark node ]] do local nodedef = { description = S("Surprise block"), tiles = { { name = "tsm_surprise_question_anim.png", animation = { type = "vertical_frames", aspect_w=16, aspect_h=16, length=2.0 } } }, drop = "", groups = { cracky=3, }, after_destruct = function (pos, oldnode) local drops = treasurer.select_random_treasures(1,0,3) for _,item in ipairs(drops) do local count, name if type(item) == "string" then name, count = item:match("^([a-zA-Z0-9_:]*) ([0-9]*)$") if not name then name = item end if not count then count = 1 end else count = item:get_count() name = item:get_name() end if not inv or not inv:contains_item("main", ItemStack(name)) then for i=1,count do local obj = minetest.env:add_item(pos, name) if obj ~= nil then obj:get_luaentity().collect = true local x = math.random(1, 5) if math.random(1,2) == 1 then x = -x end local z = math.random(1, 5) if math.random(1,2) == 1 then z = -z end obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z}) end end end end end, } minetest.register_node("tsm_surprise:question",nodedef) end