local world_path = minetest.get_worldpath()
local settings = Settings(world_path.."/assets_warehouse.conf")

model_detail = settings:get("assets_warehouse_model_quality") or 2
texture_detail = settings:get("assets_warehouse_texture_quality") or 2
idioma = settings:get("assets_warehouse_idioma") or "espanol"

local royal_robedescripcion = "A royal robe"
local heavy_hammerdescripcion = "A hammer"
local shirtdescripcion = "A shirt"
local pantsdescripcion = "Pants"
local wesnoth_magic_wanddescripcion = "A wand used by the magicians"
local training_long_sworddescripcion = "Almost like fight whit a feather"
local reinforced_iron_pickdescripcion = "A reincorced pick"
local palareforzadadescripcion = "A reinforced iron shovel"
local destapadordescripcion = "A horn?"
local simple_jacketdescripcion = "A simple jacket"
local barcodepapeldescripcion= "My friend"
local triangular_fencedescripcion = "A normal fence"
local black_tophatdescripcion = "A top hat"
local googlesdescripcion = "Googles"
local BanderadelaUnionSovietica = "Flag of the Soviet Union"
local soviet_ushanka_descripcion = "Soviet hat"

if idioma == "espanol" then
    royal_robedescripcion = "Una bata de la realeza"
    heavy_hammerdescripcion = "Un martillo"
    shirtdescripcion = "Una camisa"
    pantsdescripcion = "Pantalones"
    wesnoth_magic_wanddescripcion = "Una bara usada por los magos"
    training_long_sworddescripcion ="Casi como luchar con una pluma"
    reinforced_iron_pickdescripcion = "Un pico reforzado"
    palareforzadadescripcion = "Una pala reforzada"
    destapadordescripcion = "Un cuerno?"
    simple_jacketdescripcion = "Una chaqueta simple"
    barcodepapeldescripcion = "Mi amigo"
    triangular_fencedescripcion = "Una cerca normal"
    black_tophatdescripcion = "Un sombrero de copa"
    googlesdescripcion = "Gafas"
    BanderadelaUnionSovietica = "BanderadelaUnionSovietica"
    soviet_ushanka_descripcion = "Sombrero sovietico"
end

minetest.log("none","Shirt2")


    

assets_warehousepart2.item("assets_warehousepart2:wesnoth_magic_wand",{
    --wield_mesh ='wesnoth_magic_wandMD'..model_detail..'.obj',
    --wielded_entity = true,
    mesh ='wesnoth_magic_wandMD'..model_detail..'.obj',
    texture = {'wesnoth_magic_wand.png'},
    wield_image = "wesnoth_magic_wand_preview.png",
    --selectionbox ={-0.1,-0.5,-0.1,0.1,0.05,0.1},
    --collisionbox = {-0.1,-0.5,-0.1,0.1,0.05,0.1},
    description = wesnoth_magic_wanddescripcion,
    --atack = "assets_warehouse2:wesnoth_magic_wand_atack",
    
})

assets_warehousepart2:register_attack("assets_warehousepart2:wesnoth_magic_wand_atack", {
    visual = "sprite",
    visual_size = {x = 0.1, y = 0.1},
    textures = {'wesnoth_magic_wand_atack.png'},
    damage = 1,
    lifetime = 4,
    --range = 1,

    -- direct hit
    --hit_player = function(self, player)
    --    player:punch(self.object, 1.0, {
    --        full_punch_interval = 1.0,
    --        damage_groups = {fleshy = 2},
    --    }, nil)
    --end,

    hit_mob = function(self, player)
        player:punch(self.object, 1.0, {
            full_punch_interval = 1.0,
            damage_groups = {fleshy = 5},
        }, nil)
    end,

    hit_node = function(self, pos, node)
    end
})



assets_warehousepart2.item("assets_warehousepart2:heavy_hammer",{
    wield_mesh ='heavy_hammerMD'..model_detail..'.obj',
    wielded_entity = true,
    mesh ='heavy_hammerMD'..model_detail..'.obj',
    texture = {'heavy_hammer.png'},
    wield = "heavy_hammerpreview.png",
    selectionbox ={-0.1,-0.5,-0.1,0.1,0.05,0.1},
    collisionbox = {-0.1,-0.5,-0.1,0.1,0.05,0.1},
    description = heavy_hammerdescripcion,
    atack = "assets_warehouse2:wesnoth_magic_wand_atack",
    
})

