Skip to content

Commit

Permalink
lord-server#267 Update MTG/default: upd torches
Browse files Browse the repository at this point in the history
  • Loading branch information
alek13 committed Apr 7, 2021
1 parent e72f2ea commit 9014984
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 146 deletions.
1 change: 1 addition & 0 deletions mods/_minetest_game/default/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@ dofile(default_path.."/trees.lua")

dofile(default_path.."/chests.lua")
dofile(default_path.."/furnace.lua")
dofile(default_path.."/torch.lua")

lord.mod_loaded()
35 changes: 0 additions & 35 deletions mods/_minetest_game/default/nodes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -948,41 +948,6 @@ minetest.register_node("default:lava_source", {
groups = { lava = 3, liquid = 2, hot = 3, igniter = 1 },
})

minetest.register_node("default:torch", {
description = SL("Torch"),
drawtype = "torchlike",
tiles = {
{
name = "default_torch_on_floor_animated.png",
animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.0 }
},
{
name = "default_torch_on_ceiling_animated.png",
animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.0 }
},
{
name = "default_torch_animated.png",
animation = { type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.0 }
}
},
inventory_image = "default_torch_on_floor.png",
wield_image = "default_torch_on_floor.png",
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
is_ground_content = false,
walkable = false,
light_source = LIGHT_MAX - 1,
selection_box = {
type = "wallmounted",
wall_top = { -0.1, 0.5 - 0.6, -0.1, 0.1, 0.5, 0.1 },
wall_bottom = { -0.1, -0.5, -0.1, 0.1, -0.5 + 0.6, 0.1 },
wall_side = { -0.5, -0.3, -0.1, -0.5 + 0.3, 0.3, 0.1 },
},
groups = { choppy = 2, dig_immediate = 3, flammable = 1, attached_node = 1, hot = 2, wooden = 1 },
legacy_wallmounted = true,
sounds = default.node_sound_defaults(),
})

minetest.register_node("default:sign_wall", {
description = SL("Sign"),
Expand Down
157 changes: 157 additions & 0 deletions mods/_minetest_game/default/torch.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
-- default/torch.lua

-- support for MT game translation.
local S = default.get_translator

local function on_flood(pos, oldnode, newnode)
minetest.add_item(pos, ItemStack("default:torch 1"))
-- Play flame-extinguish sound if liquid is not an 'igniter'
local nodedef = minetest.registered_items[newnode.name]
if not (nodedef and nodedef.groups and
nodedef.groups.igniter and nodedef.groups.igniter > 0) then
minetest.sound_play(
"default_cool_lava",
{pos = pos, max_hear_distance = 16, gain = 0.1},
true
)
end
-- Remove the torch node
return false
end

minetest.register_node("default:torch", {
description = S("Torch"),
drawtype = "mesh",
mesh = "torch_floor.obj",
inventory_image = "default_torch_on_floor.png",
wield_image = "default_torch_on_floor.png",
tiles = {{
name = "default_torch_on_floor_animated.png",
animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
}},
use_texture_alpha = "clip",
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
walkable = false,
liquids_pointable = false,
light_source = 12,
groups = {choppy=2, dig_immediate=3, flammable=1, attached_node=1, torch=1},
drop = "default:torch",
selection_box = {
type = "wallmounted",
wall_bottom = {-1/8, -1/2, -1/8, 1/8, 2/16, 1/8},
},
sounds = default.node_sound_wood_defaults(),
on_place = function(itemstack, placer, pointed_thing)
local under = pointed_thing.under
local node = minetest.get_node(under)
local def = minetest.registered_nodes[node.name]
if def and def.on_rightclick and
not (placer and placer:is_player() and
placer:get_player_control().sneak) then
return def.on_rightclick(under, node, placer, itemstack,
pointed_thing) or itemstack
end

local above = pointed_thing.above
local wdir = minetest.dir_to_wallmounted(vector.subtract(under, above))
local fakestack = itemstack
if wdir == 0 then
fakestack:set_name("default:torch_ceiling")
elseif wdir == 1 then
fakestack:set_name("default:torch")
else
fakestack:set_name("default:torch_wall")
end

itemstack = minetest.item_place(fakestack, placer, pointed_thing, wdir)
itemstack:set_name("default:torch")

return itemstack
end,
floodable = true,
on_flood = on_flood,
on_rotate = false
})

minetest.register_node("default:torch_wall", {
drawtype = "mesh",
mesh = "torch_wall.obj",
tiles = {{
name = "default_torch_on_floor_animated.png",
animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
}},
use_texture_alpha = "clip",
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
walkable = false,
light_source = 12,
groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1},
drop = "default:torch",
selection_box = {
type = "wallmounted",
wall_side = {-1/2, -1/2, -1/8, -1/8, 1/8, 1/8},
},
sounds = default.node_sound_wood_defaults(),
floodable = true,
on_flood = on_flood,
on_rotate = false
})

minetest.register_node("default:torch_ceiling", {
drawtype = "mesh",
mesh = "torch_ceiling.obj",
tiles = {{
name = "default_torch_on_floor_animated.png",
animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
}},
use_texture_alpha = "clip",
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
walkable = false,
light_source = 12,
groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1},
drop = "default:torch",
selection_box = {
type = "wallmounted",
wall_top = {-1/8, -1/16, -5/16, 1/8, 1/2, 1/8},
},
sounds = default.node_sound_wood_defaults(),
floodable = true,
on_flood = on_flood,
on_rotate = false
})

