aw_edificiosdecuba_habana={}

local world_path = minetest.get_worldpath()

local function aw_edificiosdecuba_habana_poneredificio(name)
    minetest.register_tool('aw_edificiosdecuba_habana:'..name, {
        selectionbox ={-0.1,-0.5,-0.1,0.1,1.0,0.1},
        collisionbox = {-0.1,-0.5,-0.1,0.1,1.0,0.1},
        description = name,
        groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3},
        range=5.0,
        inventory_image = "viviendabasica.png",
        
        on_use = function(itemstack, user, pointed_thing)
            local player = user
            local pos = player:get_pos()
            local dir = player:get_look_dir()
            local yaw = player:get_look_horizontal()
            local power = 50
            local controls = player:get_player_control()
            local aceleration = {x=dir.x*power, y=dir.y*power, z=dir.z*power}
            local addinpos = {x=pos.x,y=pos.y,z=pos.z}
            
            
            schematic = minetest.get_modpath("aw_edificiosdecuba_habana") .."/schems/"..name..".mts"
            minetest.place_schematic(pos, schematic, "random",nil,false)
            
            --minetest.place_schematic(pos, schematic, rotation, replacements, force_placement, flags)`
        -- Place the schematic specified by schematic (see [Schematic specifier]) at
        --  `pos`.
        -- `rotation` can equal `"0"`, `"90"`, `"180"`, `"270"`, or `"random"`.
        -- If the `rotation` parameter is omitted, the schematic is not rotated.
        -- `replacements` = `{["old_name"] = "convert_to", ...}`
        -- `force_placement` is a boolean indicating whether nodes other than `air`
        --  and `ignore` are replaced by the schematic.
        -- Returns nil if the schematic could not be loaded.
        --Warning: Once you have loaded a schematic from a file, it will be
        --  cached. Future calls will always use the cached version and the
        --  replacement list defined for it, regardless of whether the file or the
        --  replacement list parameter have changed. The only way to load the file
        --  anew is to restart the server.
        -- `flags` is a flag field with the available flags:
            -- place_center_x
            -- place_center_y
            -- place_center_z
        end,
        
    })
end

aw_edificiosdecuba_habana_poneredificio("viviendacubanatipoA1")
aw_edificiosdecuba_habana_poneredificio("viviendacubanatipoA2")
aw_edificiosdecuba_habana_poneredificio("viviendacubanatipoA3")
aw_edificiosdecuba_habana_poneredificio("viviendacubanatipoA4")


--------------------------------------------------------

local formspec_config = { 
        "formspec_version[4]",
        "size[100,100]",
        "anchor[0.5,0.5]",
        "padding[0.0,0.0]",
        "scrollbaroptions[min=0,max=50,smallstep=10,largestep=20,thumbsize=10,arrows=default]",
        "scrollbar[95,0;5,100;vertical;'testscroll';]",
        "scroll_container[1.10,0.0;90,150;'testscroll';vertical;0.1]",
        
        "textarea[0.5,90.5;90,40;;;I don' speak English,Este mod tiene algunos edificios basados en los de la Habana]",
        "scroll_container_end[]",
}

formspec_config =  table.concat(formspec_config, "")


minetest.register_tool("aw_edificiosdecuba_habana:config_menu", {
    description = "configuration_menu",
    --tiles = "configuration_menu.png",
    inventory_image = "aw_makehuman_logo.png",
    --wield_image = "configuration_menu.png",
    groups = {cracky = 1},
    on_use = function(itemstack, player, pointed_thing)
        local playername = player:get_player_name()
        if pointed_thing.type == "node" then
            minetest.show_formspec(playername, "aw_edificiosdecuba_habana:config_menu",formspec_config) 
        else 
            minetest.show_formspec(playername, "aw_edificiosdecuba_habana:config_menu",formspec_config)    
        end
    end,
    on_receive_fields = function(pos, formname, fields, player)
        if fields.quit then
            return
        end

        print(fields.x)
    end
})