assets_warehousepart2.item("assets_warehousepart2:training_long_sword",{
    wield_mesh ='training_long_swordMD'..model_detail..'.obj',
    wielded_entity = true,
    mesh ='training_long_swordMD'..model_detail..'.obj',
    texture = {'training_long_sword.png'},
    wield = "training_long_swordpreview.png",
    selectionbox ={-0.1,-0.5,-0.1,0.1,0.05,0.1},
    collisionbox = {-0.1,-0.5,-0.1,0.1,0.05,0.1},
    description = training_long_sworddescripcion,
    atack = "assets_warehouse2:wesnoth_magic_wand_atack",
    
})

assets_warehousepart2.item("assets_warehousepart2:reinforced_iron_pick",{
    wield_mesh ='reinforced_iron_pickMD'..model_detail..'.obj',
    wielded_entity = true,
    mesh ='reinforced_iron_pickMD'..model_detail..'.obj',
    texture = {'reinforced_iron_pick.png'},
    wield = "reinforced_iron_pickpreview.png",
    selectionbox ={-0.1,-0.5,-0.1,0.1,0.05,0.1},
    collisionbox = {-0.1,-0.5,-0.1,0.1,0.05,0.1},
    description = reinforced_iron_pickdescripcion,
    atack = "assets_warehouse2:wesnoth_magic_wand_atack",
    
})

assets_warehousepart2.item("assets_warehousepart2:pala_de_hierro_reforzada",{
    wield_mesh ='palaMD'..model_detail..'.obj',
    wielded_entity = true,
    mesh ='palaMD'..model_detail..'.obj',
    texture = {'pala.png'},
    wield = "palapreview.png",
    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 = palareforzadadescripcion,
    atack = "assets_warehouse:peppert_and_carrot_sword1_atack",
    custom_function = 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 = 100
        local aceleration = {x=dir.x*power, y=dir.y*power, z=dir.z*power}
        local addinpos = {x=pos.x,y=pos.y+1.5,z=pos.z}
        
        if pointed_thing.type == "node" then
            obj = minetest.add_entity(addinpos,"assets_warehouse:peppert_and_carrot_sword1_atack2")--"assets_warehouse:testatack")
            obj:set_acceleration(aceleration)
            obj:set_yaw(yaw)--math.pi/2)
        else 
            obj = minetest.add_entity(addinpos,"assets_warehouse:peppert_and_carrot_sword1_atack2")--"assets_warehouse:testatack")
            obj:set_acceleration(aceleration)
            obj:set_yaw(yaw)--math.pi/2)
        end
       
    end,
})