minetest.register_lbm({
name = "default:3dtorch",
nodenames = {"default:torch", "torches:floor", "torches:wall"},
action = function(pos, node)
if node.param2 == 0 then
minetest.set_node(pos, {name = "default:torch_ceiling",
param2 = node.param2})
elseif node.param2 == 1 then
minetest.set_node(pos, {name = "default:torch",
param2 = node.param2})
else
minetest.set_node(pos, {name = "default:torch_wall",
param2 = node.param2})
end
end
})

minetest.register_craft({
output = "default:torch 4",
recipe = {
{"default:coal_lump"},
{"group:stick"},
}
})

minetest.register_craft({
type = "fuel",
recipe = "default:torch",
burntime = 4,
})
111 changes: 0 additions & 111 deletions mods/_various/torches/mt_style.lua
Original file line number Diff line number Diff line change
@@ -1,116 +1,5 @@
local SL = lord.require_intllib()

minetest.register_craftitem(":default:torch", {
description = SL("Torch"),
groups = {wooden = 1},
inventory_image = "default_torch_on_floor.png",
wield_image = "default_torch_on_floor.png",
wield_scale = {x = 1, y = 1, z = 1 + 1/16},
liquids_pointable = false,
on_place = function(itemstack, placer, pointed_thing)
local above = pointed_thing.above
local under = pointed_thing.under
local nu = minetest.get_node(under)
if minetest.registered_nodes[nu.name].on_rightclick then
return minetest.registered_nodes[nu.name].on_rightclick(under, nu, placer, itemstack)
end
local wdir = minetest.dir_to_wallmounted({x = under.x - above.x, y = under.y - above.y, z = under.z - above.z})
if wdir < 1 and not torches.enable_ceiling then
return itemstack
end
local fakestack = itemstack
local retval
if wdir <= 1 then
retval = fakestack:set_name("torches:floor")
else
retval = fakestack:set_name("torches:wall")
end
if not retval then
return itemstack
end
-- Использовалась пер. dir, но она не объявлена
itemstack = minetest.item_place(fakestack, placer, pointed_thing, nil --[[dir]])
itemstack:set_name("default:torch")

return itemstack
end
})

minetest.register_node("torches:floor", {
description = "Torch",
inventory_image = "default_torch_on_floor.png",
wield_image = "default_torch_on_floor.png",
wield_scale = {x = 1, y = 1, z = 1 + 1/16},
drawtype = "mesh",
mesh = "torch_floor.obj",
tiles = {
{
name = "default_torch_on_floor_animated.png",
animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
}
},
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
walkable = false,
light_source = 13,
groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1},
drop = "default:torch",
selection_box = {
type = "wallmounted",
wall_top = {-1/16, -2/16, -1/16, 1/16, 0.5, 1/16},
wall_bottom = {-1/16, -0.5, -1/16, 1/16, 2/16, 1/16},
},
})

minetest.register_node("torches:wall", {
inventory_image = "default_torch_on_floor.png",
wield_image = "default_torch_on_floor.png",
wield_scale = {x = 1, y = 1, z = 1 + 1/16},
drawtype = "mesh",
mesh = "torch_wall.obj",
tiles = {
{
name = "default_torch_on_floor_animated.png",
animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
}
},
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
walkable = false,
light_source = 13,
groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1},
drop = "default:torch",
selection_box = {
type = "wallmounted",
wall_top = {-0.1, -0.1, -0.1, 0.1, 0.5, 0.1},
wall_bottom = {-0.1, -0.5, -0.1, 0.1, 0.1, 0.1},
wall_side = {-0.5, -0.3, -0.1, -0.2, 0.3, 0.1},
},
})

-- convert old torches and remove ceiling placed
minetest.register_abm({
nodenames = {"default:torch"},
interval = 1,
chance = 1,
action = function(pos)
local n = minetest.get_node(pos)
local def = minetest.registered_nodes[n.name]
if n and def then
local wdir = n.param2
local node_name = "torches:wall"
if wdir < 1 and not torches.enable_ceiling then
minetest.remove_node(pos)
return
elseif wdir <= 1 then
node_name = "torches:floor"
end
minetest.set_node(pos, {name = node_name, param2 = wdir})
end
end
})


if minetest.get_modpath("lottother") then
Expand Down

0 comments on commit 9014984

Please sign in to comment.