change some code

This commit is contained in:
HybridDog 2015-11-27 22:45:50 +01:00
parent 154ce756b5
commit 4e4ff111c6
5 changed files with 184 additions and 207 deletions

View File

@ -7,19 +7,16 @@ local door_wood = { -- color, desc, image
{"yellow", "Clear Stained", "yellow"},
{"black", "Black", "black"},
}
for i in ipairs(door_wood) do
local color = door_wood[i][1]
local desc = door_wood[i][2]
local img = door_wood[i][3]
for i = 1,#door_wood do
local color,desc,img = unpack(door_wood[i])
minetest.register_node("my_door_wood:wood_"..color, {
description = desc.." Wood",
drawtype = "normal",
paramtype = "light",
tiles = {"mydoors_"..img.."_wood.png"},
paramtype = "light",
groups = {cracky = 2, choppy = 2},
})
-- Crafts
@ -33,6 +30,3 @@ minetest.register_craft({
}
})
end

View File

@ -1,9 +1,7 @@
minetest.register_node("my_garage_door:garage_door", {
description = "Garage Door",
tiles = {
"default_snow.png"
},
tiles = {"default_snow.png"},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
@ -24,15 +22,26 @@ minetest.register_node("my_garage_door:garage_door", {
{-1.5, -0.5, -0.1875, 1.5, 1.5, -0.0625},
}
},
on_place = function(itemstack, placer, pointed_thing)
local p = pointed_thing.above
local p2 = minetest.dir_to_facedir(placer:get_look_dir())
print(p2)
minetest.set_node(p, {name = "my_garage_door:garage_door",param2 = p2})
minetest.set_node({x=p.x,y=p.y+1,z=p.z}, {name = "my_garage_door:garage_door_top",param2 = p2})
on_place = function(_, placer, pt)
if not placer
or not pt then
return
end
local p = pt.above
local node = {
name = "my_garage_door:garage_door",
param2 = minetest.dir_to_facedir(placer:get_look_dir())
}
minetest.set_node(p, node)
p.y = p.y+1
node.name = node.name.."_top"
minetest.set_node(p, node)
end,
after_destruct = function(pos, oldnode)
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name = "air"})
pos.y = pos.y+1
if minetest.get_node(pos).name == "my_garage_door:garage_door_top" then
minetest.remove_node(pos)
end
end,
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
@ -54,15 +63,13 @@ print(p2)
end
minetest.set_node(t1,{name="my_garage_door:garage_door_open",param2=p2})
minetest.set_node(t2,{name="my_garage_door:garage_door_open2",param2=p2})
minetest.set_node(pos,{name="air"})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="air"})
minetest.remove_node(pos)
minetest.remove_node({x=pos.x,y=pos.y+1,z=pos.z})
--end
end,
})
minetest.register_node("my_garage_door:garage_door_top", {
tiles = {
"default_snow.png"
},
tiles = {"default_snow.png"},
drawtype = "nodebox",
paramtype = "light",
paramtype2= "facedir",
@ -80,12 +87,9 @@ minetest.register_node("my_garage_door:garage_door_top", {
{-1.5, 0.25, -0.1875, 1.5, 0.4375, -0.0625},
}
},
selection_box = {type = "fixed",fixed = {{0, 0, 0, 0, 0, 0},}},
})
minetest.register_node("my_garage_door:garage_door_open", {
tiles = {
"default_snow.png"
},
tiles = {"default_snow.png"},
drawtype = "nodebox",
paramtype = "light",
paramtype2= "facedir",
@ -127,8 +131,8 @@ minetest.register_node("my_garage_door:garage_door_open", {
end
minetest.set_node(t1,{name="my_garage_door:garage_door_top",param2=p2})
minetest.set_node(t2,{name="my_garage_door:garage_door",param2=p2})
minetest.set_node(pos,{name="air"})
minetest.set_node(t3,{name="air"})
minetest.remove_node(pos)
minetest.remove_node(t3)
end,
})
minetest.register_node("my_garage_door:garage_door_open2", {
@ -152,6 +156,4 @@ minetest.register_node("my_garage_door:garage_door_open2", {
{-1.5, 0.375, -0.4375, 1.5, 0.5, -0.25},
}
},
selection_box = {type = "fixed",fixed = {{0, 0, 0, 0, 0, 0},}},
})

View File

@ -1,14 +1,7 @@
minetest.register_node("my_misc_doors:door2a", {
description = "Sliding Door",
inventory_image = "mydoors_bars.png",
tiles = {
"mydoors_bars.png",
"mydoors_bars.png",
"mydoors_bars.png",
"mydoors_bars.png",
"mydoors_bars.png",
"mydoors_bars.png",
},
tiles = {"mydoors_bars.png"},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
@ -30,23 +23,24 @@ minetest.register_node("my_misc_doors:door2a", {
}
},
on_place = function(itemstack, placer, pointed_thing)
local pos1 = pointed_thing.above
local pos2 = {x=pos1.x, y=pos1.y, z=pos1.z}
pos2.y = pos2.y+1
if
not minetest.registered_nodes[minetest.get_node(pos1).name].buildable_to or
not minetest.registered_nodes[minetest.get_node(pos2).name].buildable_to or
not placer or
not placer:is_player() then
on_place = function(_, placer, pt)
if not placer
or not pt
or not placer:is_player() then
return
end
local pt = pointed_thing.above
local pt2 = {x=pt.x, y=pt.y, z=pt.z}
pt2.y = pt2.y+1
pt = pt.above
local pt2 = {x=pt.x, y=pt.y+1, z=pt.z}
if not minetest.registered_nodes[minetest.get_node(pt).name].buildable_to
or not minetest.registered_nodes[minetest.get_node(pt2).name].buildable_to then
return
end
local pt3 = vector.new(pt)
local p2 = minetest.dir_to_facedir(placer:get_look_dir())
local pt3 = {x=pt.x, y=pt.y, z=pt.z}
local p4 = 0
local p4
if p2 == 0 then
pt3.x = pt3.x-1
p4 = 2
@ -68,8 +62,11 @@ on_place = function(itemstack, placer, pointed_thing)
minetest.set_node(pt2, {name="my_misc_doors:door2b", param2=p2})
end
end,
after_destruct = function(pos, oldnode)
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="air"})
after_destruct = function(pos)
pos.y = pos.y+1
if minetest.get_node(pos).name == "my_misc_doors:door2b" then
minetest.remove_node(pos)
end
end,
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local timer = minetest.get_node_timer(pos)
@ -101,13 +98,14 @@ on_rightclick = function(pos, node, player, itemstack, pointed_thing)
end,
})
minetest.register_node("my_misc_doors:door2b", {
tiles = {
"mydoors_bars.png",
},
tiles = {"mydoors_bars.png"},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
diggable = false,
pointable = false,
groups = {cracky = 1},
node_box = {
type = "fixed",
@ -119,12 +117,6 @@ minetest.register_node("my_misc_doors:door2b", {
{-0.25, -0.5, -0.0625, -0.125, 0.5, 0.0625},
}
},
selection_box = {
type = "fixed",
fixed = {
{0, 0, 0, 0, 0, 0},
}
},
})
minetest.register_node("my_misc_doors:door2c", {
tiles = {
@ -138,6 +130,8 @@ minetest.register_node("my_misc_doors:door2c", {
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
diggable = false,
pointable = false,
groups = {cracky = 1},
node_box = {
type = "fixed",
@ -149,19 +143,17 @@ minetest.register_node("my_misc_doors:door2c", {
{-0.25, -0.375, -0.0625, -0.125, -0.5, 0.0625},
}
},
selection_box = {
type = "fixed",
fixed = {
{0, 0, 0, 0, 0, 0},
}
},
after_place_node = function(pos, placer, itemstack, pointed_thing)
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="my_misc_doors:door2d",param2=nodeu.param2})
--[[after_place_node = function(pos)
pos.y = pos.y+1
minetest.set_node(pos, {name="my_misc_doors:door2d"}) -- param2=nodeu.param2 ?
end,--]]
after_destruct = function(pos)
pos.y = pos.y+1
if minetest.get_node(pos).name == "my_misc_doors:door2d" then
minetest.remove_node(pos)
end
end,
after_destruct = function(pos, oldnode)
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="air"})
end,
on_timer = function(pos, elapsed)
on_timer = function(pos)
local node = minetest.get_node(pos)
local a = minetest.get_node({x=pos.x, y=pos.y, z=pos.z-1})
local b = minetest.get_node({x=pos.x, y=pos.y, z=pos.z+1})
@ -186,7 +178,6 @@ on_timer = function(pos, elapsed)
minetest.set_node({x=pos.x-1, y=pos.y, z=pos.z}, {name="my_misc_doors:door2a", param2=d.param2})
minetest.set_node({x=pos.x-1,y=pos.y+1,z=pos.z}, {name="my_misc_doors:door2b", param2=d.param2})
end
end,
})
minetest.register_node("my_misc_doors:door2d", {
@ -201,6 +192,8 @@ minetest.register_node("my_misc_doors:door2d", {
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
diggable = false,
pointable = false,
groups = {cracky = 1},
node_box = {
type = "fixed",
@ -212,18 +205,12 @@ minetest.register_node("my_misc_doors:door2d", {
{-0.25, 0.375, -0.0625, -0.125, 0.5, 0.0625},
}
},
selection_box = {
type = "fixed",
fixed = {
{0, 0, 0, 0, 0, 0},
}
},
})
minetest.register_craft({
output = "my_misc_doors:door2a 1",
output = "my_misc_doors:door2a",
recipe = {
{"default:steel_ingot", "default:steelblock", ""},
{"default:steel_ingot", "default:steel_ingot", ""},
{"default:steelblock", "default:steel_ingot", ""}
{"default:steel_ingot", "default:steelblock"},
{"default:steel_ingot", "default:steel_ingot"},
{"default:steelblock", "default:steel_ingot"}
}
})

View File

@ -1,5 +1,3 @@
dofile(minetest.get_modpath("my_misc_doors").."/locked.lua")
dofile(minetest.get_modpath("my_misc_doors").."/unlocked.lua")
dofile(minetest.get_modpath("my_misc_doors").."/bars.lua")

View File

@ -8,12 +8,8 @@ local mdoor_list = { --Number , Description , Inven Image , Image
}
for i in ipairs(mdoor_list) do
local num = mdoor_list[i][1]
local desc = mdoor_list[i][2]
local inv = mdoor_list[i][3]
local img = mdoor_list[i][4]
for i = 1,#mdoor_list do
local num,desc,inv,img = unpack(mdoor_list[i])
doors.register_door("my_misc_doors:door"..num.."_locked", {
description = desc.." Locked",
@ -53,7 +49,7 @@ minetest.register_craft({
}
})
minetest.register_craft({
output = "my_misc_doors:door4_locked 1",
output = "my_misc_doors:door4_locked",
recipe = {
{"default:cobble", "default:cobble", ""},
{"default:cobble", "default:cobble", "default:steel_ingot"},
@ -69,7 +65,7 @@ minetest.register_craft({
}
})
minetest.register_craft({
output = "my_misc_doors:door6_locked 1",
output = "my_misc_doors:door6_locked",
recipe = {
{"default:steel_ingot", "default:iron_lump", ""},
{"default:steel_ingot", "default:iron_lump", "default:steel_ingot"},