minetest.register_entity("assets_warehousepart2:destapador_wielded", {--("assets_warehouse:"..name..name_end, {
    basename = "assets_warehousepart2:destapador_wielded",
    physical = false,
    visual = "mesh",
    visual_size = {x=1,y=1,z=1},
    mesh = 'destapadorMD'..model_detail..'.obj',
    textures = {"destapador.png"},
    backface_culling = false,
    maskforpants = "default_maskforpants.png",
    timer = 0,
    pointable = false,
    cloth_type = "wielded",
    texture_mask = "default_mask.png",
    
})

minetest.register_node('assets_warehousepart2:triangular_fence', {
    drawtype = 'mesh',
    mesh = 'triangularfence.obj',
    tiles ={'normal_fence_woodTQ'..texture_detail..'.png'}, 
    description= triangular_fencedescripcion,
    stack_max = 1,
    groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3},
    paramtype2 = "facedir",
    is_ground_content=true,
    climbable=false,
    buildable_to=false,
    damage_per_second=0,
    diggable=true,
    drowning=0,
    floodable=false,
    range=5.0,
    selection_box = {
        type = "fixed",
        fixed = {
            {-0.5,0.47,-0.1,0.5,-0.5,0.05},		
        },	
    },
    collision_box = {
        type = "fixed",
        fixed = {
            {-0.5,0.47,-0.1,0.5,-0.5,0.05},		
        },	
    },
    paramtype = "light",
    sunlight_propagates=true,
    use_texture_alpha=false,
    walkable=true,
    pointable=true,
})

minetest.register_node('assets_warehousepart2:triangular_fencecorner', {
    drawtype = 'mesh',
    mesh = 'triangularfence_corner.obj',
    tiles ={'normal_fence_woodTQ'..texture_detail..'.png'}, 
    description= triangular_fencedescripcion,
    stack_max = 1,
    groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3},
    paramtype2 = "facedir",
    is_ground_content=true,
    climbable=false,
    buildable_to=false,
    damage_per_second=0,
    diggable=true,
    drowning=0,
    floodable=false,
    range=5.0,
    selection_box = {
        type = "fixed",
        fixed = {
            {-0.1,0.47,-0.1,0.5,-0.5,0.05},	
            {-0.1,0.47,0.0,0.1,-0.5,0.5},		
        },	
    },
    collision_box = {
        type = "fixed",
        fixed = {
            {-0.1,0.47,-0.1,0.5,-0.5,0.05},	
            {-0.1,0.47,0.0,0.1,-0.5,0.5},
        },	
    },
    paramtype = "light",
    sunlight_propagates=true,
    use_texture_alpha=false,
    walkable=true,
    pointable=true,
})



    


minetest.register_node('assets_warehousepart2:BanderadelaUnionSovietica', {
    drawtype = 'mesh',
    mesh = 'BanderadelaUnionSovietica.obj',
    tiles ={'BanderadelaUnionSovietica.png'}, 
    description= BanderadelaUnionSovietica,
    stack_max = 1,
    groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3},
    paramtype2 = "facedir",
    is_ground_content=true,
    climbable=false,
    buildable_to=false,
    damage_per_second=0,
    diggable=true,
    drowning=0,
    floodable=false,
    range=5.0,
    paramtype = "light",
    selection_box = {
        type = "fixed",
        fixed = {
            {-1.5,0.5,0.35,0.5,-0.5,0.5},		
        },	
    },
    collision_box = {
        type = "fixed",
        fixed = {
            {-1.5,0.5,0.45,0.5,-0.5,0.5},
        },	
    },
    sunlight_propagates=true,
    use_texture_alpha=true,
    walkable=true,
    pointable=true,
})



if minetest.get_modpath("aw_personaje_anthro") then
    assets_warehousepart2.sombrero("soviet_ushanka",{'soviet_ushanka.png'},'ushankaMD'..model_detail..'.obj',soviet_ushanka_descripcion,"soviet_ushankapreview.png")
    assets_warehousepart2.sombrero("googles",{"googles.png"},'googlesMD'..model_detail..'.b3d',"googlespreview.png",googlesdescription,"googlepreview.png")
    assets_warehousepart2.sombrero("red_tophat",{'red_tophat.png'},'black_tophatMD'..model_detail..'.obj',black_tophatdescripcion,"red_tophatpreview.png")
    assets_warehousepart2.sombrero("peppert_and_carrot_coriander_hat",{'peppert_and_carrot_coriander_hat.png'},'peppert_and_carrot_coriander_hatMD'..model_detail..'.obj',peppert_and_carrot_coriander_hatdescripcion,"peppert_and_carrot_coriander_hatpreview.png")
    assets_warehousepart2.sombrero("black_tophat",{'black_tophat.png'},'black_tophatMD'..model_detail..'.obj',black_tophatdescripcion,"black_tophatpreview.png")
    assets_warehousepart2.sombrero("destapador",{'destapador.png'},'destapadorclothMD'..model_detail..'.obj',destapadordescripcion,"destapadorpreview.png")
    assets_warehousepart2.ropa("camisa","simple_jacket_red",'simple_jacket_red.png',simple_jacketdescripcion,"simple_jacket_redpreview.png")
    --assets_warehousepart2.ropa("camisa","royal_robe",{'royal_robe.png'},royal_robedescripcion,"royal_robepreview.png")
    assets_warehousepart2.sombrero("bandana",{'bandana.png'},'bandana.obj',"bandana","bandana_preview.png")
end