123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288 |
- minetest.register_node('ship:ladder', {
- description = 'Ladder',
- drawtype = 'mesh',
- mesh = 'ship_ladder.obj',
- paramtype = 'light',
- paramtype2 = 'facedir',
- climbable = true,
- selection_box = {
- type = 'fixed',
- fixed = {
- {-.4, -.5, .3, .4, .5, .5},},
- },
- collision_box = {
- type = 'fixed',
- fixed = {
- {-.4, -.5, .3, .4, .5, .5},},
- },
- tiles = {'ship_rail_blank.png', 'ship_floor_blank.png'},
- groups = {breakable=1}
- })
- minetest.register_node('ship:door_H_1_0', {
- description = 'Closed Door',
- drawtype = 'mesh',
- mesh = 'ship_door_H_closed.obj',
- paramtype = 'light',
- paramtype2 = 'facedir',
- tiles = {'ship_door_H_0.png'},
- groups = {breakable=1},
- selection_box = {
- type = 'fixed',
- fixed = {
- {-.5, -.5, -.1, .5, 1.5, .1},},
- },
- collision_box = {
- type = 'fixed',
- fixed = {
- {-.5, -.5, -.1, .5, 1.5, .1},},
- },
- on_rightclick = function(pos, node)
- local fdir = node.param2
- local timer = minetest.get_node_timer(pos)
- timer:start(3)
- minetest.set_node(pos, {name = 'ship:door_H_1_1', param2=fdir})
- minetest.sound_play('ship_door_open', {pos = pos, max_hear_distance = 10, gain = 1})
- if fdir == 0 then --Search in the X axis
- local other_door_pos = {x=pos.x+1, y=pos.y, z=pos.z}
- local other_door = minetest.get_node(other_door_pos)
- if other_door.name == 'ship:door_H_1_0' then
- minetest.set_node(other_door_pos, {name = 'ship:door_H_1_1', param2=other_door.param2})
- local timer = minetest.get_node_timer(other_door_pos)
- timer:start(3)
- end
- elseif fdir == 1 then --Search in the Z axis
- local other_door_pos = {x=pos.x, y=pos.y, z=pos.z-1}
- local other_door = minetest.get_node(other_door_pos)
- if other_door.name == 'ship:door_H_1_0' then
- minetest.set_node(other_door_pos, {name = 'ship:door_H_1_1', param2=other_door.param2})
- local timer = minetest.get_node_timer(other_door_pos)
- timer:start(3)
- end
- elseif fdir == 2 then --Search in the X axis
- local other_door_pos = {x=pos.x-1, y=pos.y, z=pos.z}
- local other_door = minetest.get_node(other_door_pos)
- if other_door.name == 'ship:door_H_1_0' then
- minetest.set_node(other_door_pos, {name = 'ship:door_H_1_1', param2=other_door.param2})
- local timer = minetest.get_node_timer(other_door_pos)
- timer:start(3)
- end
- elseif fdir == 3 then --Search in the Z axis
- local other_door_pos = {x=pos.x, y=pos.y, z=pos.z+1}
- local other_door = minetest.get_node(other_door_pos)
- if other_door.name == 'ship:door_H_1_0' then
- minetest.set_node(other_door_pos, {name = 'ship:door_H_1_1', param2=other_door.param2})
- local timer = minetest.get_node_timer(other_door_pos)
- timer:start(3)
- end
- end
- end,
- })
- minetest.register_node('ship:door_H_1_1', {
- description = 'Open Door',
- drawtype = 'mesh',
- mesh = 'ship_door_H_open.obj',
- paramtype = 'light',
- paramtype2 = 'facedir',
- tiles = {'ship_door_H_0.png'},
- groups = {breakable=1, not_in_creative_inventory=1},
- drop = 'ship:door_H_1_0',
- selection_box = {
- type = 'fixed',
- fixed = {
- {-.5, -.5, -.1, -.4, 1.5, .1},},
- },
- collision_box = {
- type = 'fixed',
- fixed = {
- {-.5, -.5, -.1, -.4, 1.5, .1},},
- },
- on_rightclick = function(pos, node)
- minetest.set_node(pos, {name = 'ship:door_H_1_0', param2=node.param2})
- minetest.sound_play('ship_door_close', {pos = pos, max_hear_distance = 10, gain = 1})
- end,
- on_timer = function(pos)
- local node = minetest.get_node(pos)
- minetest.set_node(pos, {name = 'ship:door_H_1_0', param2=node.param2})
- minetest.sound_play('ship_door_close', {pos = pos, max_hear_distance = 10, gain = .5})
- end
- })
- minetest.register_node('ship:door_V_1_0', { --Vertical opening, style 1, binary state 0 (closed)
- description = 'Closed Door',
- drawtype = 'mesh',
- mesh = 'ship_door_V_closed.obj',
- paramtype = 'light',
- paramtype2 = 'facedir',
- tiles = {'ship_door_V_0.png'},
- groups = {breakable=1},
- selection_box = {
- type = 'fixed',
- fixed = {
- {-.5, -.5, -.1, .5, 1.5, .1},},
- },
- collision_box = {
- type = 'fixed',
- fixed = {
- {-.5, -.5, -.1, .5, 1.5, .1},},
- },
- on_rightclick = function(pos, node)
- local fdir = node.param2
- local timer = minetest.get_node_timer(pos)
- timer:start(3)
- minetest.set_node(pos, {name = 'ship:door_V_1_1', param2=fdir})
- minetest.sound_play('ship_door_open', {pos = pos, max_hear_distance = 10, gain = 1})
- if fdir == 0 or fdir == 2 then --Search in the X axis
- local other_door_r_pos = {x=pos.x+1, y=pos.y, z=pos.z}
- local other_door_r = minetest.get_node(other_door_r_pos).name
- local other_door_l_pos = {x=pos.x-1, y=pos.y, z=pos.z}
- local other_door_l = minetest.get_node(other_door_l_pos).name
- while other_door_r == 'ship:door_V_1_0' do
- local timer = minetest.get_node_timer(other_door_r_pos)
- timer:start(3)
- minetest.set_node(other_door_r_pos, {name = 'ship:door_V_1_1', param2=fdir})
- other_door_r_pos.x = other_door_r_pos.x + 1
- other_door_r = minetest.get_node(other_door_r_pos).name
- end
- while other_door_l == 'ship:door_V_1_0' do
- local timer = minetest.get_node_timer(other_door_l_pos)
- timer:start(3)
- minetest.set_node(other_door_l_pos, {name = 'ship:door_V_1_1', param2=fdir})
- other_door_l_pos.x = other_door_l_pos.x - 1
- other_door_l = minetest.get_node(other_door_l_pos).name
- end
- elseif fdir == 1 or fdir == 3 then --Search in the Z axis
- local other_door_r_pos = {x=pos.x, y=pos.y, z=pos.z+1}
- local other_door_r = minetest.get_node(other_door_r_pos).name
- local other_door_l_pos = {x=pos.x, y=pos.y, z=pos.z-1}
- local other_door_l = minetest.get_node(other_door_l_pos).name
- while other_door_r == 'ship:door_V_1_0' do
- local timer = minetest.get_node_timer(other_door_r_pos)
- timer:start(3)
- minetest.set_node(other_door_r_pos, {name = 'ship:door_V_1_1', param2=fdir})
- other_door_r_pos.z = other_door_r_pos.z + 1
- other_door_r = minetest.get_node(other_door_r_pos).name
- end
- while other_door_l == 'ship:door_V_1_0' do
- local timer = minetest.get_node_timer(other_door_l_pos)
- timer:start(3)
- minetest.set_node(other_door_l_pos, {name = 'ship:door_V_1_1', param2=fdir})
- other_door_l_pos.z = other_door_l_pos.z - 1
- other_door_l = minetest.get_node(other_door_l_pos).name
- end
- end
- end,
- })
- minetest.register_node('ship:door_V_1_1', { --Vertical opening, style 1, binary state 1 (open)
- description = 'Open Door',
- drawtype = 'mesh',
- mesh = 'ship_door_V_open.obj',
- paramtype = 'light',
- paramtype2 = 'facedir',
- tiles = {'ship_door_V_0.png'},
- groups = {breakable=1, not_in_creative_inventory=1},
- drop = 'ship:door_H_1_0',
- selection_box = {
- type = 'fixed',
- fixed = {
- {-.5, -.5, -.1, .5, -.4, .1},
- {-.5, 1.4, -.1, .5, 1.5, .1},},
- },
- collision_box = {
- type = 'fixed',
- fixed = {
- {-.5, -.5, -.1, .5, -.4, .1},
- {-.5, 1.4, -.1, .5, 1.5, .1},},
- },
- on_rightclick = function(pos, node)
- minetest.set_node(pos, {name = 'ship:door_V_1_0', param2=node.param2})
- minetest.sound_play('ship_door_close', {pos = pos, max_hear_distance = 10, gain = 1})
- end,
- on_timer = function(pos)
- local node = minetest.get_node(pos)
- minetest.set_node(pos, {name = 'ship:door_V_1_0', param2=node.param2})
- minetest.sound_play('ship_door_close', {pos = pos, max_hear_distance = 10, gain = .5})
- end
- })
- minetest.register_node('ship:energy_support', {
- description = 'Energy Support Beam',
- drawtype = 'mesh',
- mesh = 'ship_energy_support.obj',
- paramtype = 'light',
- paramtype2 = 'facedir',
- light_source = 10,
- tiles = {'ship_energy_support.png'},
- groups = {breakable=1},
- selection_box = {
- type = 'fixed',
- fixed = {
- {-.35, -.5, -.35, .35, .4, .35},}
- },
- collision_box = {
- type = 'fixed',
- fixed = {
- {-.35, -.5, -.35, .35, .4, .35},}
- },
- after_place_node = function(pos, placer, itemstack)
- local node = minetest.get_node(pos)
- local above_pos = {x=pos.x, y=pos.y+1, z=pos.z}
- local above_name = minetest.get_node(above_pos).name
- local height = 0
- while above_name == 'air' and height < 20 do
- minetest.set_node(above_pos, {name = 'ship:energy_beam', param2 = node.param2})
- above_pos = {x=above_pos.x, y=above_pos.y+1, z=above_pos.z}
- above_name = minetest.get_node(above_pos).name
- height = height + 1
- end
- if above_name ~= 'air' then
- local pos = {x=above_pos.x, y=above_pos.y-1, z=above_pos.z}
- minetest.set_node(pos, {name = 'ship:energy_support_top', param2 = node.param2})
- end
- end,
- after_dig_node = function(pos, oldnode, oldmetadata, digger)
- local above_pos = {x=pos.x, y=pos.y+1, z=pos.z}
- local above_name = minetest.get_node(above_pos).name
- while above_name == 'ship:energy_beam' do
- minetest.remove_node(above_pos)
- above_pos = {x=above_pos.x, y=above_pos.y+1, z=above_pos.z}
- above_name = minetest.get_node(above_pos).name
- end
- if above_name == 'ship:energy_support_top' then
- minetest.remove_node(above_pos)
- end
- end,
- })
- local beam_select = {
- type = 'fixed',
- fixed = {
- {-.2, -.5, -.2, .2, .5, .2},},}
- minetest.register_node('ship:energy_beam', {
- drawtype = 'mesh',
- mesh = 'ship_energy_beam.obj',
- paramtype = 'light',
- light_source = 10,
- tiles = {'ship_energy_beam.png'},
- groups = {breakable=1, not_in_creative_inventory=1},
- drop = '',
- selection_box = beam_select,
- collision_box = beam_select,
- })
- minetest.register_node('ship:energy_support_top', {
- drawtype = 'mesh',
- mesh = 'ship_energy_support_top.obj',
- paramtype = 'light',
- paramtype2 = 'facedir',
- light_source = 10,
- tiles = {'ship_energy_support_top.png'},
- groups = {breakable=1, not_in_creative_inventory=1},
- drop = '',
- selection_box = beam_select,
- collision_box = beam_select,
- })
|