function p.__get_is_solid() return true end
function p.__get_tex() return "block_room" end

--The "health" variable of the block
--determines how many blocks are generated.
function p.__main()
    set_default_block("e")
    local level = get_level() --Identical to "get_input_path_length".
    local health = get_input_path_block_i(level, "health")
    --
    local frac = health / 10.0
    for x = 0,15 do
    for y = 0,15 do
    for z = 0,15 do
        if( randf() < frac ) then
            set_pos(x,y,z, "r_room")
        end
    end end end
end

function p.__type_init(id)
    ia_block_new_var_i(id, "health", 10)
end

function p.__get_can_use(level, bp)
    return true
end

function p.__get_use_msg(level, bp)
    local health = ga_block_get_i(level, bp, "health")
    return "Health: " .. tostring(health)
end

function p.__on_use(level, bp)
    local health = ga_block_get_i(level, bp, "health")
    if( health <= 0 ) then return end
    health = health - 1
    ga_block_set_i(level, bp, "health", health)
    -- --
    ga_play_sound("gold")
end

function p.__on_use2(level, bp)
    local health = ga_block_get_i(level, bp, "health")
    if( health >= 10 ) then return end
    health = health + 1
    ga_block_set_i(level, bp, "health", health)
    -- --
    ga_play_sound("gold")
end
