diff --git a/README.txt b/README.txt index 8b8441c..8d235ef 100644 --- a/README.txt +++ b/README.txt @@ -1,52 +1,56 @@ Minetest mod "Torches" ====================== -version: 2.1 +Version: 3.0 -License of source code and textures: WTFPL ------------------------------------------- (c) Copyright BlockMen (2013-2015) +About this mod: +~~~~~~~~~~~~~~~ +This mod adds two different styles of 3D torches to Minetest, by default in Minetest style (flames are animated textures). +The second style is Minecraft like, so flames are "animated" by using particles + +Minetest styled: +Those torches use the same textures as the 2D torch, so its fully compatible with Texture Packs. By default ceiling torches +are removed and cannot be placed aswell. You can change this behavior by adding "torches_enable_ceiling = true" to your minetest.conf +Furthermore this style is more server traffic friendly, so it is enabled by default + +Minecraft styled: +Those torches have a non-animated texture and needs to be supported by Texture Packs (currently most don't support this mod). +"Animation" is done like in Minecraft with particles, which cause (in the current implementation in the Minetest engine) +some amount of traffic and can cause lags at slow connections. The rate and distance when particles are send is configurable +in the first lines of "mc_style.lua". Enable this style by adding "torches_style = minecraft" to your minetest.conf. Note that +the ceiling setting is ignored with this style. + +More informations: +Both styles convert existing torches to the new style. Keep in mind that by default ceiling torches get removed! + + +License: +~~~~~~~~ +(c) Copyright BlockMen (2013-2015) + +Code: +WTFPL This program is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See http://sam.zoy.org/wtfpl/COPYING for more details. - -Using the mod: --------------- -This mod adds 3D torches to Minetest. They also have "real" flames and look much more realistic. -Notice: Already placed old torches will be converted to new, ceiling placed will be removed +Textures and Meshes/Models: +CC-BY 3.0 BlockMen -!! Warning: Extensive use (like a few dozen per mapblock [16x16x16 nodes]) can slowdown servers. +Github: +~~~~~~~ +https://github.com/BlockMen/torches + +Forum: +~~~~~~ +https://forum.minetest.net/viewtopic.php?id=6099 Changelog: ----------- -- Torches on wall dont fall when node under it is dug -- Torches fall directly when not placed on floor or wall -- fixed different placing bugs - -1.3: -- Torches only show flames when player is near (13 blocks) -- Old torches are converted to new, ceiling torches are dropped - -1.3.1: -- fix dropping torches when digging a block next to it -- all torches attached to a block get droped when dug - -1.3.2: -- fix crashes by unknown nodes - -2.0: -- Use new mesh drawtype to improve wallmounted torches -- Update particle usage -- New textures; flame texture fix by Yepoleb -- Fix for doors, chests, etc (rightclick support) - -2.1 -- Fix wallmounted torch mesh -- Clean up code, use wallmounted paramtype2 -- Fix torches being placeable on ceilings (reported by kilbith) +~~~~~~~~~~ +see changelog.txt diff --git a/changelog.txt b/changelog.txt new file mode 100644 index 0000000..525331b --- /dev/null +++ b/changelog.txt @@ -0,0 +1,34 @@ +Changelog: +---------- +1.1 - 1.2.x: +- Torches on wall dont fall when node under it is dug +- Torches fall directly when not placed on floor or wall +- fixed different placing bugs + +1.3: +- Torches only show flames when player is near (13 blocks) +- Old torches are converted to new, ceiling torches are dropped + +1.3.1: +- fix dropping torches when digging a block next to it +- all torches attached to a block get droped when dug + +1.3.2: +- fix crashes by unknown nodes + +2.0: +- Use new mesh drawtype to improve wallmounted torches +- Update particle usage +- New textures; flame texture fix by Yepoleb +- Fix for doors, chests, etc (rightclick support) + +2.1 +- Fix wallmounted torch mesh +- Clean up code, use wallmounted paramtype2 +- Fix torches being placeable on ceilings (reported by kilbith) + +3.0 +- Minetest style added and used by default +- style can be changed via settings +- using Minetest style allows ceiling torches via settings +- Minetest style supports all texturepacks (as long torch shaped) diff --git a/init.lua b/init.lua index 446c81f..83af8e3 100644 --- a/init.lua +++ b/init.lua @@ -1,201 +1,12 @@ --- Reduce particles send to client if on Server -local SERVER = minetest.is_singleplayer() or false -SERVER = not SERVER -local dur = 2 -if SERVER then - dur = 9 -- lowering sends more pakets to clients and let flames faster disappear (not recommended) +torches = {} +torches.enable_ceiling = minetest.setting_getbool("torches_enable_ceiling") or false +local style = minetest.setting_get("torches_style") + +local modpath = minetest.get_modpath("torches") + +-- load torch definition depending on stlye +if style == "minecraft" then + dofile(modpath.."/mc_style.lua") +else + dofile(modpath.."/mt_style.lua") end - -local VIEW_DISTANCE = 13 -- from what distance (in nodes) flames are send to player/client - --- constants -local rotat = {"I", "FX"} -local particle_def = { - pos = {x = 0, y = 0, z = 0}, - velocity = { x= 0, y = 0, z = 0}, - acceleration = {x = 0, y = 0, z = 0}, - expirationtime = 1, - size = 3.0, - collisiondetection = true, - vertical = false, - texture = "torches_fire_1.png", -} - --- fire particles (flames) -local function add_fire(pos, duration, offset) - if offset then - pos.x = pos.x + offset.x - pos.z = pos.z + offset.z - end - pos.y = pos.y + 0.19 - particle_def.pos = pos - particle_def.expirationtime = duration - particle_def.texture = "torches_fire"..tostring(math.random(1, 2)) ..".png^[transform"..rotat[math.random(1,2)] - minetest.add_particle(particle_def) - - pos.y = pos.y + 0.01 - particle_def.pos = pos - particle_def.texture = "torches_fire"..tostring(math.random(1, 2)) ..".png^[transform"..rotat[math.random(1,2)] - minetest.add_particle(particle_def) -end - --- helper functions -local function player_near(pos) - for _,object in ipairs(minetest.get_objects_inside_radius(pos, VIEW_DISTANCE)) do - if object:is_player() then - return true - end - end - - return false -end - -local function get_offset(wdir) - local z = 0 - local x = 0 - if wdir == 4 then - z = 0.15 - elseif wdir == 2 then - x = 0.15 - elseif wdir == 5 then - z = -0.15 - elseif wdir == 3 then - x = -0.15 - end - return {x = x, y = -0.06, z = z} - -end - --- abms for flames -minetest.register_abm({ - nodenames = {"torches:wand"}, - interval = dur - 1, - chance = 1, - action = function(pos) - if player_near(pos) then - local n = minetest.get_node_or_nil(pos) - local dir = {x = 0, y = 0, z = 0} - if n and n.param2 then - dir = get_offset(n.param2) - end - add_fire(pos, dur - .9, dir) - end - end -}) - -minetest.register_abm({ - nodenames = {"torches:floor"}, - interval = dur - 1, - chance = 1, - action = function(pos) - if player_near(pos) then - add_fire(pos, dur - .9) - end - end -}) - --- 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 - if wdir == 0 then - minetest.remove_node(pos) - elseif wdir == 1 then - minetest.set_node(pos, {name = "torches:floor", param2 = wdir}) - else - minetest.set_node(pos, {name = "torches:wall", param2 = wdir}) - end - end - end -}) - --- Item definitions -minetest.register_craftitem(":default:torch", { - description = "Torch", - inventory_image = "torches_torch.png^[transformR90", - wield_image = "torches_torch.png^[transformR90", - wield_scale = {x = 1, y = 1, z = 1 + 1/16}, - liquids_pointable = false, - on_place = function(itemstack, placer, pointed_thing) - if pointed_thing.type ~= "node" then - return itemstack - end - - local above = pointed_thing.above - local under = pointed_thing.under - local wdir = minetest.dir_to_wallmounted({x = under.x - above.x, y = under.y - above.y, z = under.z - above.z}) - - local fakestack = itemstack - local retval = false - if wdir < 1 then - return itemstack - elseif wdir == 1 then - retval = fakestack:set_name("torches:floor") - else - retval = fakestack:set_name("torches:wall") - end - if not retval then - return itemstack - end - itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir) - itemstack:set_name("default:torch") - - -- add flame if placing was sucessfull - if retval then - -- expect node switch one sever step (default 0.1) delayed - minetest.after(0.1, add_fire, above, dur, get_offset(wdir)) - end - return itemstack - end -}) - -minetest.register_node("torches:floor", { - inventory_image = "default_torch.png", - wield_image = "torches_torch.png", - wield_scale = {x = 1, y = 1, z = 1 + 2/16}, - drawtype = "mesh", - mesh = "torch_floor.obj", - tiles = {"torches_torch.png"}, - paramtype = "light", - paramtype2 = "none", - sunlight_propagates = true, - drop = "default:torch", - walkable = false, - light_source = 13, - groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1}, - legacy_wallmounted = true, - selection_box = { - type = "fixed", - fixed = {-1/16, -0.5, -1/16, 1/16, 2/16, 1/16}, - }, -}) - -minetest.register_node("torches:wall", { - inventory_image = "default_torch.png", - wield_image = "torches_torch.png", - wield_scale = {x = 1, y = 1, z = 1 + 1/16}, - drawtype = "mesh", - mesh = "torch_wall.obj", - tiles = {"torches_torch.png"}, - 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}, - }, -}) - -minetest.register_alias("torches:wand", "torches:wall") diff --git a/mc_style.lua b/mc_style.lua new file mode 100644 index 0000000..f984d67 --- /dev/null +++ b/mc_style.lua @@ -0,0 +1,202 @@ +-- Reduce particles send to client if on Server +local SERVER = minetest.is_singleplayer() or false +SERVER = not SERVER +local dur = 2 +if SERVER then + dur = 9 -- lowering sends more pakets to clients and let flames faster disappear (not recommended) +end + +local VIEW_DISTANCE = 13 -- from what distance (in nodes) flames are send to player/client + +-- constants +local rotat = {"I", "FX"} +local particle_def = { + pos = {x = 0, y = 0, z = 0}, + velocity = { x= 0, y = 0, z = 0}, + acceleration = {x = 0, y = 0, z = 0}, + expirationtime = 1, + size = 3.0, + collisiondetection = true, + vertical = false, + texture = "torches_fire_1.png", +} + +-- fire particles (flames) +local function add_fire(pos, duration, offset) + if offset then + pos.x = pos.x + offset.x + pos.z = pos.z + offset.z + pos.y = pos.y + offset.y + end + pos.y = pos.y + 0.19 + particle_def.pos = pos + particle_def.expirationtime = duration + particle_def.texture = "torches_fire"..tostring(math.random(1, 2)) ..".png^[transform"..rotat[math.random(1,2)] + minetest.add_particle(particle_def) + + pos.y = pos.y + 0.01 + particle_def.pos = pos + particle_def.texture = "torches_fire"..tostring(math.random(1, 2)) ..".png^[transform"..rotat[math.random(1,2)] + minetest.add_particle(particle_def) +end + +-- helper functions +local function player_near(pos) + for _,object in ipairs(minetest.get_objects_inside_radius(pos, VIEW_DISTANCE)) do + if object:is_player() then + return true + end + end + + return false +end + +local function get_offset(wdir) + local z = 0 + local x = 0 + if wdir == 4 then + z = 0.25 + elseif wdir == 2 then + x = 0.25 + elseif wdir == 5 then + z = -0.25 + elseif wdir == 3 then + x = -0.25 + end + return {x = x, y = 0.08, z = z} + +end + +-- abms for flames +minetest.register_abm({ + nodenames = {"torches:wand"}, + interval = dur - 1, + chance = 1, + action = function(pos) + if player_near(pos) then + local n = minetest.get_node_or_nil(pos) + local dir = {x = 0, y = 0, z = 0} + if n and n.param2 then + dir = get_offset(n.param2) + end + add_fire(pos, dur - .9, dir) + end + end +}) + +minetest.register_abm({ + nodenames = {"torches:floor"}, + interval = dur - 1, + chance = 1, + action = function(pos) + if player_near(pos) then + add_fire(pos, dur - .9) + end + end +}) + +-- 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 + if wdir == 0 then + minetest.remove_node(pos) + elseif wdir == 1 then + minetest.set_node(pos, {name = "torches:floor", param2 = wdir}) + else + minetest.set_node(pos, {name = "torches:wall", param2 = wdir}) + end + end + end +}) + +-- Item definitions +minetest.register_craftitem(":default:torch", { + description = "Torch", + inventory_image = "torches_torch.png", + wield_image = "torches_torch.png", + wield_scale = {x = 1, y = 1, z = 1 + 1/16}, + liquids_pointable = false, + on_place = function(itemstack, placer, pointed_thing) + if pointed_thing.type ~= "node" then + return itemstack + end + + local above = pointed_thing.above + local under = pointed_thing.under + local wdir = minetest.dir_to_wallmounted({x = under.x - above.x, y = under.y - above.y, z = under.z - above.z}) + + local fakestack = itemstack + local retval = false + if wdir < 1 then + return itemstack + elseif wdir == 1 then + retval = fakestack:set_name("torches:floor") + else + retval = fakestack:set_name("torches:wall") + end + if not retval then + return itemstack + end + itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir) + itemstack:set_name("default:torch") + + -- add flame if placing was sucessfull + if retval then + -- expect node switch one sever step (default 0.1) delayed + minetest.after(0.1, add_fire, above, dur, get_offset(wdir)) + end + return itemstack + end +}) + +minetest.register_node("torches:floor", { + inventory_image = "default_torch.png", + wield_image = "torches_torch.png", + wield_scale = {x = 1, y = 1, z = 1 + 2/16}, + drawtype = "mesh", + mesh = "torch_floor.obj", + tiles = {"torches_torch.png"}, + paramtype = "light", + paramtype2 = "none", + sunlight_propagates = true, + drop = "default:torch", + walkable = false, + light_source = 13, + groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1}, + legacy_wallmounted = true, + selection_box = { + type = "fixed", + fixed = {-1/16, -0.5, -1/16, 1/16, 2/16, 1/16}, + }, +}) + +minetest.register_node("torches:wall", { + inventory_image = "default_torch.png", + wield_image = "torches_torch.png", + wield_scale = {x = 1, y = 1, z = 1 + 1/16}, + drawtype = "mesh", + mesh = "torch_wall.obj", + tiles = {"torches_torch.png"}, + 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}, + }, +}) + +minetest.register_alias("torches:wand", "torches:wall") diff --git a/models/torch_floor.obj b/models/torch_floor.obj index 2244249..bb82af5 100644 --- a/models/torch_floor.obj +++ b/models/torch_floor.obj @@ -1,71 +1,48 @@ -# Blender v2.73 (sub 0) OBJ File: '' +# Blender v2.73 (sub 0) OBJ File: 'mt_torch_full_vertices3.blend' # www.blender.org -mtllib torch_floor.mtl -o torch_floor -v -0.060303 -0.491509 0.061268 -v -0.060303 -0.491509 -0.063732 -v 0.064697 -0.491509 -0.063732 -v 0.064697 -0.491509 0.061268 -v 0.064697 0.133491 0.061268 -v -0.060303 0.133491 0.061268 -v 0.064697 0.133491 -0.063732 -v -0.060303 0.133491 -0.063732 -v -0.060303 0.133491 0.061268 -v -0.060303 -0.491509 0.061268 -v -0.060303 -0.491509 -0.063732 -v -0.060303 0.133491 -0.063732 -v 0.064697 -0.491509 -0.063732 -v 0.064697 0.133491 -0.063732 -v 0.064697 -0.491509 0.061268 -v 0.064697 0.133491 0.061268 -vt 0.622957 0.249888 -vt 0.622957 0.125460 -vt 0.747385 0.125460 -vt 0.747385 0.249888 -vt 0.001430 0.562335 -vt 0.001430 0.437907 -vt 0.623570 0.437907 -vt 0.623570 0.562335 -vt 0.622412 0.125460 -vt 0.622412 0.249888 -vt 0.000273 0.249889 -vt 0.000272 0.125460 -vt 0.001430 0.562228 -vt 0.001430 0.437799 -vt 0.623570 0.437799 -vt 0.623570 0.562228 -vt 0.623570 0.562361 -vt 0.001430 0.562362 -vt 0.623548 0.562415 -vt 0.001452 0.437772 -vt 0.623591 0.437987 -vt 0.622412 0.874755 -vt 0.000272 0.874755 -vt 0.000272 0.750327 -vt 0.622412 0.750326 -vt 0.747385 0.499835 -vt 0.622957 0.499835 -vt 0.622957 0.375407 -vt 0.747385 0.375407 -vt 0.624714 0.562308 -vt 0.500286 0.562308 -vt 0.500286 0.437880 -vt 0.624714 0.437880 -vt 0.747385 0.374861 -vt 0.622957 0.374861 -vt 0.622957 0.250433 -vt 0.747385 0.250433 -usemtl None.001 +mtllib mt_torch_full_vertices3.mtl +o Cube_Cube.001 +v 0.061653 -0.496733 0.061674 +v 0.061653 -0.496733 -0.062460 +v -0.059258 -0.496733 0.061674 +v -0.059258 -0.496733 -0.062460 +v -0.059994 -0.497234 0.497315 +v -0.059994 -0.497234 -0.498102 +v -0.059994 0.507706 -0.498102 +v -0.059994 0.507706 0.497315 +v -0.494900 0.507706 0.061709 +v -0.494900 -0.497234 0.061709 +v 0.497295 0.507706 0.061709 +v 0.497295 -0.497234 0.061709 +v 0.062686 0.507706 -0.498102 +v 0.062686 -0.497234 -0.498102 +v 0.062686 0.507706 0.497315 +v 0.062686 -0.497234 0.497315 +v -0.494900 0.507706 -0.063149 +v -0.494900 -0.497234 -0.063149 +v 0.497295 0.507706 -0.063149 +v 0.497295 -0.497234 -0.063149 +v -0.058217 0.134520 0.060216 +v -0.058217 0.135872 -0.061813 +v 0.061944 0.135872 -0.061813 +v 0.061944 0.134520 0.060216 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 0.437500 0.500000 +vt 0.562500 0.500000 +vt 0.562500 0.625000 +vt 0.437541 0.625000 +vt 0.437541 0.000000 +vt 0.562500 0.000000 +vt 0.562500 0.125000 +vt 0.437500 0.125000 +usemtl None s off -f 1/1 2/2 3/3 4/4 -f 1/5 4/6 5/7 6/8 -f 7/9 5/10 4/11 3/12 -f 2/13 1/14 6/15 8/16 -f 8/7 7/17 3/18 2/6 -f 9/19 10/13 11/20 12/21 -f 12/22 11/23 13/24 14/25 -f 14/8 13/5 15/6 16/7 -f 16/8 15/5 10/6 9/7 -f 10/26 15/27 13/28 11/29 -f 16/30 9/31 12/32 14/33 -f 5/34 7/35 8/36 6/37 +f 11/1 9/2 10/3 12/4 +f 22/5 21/6 24/7 23/8 +f 17/2 19/1 20/4 18/3 +f 13/2 15/1 16/4 14/3 +f 3/9 4/10 2/11 1/12 +f 8/1 7/2 6/3 5/4 diff --git a/models/torch_wall.obj b/models/torch_wall.obj index c5a3829..2385563 100644 --- a/models/torch_wall.obj +++ b/models/torch_wall.obj @@ -1,71 +1,48 @@ -# Blender v2.73 (sub 0) OBJ File: '' +# Blender v2.73 (sub 0) OBJ File: 'mt_torch_full_vertices3.blend' # www.blender.org -mtllib torch_wall.mtl -o torch_wall -v 0.061088 -0.475096 -0.371119 -v 0.061088 -0.571653 -0.291735 -v -0.063912 -0.571653 -0.291735 -v -0.063912 -0.475096 -0.371119 -v -0.063913 -0.078178 0.111667 -v 0.061087 -0.078178 0.111667 -v -0.063913 -0.174736 0.191050 -v 0.061087 -0.174736 0.191050 -v 0.061087 -0.078178 0.111667 -v 0.061088 -0.475096 -0.371119 -v 0.061088 -0.571653 -0.291735 -v 0.061087 -0.174736 0.191050 -v -0.063912 -0.571653 -0.291735 -v -0.063913 -0.174736 0.191050 -v -0.063912 -0.475096 -0.371119 -v -0.063913 -0.078178 0.111667 -vt 0.622957 0.249888 -vt 0.622957 0.125460 -vt 0.747385 0.125460 -vt 0.747385 0.249888 -vt 0.001430 0.562335 -vt 0.001430 0.437907 -vt 0.623570 0.437907 -vt 0.623570 0.562335 -vt 0.622412 0.125460 -vt 0.622412 0.249888 -vt 0.000273 0.249889 -vt 0.000272 0.125460 -vt 0.001430 0.562228 -vt 0.001430 0.437799 -vt 0.623570 0.437799 -vt 0.623570 0.562228 -vt 0.623570 0.562361 -vt 0.001430 0.562362 -vt 0.623548 0.562415 -vt 0.001452 0.437772 -vt 0.623591 0.437987 -vt 0.622412 0.874755 -vt 0.000272 0.874755 -vt 0.000272 0.750327 -vt 0.622412 0.750326 -vt 0.747385 0.499835 -vt 0.622957 0.499835 -vt 0.622957 0.375407 -vt 0.747385 0.375407 -vt 0.624714 0.562308 -vt 0.500286 0.562308 -vt 0.500286 0.437880 -vt 0.624714 0.437880 -vt 0.747385 0.374861 -vt 0.622957 0.374861 -vt 0.622957 0.250433 -vt 0.747385 0.250433 +mtllib torch_wall4.mtl +o Cube_Cube.001 +v 0.061653 -0.554493 -0.328908 +v 0.061653 -0.442208 -0.381835 +v -0.059258 -0.554493 -0.328908 +v -0.059258 -0.442208 -0.381835 +v -0.059994 -0.948766 -0.143618 +v -0.059994 -0.048361 -0.568031 +v -0.059994 0.380112 0.340988 +v -0.059994 -0.520293 0.765401 +v -0.494900 -0.126265 0.579672 +v -0.494900 -0.554738 -0.329346 +v 0.497295 -0.126265 0.579672 +v 0.497295 -0.554738 -0.329346 +v 0.062686 0.380112 0.340988 +v 0.062686 -0.048361 -0.568031 +v 0.062686 -0.520293 0.765401 +v 0.062686 -0.948766 -0.143618 +v -0.494900 -0.013324 0.526437 +v -0.494900 -0.441797 -0.382582 +v 0.497295 -0.013324 0.526437 +v 0.497295 -0.441797 -0.382582 +v -0.058217 -0.284029 0.241470 +v -0.058217 -0.173071 0.190665 +v 0.061944 -0.173071 0.190665 +v 0.061944 -0.284029 0.241470 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +vt 1.000000 0.000000 +vt 0.000000 0.000000 +vt 0.437500 0.500000 +vt 0.562500 0.500000 +vt 0.562500 0.625000 +vt 0.437541 0.625000 +vt 0.437541 0.000000 +vt 0.562500 0.000000 +vt 0.562500 0.125000 +vt 0.437500 0.125000 usemtl None s off -f 1/1 2/2 3/3 4/4 -f 1/5 4/6 5/7 6/8 -f 7/9 5/10 4/11 3/12 -f 2/13 1/14 6/15 8/16 -f 8/7 7/17 3/18 2/6 -f 9/19 10/13 11/20 12/21 -f 12/22 11/23 13/24 14/25 -f 14/8 13/5 15/6 16/7 -f 16/8 15/5 10/6 9/7 -f 10/26 15/27 13/28 11/29 -f 16/30 9/31 12/32 14/33 -f 5/34 7/35 8/36 6/37 +f 11/1 9/2 10/3 12/4 +f 22/5 21/6 24/7 23/8 +f 17/2 19/1 20/4 18/3 +f 13/2 15/1 16/4 14/3 +f 3/9 4/10 2/11 1/12 +f 8/1 7/2 6/3 5/4 diff --git a/mt_style.lua b/mt_style.lua new file mode 100644 index 0000000..efda8bc --- /dev/null +++ b/mt_style.lua @@ -0,0 +1,105 @@ +minetest.register_craftitem(":default:torch", { + 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}, + liquids_pointable = false, + on_place = function(itemstack, placer, pointed_thing) + local above = pointed_thing.above + local under = pointed_thing.under + 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 = false + 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 + itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, dir) + itemstack:set_name("default:torch") + + return itemstack + end +}) + +minetest.register_node("torches:floor", { + description = "Torch", + inventory_image = "default_torch.png", + wield_image = "default_torch.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.png", + wield_image = "default_torch.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 +}) diff --git a/textures/torches_torch.png b/textures/torches_torch.png index 60a7285..69c6dc8 100644 Binary files a/textures/torches_torch.png and b/textures/torches_torch.png differ