diff options
author | cheapie <no-email-for-you@example.com> | 2025-03-15 13:02:27 -0500 |
---|---|---|
committer | cheapie <no-email-for-you@example.com> | 2025-03-15 13:02:27 -0500 |
commit | feea683ef8d8a7a4c8be692e7ad1749904b2921a (patch) | |
tree | b8bf8646cdfc42b235ee3d77b85a8b4cf2628d04 | |
parent | 9adad1127871b11ec541edf52de7914903359f43 (diff) | |
download | celevator-feea683ef8d8a7a4c8be692e7ad1749904b2921a.tar celevator-feea683ef8d8a7a4c8be692e7ad1749904b2921a.tar.gz celevator-feea683ef8d8a7a4c8be692e7ad1749904b2921a.tar.bz2 celevator-feea683ef8d8a7a4c8be692e7ad1749904b2921a.tar.xz celevator-feea683ef8d8a7a4c8be692e7ad1749904b2921a.zip |
Add glass-back car
-rw-r--r-- | car.lua | 746 | ||||
-rw-r--r-- | car_glassback.lua | 416 | ||||
-rw-r--r-- | car_standard.lua | 419 | ||||
-rw-r--r-- | crafts.lua | 11 | ||||
-rw-r--r-- | doors.lua | 11 | ||||
-rw-r--r-- | drive_entity.lua | 17 | ||||
-rw-r--r-- | init.lua | 2 | ||||
-rw-r--r-- | textures/celevator_car_glass.png | bin | 0 -> 223 bytes |
8 files changed, 1054 insertions, 568 deletions
@@ -1,6 +1,6 @@ celevator.car = {} -local function disambiguatebutton(pos,facedir,player) +local function disambiguatecartopbutton(pos,facedir,player) if player and not player.is_fake_player then local eyepos = vector.add(player:get_pos(),vector.add(player:get_eye_offset(),vector.new(0,1.5,0))) local lookdir = player:get_look_dir() @@ -12,7 +12,8 @@ local function disambiguatebutton(pos,facedir,player) pointed = ray:next() if pointed and pointed.type == "node" then local node = minetest.get_node(pointed.under) - if node.name == "celevator:car_021" then + local ndef = minetest.registered_nodes[node.name] or {} + if ndef._cartopbox then button = pointed.under hitpos = vector.subtract(pointed.intersection_point,button) end @@ -68,503 +69,207 @@ minetest.register_globalstep(function() end end) -local pieces = { - { - _position = "000", - node_box = { - type = "fixed", - fixed = { - {-0.5,-0.6,-0.5,0.5,-0.5,0.5}, - {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, - {-0.5,-1.5,-0.5,0.5,-0.6,-0.45}, - }, - }, - tiles = { - "celevator_car_floor.png^celevator_door_sill_single.png", - "celevator_car_bottom.png", - "celevator_car_wallpaper.png^celevator_car_wall_bottom.png^celevator_car_switch_panel.png", - "celevator_cabinet_sides.png^celevator_car_side_overlay.png^[transformR90", - "celevator_cabinet_sides.png", - }, - on_timer = function(pos) - local carid = minetest.get_meta(pos):get_int("carid") - local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid))) - if not (carinfo and carinfo.controllerpos) then return end - local yaw = minetest.dir_to_yaw(minetest.fourdir_to_dir(minetest.get_node(pos).param2)) - local positions = { - vector.new(-0.25,-0.1,-0.5), - vector.new(0.25,-0.1,-0.5), - vector.new(0.75,-0.1,-0.5), - vector.new(1.25,-0.1,-0.5), - } - local playerseen = false - for _,searchpos in ipairs(positions) do - local rotatedpos = vector.rotate_around_axis(searchpos,vector.new(0,1,0),yaw) - local erefs = minetest.get_objects_inside_radius(vector.add(pos,rotatedpos),0.5) - for _,ref in pairs(erefs) do - if ref:is_player() then - playerseen = true - break - end - end - if playerseen then break end - end - if playerseen then - celevator.controller.run(carinfo.controllerpos,{ - type = "lightcurtain", - }) +celevator.car.types = {} + +function celevator.car.register(name,defs,size) + celevator.car.types[name] = { + size = size, + } + for _,def in ipairs(defs) do + def._celevator_car_type = name + def.groups = { + not_in_creative_inventory = 1, + _celevator_car = 1, + } + local xp = tonumber(string.sub(def._position,1,1)) + local yp = tonumber(string.sub(def._position,2,2)) + local zp = tonumber(string.sub(def._position,3,3)) + if xp > 0 then + def.groups._connects_xm = 1 + end + if xp < size.x-1 then + def.groups._connects_xp = 1 + end + if yp > 0 then + def.groups._connects_ym = 1 + end + if yp < size.y-1 then + def.groups._connects_yp = 1 + end + if zp > 0 then + def.groups._connects_zm = 1 + end + if zp < size.z-1 then + def.groups._connects_zp = 1 + end + def.paramtype = "light" + def.paramtype2 = "4dir" + def.drawtype = "nodebox" + def.description = "Car "..def._position.." (you hacker you!)" + def.light_source = 9 + def.drop = "" + if def._cop then + def.on_receive_fields = function(pos,_,fields,player) + local meta = minetest.get_meta(pos) + local carid = meta:get_int("carid") + if carid == 0 then return end + local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid))) + if not carinfo then return end + local playername = player:get_player_name() + local protected = minetest.is_protected(pos,playername) and not minetest.check_player_privs(playername,{protection_bypass=true}) + local event = { + type = "cop", + fields = fields, + player = playername, + protected = protected, + } + celevator.controller.run(carinfo.controllerpos,event) end - return true - end, - }, - { - _position = "001", - node_box = { - type = "fixed", - fixed = { - {-0.5,-0.6,-0.5,0.5,-0.5,0.5}, - {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, - }, - }, - tiles = { - "celevator_car_floor.png", - "celevator_car_bottom_center.png", - "celevator_car_wallpaper.png^celevator_car_wall_bottom.png^celevator_car_wall_vent.png", - "celevator_cabinet_sides.png^celevator_car_side_center_overlay.png", - "celevator_cabinet_sides.png", - }, - }, - { - _position = "002", - node_box = { - type = "fixed", - fixed = { - {-0.5,-0.6,-0.5,0.5,-0.5,0.5}, - {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, - {-0.45,-0.5,0.45,0.5,0.5,0.5}, - }, - }, - tiles = { - "celevator_car_floor.png", - "celevator_car_bottom.png", - "celevator_car_wallpaper.png^celevator_car_wall_bottom.png", - "celevator_cabinet_sides.png^celevator_car_side_overlay.png", - "celevator_cabinet_sides.png", - "celevator_car_wallpaper.png^celevator_car_wall_bottom.png", - }, - }, - { - _position = "100", - node_box = { - type = "fixed", - fixed = { - {-0.5,-0.6,-0.5,0.5,-0.5,0.5}, - {0.45,-0.5,-0.5,0.5,0.5,0.5}, - {-0.5,-1.5,-0.5,0.5,-0.6,-0.45}, - }, - }, - tiles = { - "celevator_car_floor.png^celevator_door_sill_double.png", - "celevator_car_bottom.png", - "celevator_cabinet_sides.png^celevator_car_side_overlay.png", - "celevator_car_wallpaper.png^celevator_car_wall_bottom.png", - "celevator_cabinet_sides.png", - }, - }, - { - _position = "101", - node_box = { - type = "fixed", - fixed = { - {-0.5,-0.6,-0.5,0.5,-0.5,0.5}, - {0.45,-0.5,-0.5,0.5,0.5,0.5}, - }, - }, - tiles = { - "celevator_car_floor.png", - "celevator_car_bottom_center.png^[transformFX", - "celevator_cabinet_sides.png^celevator_car_side_center_overlay.png", - "celevator_car_wallpaper.png^celevator_car_wall_bottom.png^celevator_car_wall_vent.png", - "celevator_cabinet_sides.png", - }, - }, - { - _position = "102", - node_box = { - type = "fixed", - fixed = { - {-0.5,-0.6,-0.5,0.5,-0.5,0.5}, - {0.45,-0.5,-0.5,0.5,0.5,0.5}, - {-0.5,-0.5,0.45,0.45,0.5,0.5}, - }, - }, - tiles = { - "celevator_car_floor.png", - "celevator_car_bottom.png", - "celevator_cabinet_sides.png^celevator_car_side_overlay.png^[transformR90", - "celevator_car_wallpaper.png^celevator_car_wall_bottom.png", - "celevator_cabinet_sides.png", - "celevator_car_wallpaper.png^celevator_car_wall_bottom.png", - }, - }, - { - _position = "010", - node_box = { - type = "fixed", - fixed = { - {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, - }, - }, - tiles = { - "celevator_cabinet_sides.png", - "celevator_cabinet_sides.png", - "celevator_car_wallpaper_2x.png^celevator_cop.png", - "celevator_cabinet_sides.png", - }, - }, - { - _position = "011", - node_box = { - type = "fixed", - fixed = { - {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, - }, - }, - tiles = { - "celevator_cabinet_sides.png", - "celevator_cabinet_sides.png", - "celevator_car_wallpaper.png^celevator_car_handrail_end.png", - "celevator_cabinet_sides.png^celevator_car_side_center2_overlay.png", - "celevator_cabinet_sides.png", - }, - }, - { - _position = "012", - node_box = { - type = "fixed", - fixed = { - {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, - {-0.45,-0.5,0.45,0.5,0.5,0.5}, - }, - }, - tiles = { - "celevator_cabinet_sides.png", - "celevator_cabinet_sides.png", - "celevator_car_wallpaper.png^(celevator_car_handrail_end.png^[transformFX)", - "celevator_cabinet_sides.png", - "celevator_cabinet_sides.png", - "celevator_car_wallpaper.png^celevator_car_handrail_end.png", - }, - }, - { - _position = "110", - node_box = { - type = "fixed", - fixed = { - {0.45,-0.5,-0.5,0.5,0.5,0.5}, - }, - }, - tiles = { - "celevator_cabinet_sides.png", - "celevator_cabinet_sides.png", - "celevator_cabinet_sides.png", - "celevator_car_wallpaper.png^(celevator_car_handrail_end.png^[transformFX)", - "celevator_cabinet_sides.png", - }, - }, - { - _position = "111", - node_box = { - type = "fixed", - fixed = { - {0.45,-0.5,-0.5,0.5,0.5,0.5}, - }, - }, - tiles = { - "celevator_cabinet_sides.png", - "celevator_cabinet_sides.png", - "celevator_cabinet_sides.png^celevator_car_side_center2_overlay.png", - "celevator_car_wallpaper.png^celevator_car_handrail_center.png", - "celevator_cabinet_sides.png", - }, - }, - { - _position = "112", - node_box = { - type = "fixed", - fixed = { - {0.45,-0.5,-0.5,0.5,0.5,0.5}, - {-0.5,-0.5,0.45,0.45,0.5,0.5}, - }, - }, - tiles = { - "celevator_cabinet_sides.png", - "celevator_cabinet_sides.png", - "celevator_cabinet_sides.png", - "celevator_car_wallpaper.png^celevator_car_handrail_end.png", - "celevator_cabinet_sides.png", - "celevator_car_wallpaper.png^(celevator_car_handrail_end.png^[transformFX)", - }, - }, - { - _position = "020", - node_box = { - type = "fixed", - fixed = { - {-0.5,0.5,-0.5,0.5,0.6,0.5}, - {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, - {-0.5,0.6,-0.4,0.5,1,-0.1}, - }, - }, - tiles = { - "celevator_cabinet_sides.png", - "celevator_car_ceiling.png", - "celevator_car_wallpaper.png", - "celevator_cabinet_sides.png", - "celevator_cabinet_sides.png", - "celevator_dooroperator_left.png", - }, - }, - { - _position = "021", - node_box = { - type = "fixed", - fixed = { - {-0.5,0.5,-0.5,0.5,0.6,0.5}, - {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, - }, - }, - tiles = { - "celevator_cabinet_sides.png^celevator_car_top_center_overlay.png", - "celevator_car_ceiling.png", - "celevator_car_wallpaper.png", - "celevator_cabinet_sides.png^celevator_car_side_center_overlay.png", - "celevator_cabinet_sides.png", - }, - on_rightclick = function(pos,node,clicker) - local name = clicker:get_player_name() - for _,v in ipairs(held) do - if name == v.name then return end + elseif def._keyswitches then + def.on_receive_fields = function(pos,_,fields,player) + if fields.quit then return end + local meta = minetest.get_meta(pos) + local carid = meta:get_int("carid") + if carid == 0 then return end + local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid))) + if not carinfo then return end + local playername = player:get_player_name() + if minetest.is_protected(pos,playername) and not minetest.check_player_privs(playername,{protection_bypass=true}) then + minetest.chat_send_player(playername,"You don't have access to these switches.") + minetest.record_protection_violation(pos,playername) + return + end + local event = { + type = "copswitches", + fields = fields, + player = name, + } + celevator.controller.run(carinfo.controllerpos,event) end - local fdir = minetest.fourdir_to_dir(node.param2) - local control = disambiguatebutton(pos,fdir,clicker) - if not control then return end - local meta = minetest.get_meta(pos) - local carid = meta:get_int("carid") - if carid == 0 then return end - local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid))) - if not (carinfo and carinfo.controllerpos) then return end - if control == "inspectswitch" then - local boxpos = vector.add(pos,vector.new(0,1,0)) - local erefs = minetest.get_objects_inside_radius(boxpos,0.5) - for _,ref in pairs(erefs) do - if ref:get_luaentity() and ref:get_luaentity().name == "celevator:car_top_box" then - local state = ref:get_properties().wield_item - if state == "celevator:car_top_box_off" then - state = "celevator:car_top_box_on" - elseif state == "celevator:car_top_box_on" then - state = "celevator:car_top_box_off" + end + if def._cartopbox then + def.groups._celevator_car_spawnstopbox = 1 + def.on_rightclick = function(pos,node,clicker) + local playername = clicker:get_player_name() + for _,v in ipairs(held) do + if playername == v.name then return end + end + local fdir = minetest.fourdir_to_dir(node.param2) + local control = disambiguatecartopbutton(pos,fdir,clicker) + if not control then return end + local meta = minetest.get_meta(pos) + local carid = meta:get_int("carid") + if carid == 0 then return end + local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid))) + if not (carinfo and carinfo.controllerpos) then return end + if control == "inspectswitch" then + local boxpos = vector.add(pos,vector.new(0,1,0)) + local erefs = minetest.get_objects_inside_radius(boxpos,0.5) + for _,ref in pairs(erefs) do + if ref:get_luaentity() and ref:get_luaentity().name == "celevator:car_top_box" then + local state = ref:get_properties().wield_item + if state == "celevator:car_top_box_off" then + state = "celevator:car_top_box_on" + elseif state == "celevator:car_top_box_on" then + state = "celevator:car_top_box_off" + end + ref:set_properties({wield_item = state}) end - ref:set_properties({wield_item = state}) end end + celevator.controller.handlecartopbox(carinfo.controllerpos,control) + table.insert(held,{ + pos = carinfo.controllerpos, + name = playername, + button = "place", + control = control, + }) end - celevator.controller.handlecartopbox(carinfo.controllerpos,control) - table.insert(held,{ - pos = carinfo.controllerpos, - name = name, - button = "place", - control = control, - }) - end, - after_dig_node = function(pos) - local toppos = vector.add(pos,vector.new(0,1.1,0)) - local entitiesnearby = minetest.get_objects_inside_radius(toppos,0.5) - for _,i in pairs(entitiesnearby) do - if i:get_luaentity() and i:get_luaentity().name == "celevator:car_top_box" then - i:remove() + def.after_dig_node = function(pos) + local toppos = vector.add(pos,vector.new(0,1.1,0)) + local entitiesnearby = minetest.get_objects_inside_radius(toppos,0.5) + for _,i in pairs(entitiesnearby) do + if i:get_luaentity() and i:get_luaentity().name == "celevator:car_top_box" then + i:remove() + end end end - end, - }, - { - _position = "022", - node_box = { - type = "fixed", - fixed = { - {-0.5,0.5,-0.5,0.5,0.6,0.5}, - {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, - {-0.45,-0.5,0.45,0.5,0.5,0.5}, - }, - }, - tiles = { - "celevator_cabinet_sides.png^celevator_car_top_hatch.png", - "celevator_car_ceiling.png", - "celevator_car_wallpaper.png", - "celevator_cabinet_sides.png", - "celevator_cabinet_sides.png", - "celevator_car_wallpaper.png", - }, - }, - { - _position = "120", - node_box = { - type = "fixed", - fixed = { - {-0.5,0.5,-0.5,0.5,0.6,0.5}, - {0.45,-0.5,-0.5,0.5,0.5,0.5}, - {-0.5,0.6,-0.4,0.5,1,-0.1}, - }, - }, - tiles = { - "celevator_cabinet_sides.png", - "celevator_car_ceiling.png", - "celevator_cabinet_sides.png", - "celevator_car_wallpaper.png", - "celevator_cabinet_sides.png", - "celevator_dooroperator_right.png", - }, - }, - { - _position = "121", - node_box = { - type = "fixed", - fixed = { - {-0.5,0.5,-0.5,0.5,0.6,0.5}, - {0.45,-0.5,-0.5,0.5,0.5,0.5}, - }, - }, - tiles = { - "celevator_cabinet_sides.png^celevator_car_top_center_overlay.png^[transformFX", - "celevator_car_ceiling.png", - "celevator_cabinet_sides.png^celevator_car_side_center_overlay.png", - "celevator_car_wallpaper.png", - "celevator_cabinet_sides.png", - }, - }, - { - _position = "122", - node_box = { - type = "fixed", - fixed = { - {-0.5,0.5,-0.5,0.5,0.6,0.5}, - {0.45,-0.5,-0.5,0.5,0.5,0.5}, - {-0.5,-0.5,0.45,0.45,0.5,0.5}, - }, - }, - tiles = { - "celevator_cabinet_sides.png^celevator_car_top_misc.png", - "celevator_car_ceiling.png", - "celevator_cabinet_sides.png", - "celevator_car_wallpaper.png", - "celevator_cabinet_sides.png", - "celevator_car_wallpaper.png", - }, - }, -} - -for _,def in ipairs(pieces) do - def.groups = { - not_in_creative_inventory = 1, - _celevator_car = 1, - } - local xp = tonumber(string.sub(def._position,1,1)) - local yp = tonumber(string.sub(def._position,2,2)) - local zp = tonumber(string.sub(def._position,3,3)) - if xp > 0 then - def.groups._connects_xm = 1 - end - if xp < 1 then - def.groups._connects_xp = 1 - end - if yp > 0 then - def.groups._connects_ym = 1 - end - if yp < 2 then - def.groups._connects_yp = 1 - end - if zp > 0 then - def.groups._connects_zm = 1 - end - if zp < 2 then - def.groups._connects_zp = 1 - end - def.paramtype = "light" - def.paramtype2 = "4dir" - def.drawtype = "nodebox" - def.description = "Car "..def._position.." (you hacker you!)" - def.light_source = 9 - def.drop = "" - def.on_receive_fields = function(pos,_,fields,player) - local meta = minetest.get_meta(pos) - local carid = meta:get_int("carid") - if carid == 0 then return end - local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid))) - if not carinfo then return end - local nname = minetest.get_node(pos).name - if nname == "celevator:car_010" then - local name = player:get_player_name() - local protected = minetest.is_protected(pos,name) and not minetest.check_player_privs(name,{protection_bypass=true}) - local event = { - type = "cop", - fields = fields, - player = player:get_player_name(), - protected = protected, - } - celevator.controller.run(carinfo.controllerpos,event) - elseif nname == "celevator:car_000" then - if fields.quit then return end - local name = player:get_player_name() - if minetest.is_protected(pos,name) and not minetest.check_player_privs(name,{protection_bypass=true}) then - minetest.chat_send_player(name,"You don't have access to these switches.") - minetest.record_protection_violation(pos,name) - return - end - local event = { - type = "copswitches", - fields = fields, - player = name, - } - celevator.controller.run(carinfo.controllerpos,event) end - end - if def._position == "000" then - def.on_construct = function(pos) - minetest.get_meta(pos):set_string("doorstate","closed") + if def._pi then + def.groups._celevator_car_spawnspi = 1 end - def.on_punch = function(pos,_,player) - if player.is_fake_player then return end - local name = player:get_player_name() - local sneak = player:get_player_control().sneak - if not sneak then return end - if minetest.is_protected(pos,name) and not minetest.check_player_privs(name,{protection_bypass=true}) then - minetest.record_protection_violation(pos,name) - return + if def._position == "000" then + def.groups._celevator_car_root = 1 + def._root = true + def.on_construct = function(pos) + minetest.get_meta(pos):set_string("doorstate","closed") + end + def.on_punch = function(pos,_,player) + if player.is_fake_player then return end + local playername = player:get_player_name() + local sneak = player:get_player_control().sneak + if not sneak then return end + if minetest.is_protected(pos,playername) and not minetest.check_player_privs(playername,{protection_bypass=true}) then + minetest.record_protection_violation(pos,playername) + return + end + local hash = minetest.hash_node_position(pos) + local fs = "formspec_version[7]size[6,4]" + fs = fs.."label[0.5,1;Really remove this car?]" + fs = fs.."button_exit[0.5,2;2,1;yes;Yes]" + fs = fs.."button_exit[3,2;2,1;no;No]" + minetest.show_formspec(playername,string.format("celevator:remove_car_%d",hash),fs) + end + def.on_timer = function(pos) + local carid = minetest.get_meta(pos):get_int("carid") + local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid))) + if not (carinfo and carinfo.controllerpos) then return end + local yaw = minetest.dir_to_yaw(minetest.fourdir_to_dir(minetest.get_node(pos).param2)) + local positions = { + vector.new(-0.25,-0.1,-0.5), + vector.new(0.25,-0.1,-0.5), + vector.new(0.75,-0.1,-0.5), + vector.new(1.25,-0.1,-0.5), + } + local playerseen = false + for _,searchpos in ipairs(positions) do + local rotatedpos = vector.rotate_around_axis(searchpos,vector.new(0,1,0),yaw) + local erefs = minetest.get_objects_inside_radius(vector.add(pos,rotatedpos),0.5) + for _,ref in pairs(erefs) do + if ref:is_player() then + playerseen = true + break + end + end + if playerseen then break end + end + if playerseen then + celevator.controller.run(carinfo.controllerpos,{ + type = "lightcurtain", + }) + end + return true end - local hash = minetest.hash_node_position(pos) - local fs = "formspec_version[7]size[6,4]" - fs = fs.."label[0.5,1;Really remove this car?]" - fs = fs.."button_exit[0.5,2;2,1;yes;Yes]" - fs = fs.."button_exit[3,2;2,1;no;No]" - minetest.show_formspec(name,string.format("celevator:remove_car_%d",hash),fs) end + minetest.register_node("celevator:car_"..name.."_"..def._position,def) end - minetest.register_node("celevator:car_"..def._position,def) end -function celevator.car.spawncar(origin,yaw,carid) +function celevator.car.spawncar(origin,yaw,carid,name) + if (not name) or name == "" then name = "standard" end + local size = celevator.car.types[name].size local right = vector.rotate_around_axis(vector.new(1,0,0),vector.new(0,1,0),yaw) local back = vector.rotate_around_axis(vector.new(0,0,1),vector.new(0,1,0),yaw) local up = vector.new(0,1,0) - for x=0,1,1 do - for y=0,2,1 do - for z=0,2,1 do + for x=0,(size.x-1),1 do + for y=0,(size.y-1),1 do + for z=0,(size.z-1),1 do local pos = vector.copy(origin) pos = vector.add(pos,vector.multiply(right,x)) pos = vector.add(pos,vector.multiply(back,z)) pos = vector.add(pos,vector.multiply(up,y)) local node = { - name = string.format("celevator:car_%d%d%d",x,y,z), + name = string.format("celevator:car_%s_%d%d%d",name,x,y,z), param2 = minetest.dir_to_fourdir(minetest.yaw_to_dir(yaw)), } minetest.set_node(pos,node) @@ -576,7 +281,7 @@ end minetest.register_abm({ label = "Respawn in-car PI displays", - nodenames = {"celevator:car_020"}, + nodenames = {"group:_celevator_car_spawnspi"}, interval = 1, chance = 1, action = function(pos) @@ -650,97 +355,22 @@ minetest.register_entity("celevator:car_top_box",{ minetest.register_abm({ label = "Respawn car-top inspection boxes", - nodenames = {"celevator:car_021"}, + nodenames = {"group:_celevator_car_spawnstopbox"}, interval = 1, chance = 1, action = updatecartopbox, }) -minetest.register_node("celevator:car",{ - description = "Elevator Car", - paramtype2 = "4dir", - buildable_to = true, - inventory_image = "celevator_car_inventory.png", - wield_image = "celevator_car_wield.png", - wield_scale = vector.new(1,1,10), - tiles = {"celevator_transparent.png"}, - after_place_node = function(pos,player) - if not player:is_player() then - minetest.remove_node(pos) - return true - end - local name = player:get_player_name() - local newnode = minetest.get_node(pos) - local facedir = minetest.dir_to_yaw(minetest.fourdir_to_dir(newnode.param2)) - for x=0,1,1 do - for y=0,2,1 do - for z=0,2,1 do - local offsetdesc = string.format("%dm to the right, %dm up, and %dm back",x,y,z) - local placeoffset = vector.new(x,y,z) - local placepos = vector.add(pos,vector.rotate_around_axis(placeoffset,vector.new(0,1,0),facedir)) - local replaces = minetest.get_node(placepos).name - if not (minetest.registered_nodes[replaces] and minetest.registered_nodes[replaces].buildable_to) then - minetest.chat_send_player(name,string.format("Can't place car here - position %s is blocked!",offsetdesc)) - minetest.remove_node(pos) - return true - end - if minetest.is_protected(placepos,name) and not minetest.check_player_privs(name,{protection_bypass=true}) then - minetest.chat_send_player(name,string.format("Can't place car here - position %s is protected!",offsetdesc)) - minetest.record_protection_violation(placepos,name) - minetest.remove_node(pos) - return true - end - end - end - end - for x=0,1,1 do - for y=0,2,1 do - for z=0,2,1 do - local piecename = string.format("celevator:car_%d%d%d",x,y,z) - local placeoffset = vector.new(x,y,z) - local placepos = vector.add(pos,vector.rotate_around_axis(placeoffset,vector.new(0,1,0),facedir)) - minetest.set_node(placepos,{name=piecename,param2=newnode.param2}) - end - end - end - end, -}) - minetest.register_on_player_receive_fields(function(_,formname,fields) if string.sub(formname,1,21) ~= "celevator:remove_car_" then return false end if not fields.yes then return true end local hash = tonumber(string.sub(formname,22,-1)) if not hash then return true end local rootpos = minetest.get_position_from_hash(hash) - local rootdir = minetest.dir_to_yaw(minetest.fourdir_to_dir(minetest.get_node(rootpos).param2)) - local toberemoved = { - ["celevator:car_top_box"] = true, - ["celevator:incar_pi_entity"] = true, - ["celevator:car_door"] = true, - } - for x=0,1,1 do - for y=0,2,1 do - for z=0,2,1 do - local piecename = string.format("celevator:car_%d%d%d",x,y,z) - local pieceoffset = vector.new(x,y,z) - local piecepos = vector.add(rootpos,vector.rotate_around_axis(pieceoffset,vector.new(0,1,0),rootdir)) - if minetest.get_node(piecepos).name == piecename then - minetest.remove_node(piecepos) - local erefs = minetest.get_objects_inside_radius(piecepos,0.5) - for _,ref in pairs(erefs) do - if ref:get_luaentity() and toberemoved[ref:get_luaentity().name] then - ref:remove() - end - end - end - end - end - end - local cartopboxpos = vector.add(rootpos,vector.rotate_around_axis(vector.new(0,3,1),vector.new(0,1,0),rootdir)) - local erefs = minetest.get_objects_inside_radius(cartopboxpos,0.5) - for _,ref in pairs(erefs) do - if ref:get_luaentity() and toberemoved[ref:get_luaentity().name] then - ref:remove() - end + local rootdef = minetest.registered_nodes[celevator.get_node(rootpos).name] or {} + local cartype = rootdef._celevator_car_type + if cartype and celevator.car.types[cartype] then + local rootdir = minetest.dir_to_yaw(minetest.fourdir_to_dir(minetest.get_node(rootpos).param2)) + celevator.car.types[cartype].remove(rootpos,rootdir) end end) diff --git a/car_glassback.lua b/car_glassback.lua new file mode 100644 index 0000000..fff3dc0 --- /dev/null +++ b/car_glassback.lua @@ -0,0 +1,416 @@ +local pieces = { + { + _position = "000", + node_box = { + type = "fixed", + fixed = { + {-0.5,-0.6,-0.5,0.5,-0.5,0.5}, + {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, + {-0.5,-1.5,-0.5,0.5,-0.6,-0.45}, + }, + }, + tiles = { + "celevator_car_floor.png^celevator_door_sill_single.png", + "celevator_car_bottom.png", + "celevator_car_wallpaper.png^celevator_car_wall_bottom.png^celevator_car_switch_panel.png", + "celevator_cabinet_sides.png^celevator_car_side_overlay.png^[transformR90", + "celevator_cabinet_sides.png", + }, + _keyswitches = true, + }, + { + _position = "001", + node_box = { + type = "fixed", + fixed = { + {-0.5,-0.6,-0.5,0.5,-0.5,0.5}, + {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, + }, + }, + tiles = { + "celevator_car_floor.png", + "celevator_car_bottom_center.png", + "celevator_car_wallpaper.png^celevator_car_wall_bottom.png^celevator_car_wall_vent.png", + "celevator_cabinet_sides.png^celevator_car_side_center_overlay.png", + "celevator_cabinet_sides.png", + }, + }, + { + _position = "002", + node_box = { + type = "fixed", + fixed = { + {-0.5,-0.6,-0.5,0.5,-0.5,0.5}, + {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, + {-0.45,-0.5,0.45,0.5,0.5,0.5}, + }, + }, + use_texture_alpha = "clip", + tiles = { + "celevator_car_floor.png", + "celevator_car_bottom.png", + "celevator_car_wallpaper.png^celevator_car_wall_bottom.png", + "celevator_cabinet_sides.png^celevator_car_side_overlay.png", + "celevator_car_glass.png", + "celevator_car_glass.png^celevator_car_wall_bottom.png", + }, + }, + { + _position = "100", + node_box = { + type = "fixed", + fixed = { + {-0.5,-0.6,-0.5,0.5,-0.5,0.5}, + {0.45,-0.5,-0.5,0.5,0.5,0.5}, + {-0.5,-1.5,-0.5,0.5,-0.6,-0.45}, + }, + }, + tiles = { + "celevator_car_floor.png^celevator_door_sill_double.png", + "celevator_car_bottom.png", + "celevator_cabinet_sides.png^celevator_car_side_overlay.png", + "celevator_car_wallpaper.png^celevator_car_wall_bottom.png", + "celevator_cabinet_sides.png", + }, + }, + { + _position = "101", + node_box = { + type = "fixed", + fixed = { + {-0.5,-0.6,-0.5,0.5,-0.5,0.5}, + {0.45,-0.5,-0.5,0.5,0.5,0.5}, + }, + }, + tiles = { + "celevator_car_floor.png", + "celevator_car_bottom_center.png^[transformFX", + "celevator_cabinet_sides.png^celevator_car_side_center_overlay.png", + "celevator_car_wallpaper.png^celevator_car_wall_bottom.png^celevator_car_wall_vent.png", + "celevator_cabinet_sides.png", + }, + }, + { + _position = "102", + node_box = { + type = "fixed", + fixed = { + {-0.5,-0.6,-0.5,0.5,-0.5,0.5}, + {0.45,-0.5,-0.5,0.5,0.5,0.5}, + {-0.5,-0.5,0.45,0.45,0.5,0.5}, + }, + }, + use_texture_alpha = "clip", + tiles = { + "celevator_car_floor.png", + "celevator_car_bottom.png", + "celevator_cabinet_sides.png^celevator_car_side_overlay.png^[transformR90", + "celevator_car_wallpaper.png^celevator_car_wall_bottom.png", + "celevator_car_glass.png", + "celevator_car_glass.png^celevator_car_wall_bottom.png", + }, + }, + { + _position = "010", + node_box = { + type = "fixed", + fixed = { + {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, + }, + }, + tiles = { + "celevator_cabinet_sides.png", + "celevator_cabinet_sides.png", + "celevator_car_wallpaper_2x.png^celevator_cop.png", + "celevator_cabinet_sides.png", + }, + _cop = true, + }, + { + _position = "011", + node_box = { + type = "fixed", + fixed = { + {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, + }, + }, + tiles = { + "celevator_cabinet_sides.png", + "celevator_cabinet_sides.png", + "celevator_car_wallpaper.png^celevator_car_handrail_end.png", + "celevator_cabinet_sides.png^celevator_car_side_center2_overlay.png", + "celevator_cabinet_sides.png", + }, + }, + { + _position = "012", + node_box = { + type = "fixed", + fixed = { + {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, + {-0.45,-0.5,0.45,0.5,0.5,0.5}, + }, + }, + use_texture_alpha = "clip", + tiles = { + "celevator_cabinet_sides.png", + "celevator_cabinet_sides.png", + "celevator_car_wallpaper.png^(celevator_car_handrail_end.png^[transformFX)", + "celevator_cabinet_sides.png", + "celevator_car_glass.png", + "celevator_car_glass.png", + }, + }, + { + _position = "110", + node_box = { + type = "fixed", + fixed = { + {0.45,-0.5,-0.5,0.5,0.5,0.5}, + }, + }, + tiles = { + "celevator_cabinet_sides.png", + "celevator_cabinet_sides.png", + "celevator_cabinet_sides.png", + "celevator_car_wallpaper.png^(celevator_car_handrail_end.png^[transformFX)", + "celevator_cabinet_sides.png", + }, + }, + { + _position = "111", + node_box = { + type = "fixed", + fixed = { + {0.45,-0.5,-0.5,0.5,0.5,0.5}, + }, + }, + tiles = { + "celevator_cabinet_sides.png", + "celevator_cabinet_sides.png", + "celevator_cabinet_sides.png^celevator_car_side_center2_overlay.png", + "celevator_car_wallpaper.png^celevator_car_handrail_center.png", + "celevator_cabinet_sides.png", + }, + }, + { + _position = "112", + node_box = { + type = "fixed", + fixed = { + {0.45,-0.5,-0.5,0.5,0.5,0.5}, + {-0.5,-0.5,0.45,0.45,0.5,0.5}, + }, + }, + use_texture_alpha = "clip", + tiles = { + "celevator_cabinet_sides.png", + "celevator_cabinet_sides.png", + "celevator_cabinet_sides.png", + "celevator_car_wallpaper.png^celevator_car_handrail_end.png", + "celevator_car_glass.png", + "celevator_car_glass.png", + }, + }, + { + _position = "020", + node_box = { + type = "fixed", + fixed = { + {-0.5,0.5,-0.5,0.5,0.6,0.5}, + {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, + {-0.5,0.6,-0.4,0.5,1,-0.1}, + }, + }, + tiles = { + "celevator_cabinet_sides.png", + "celevator_car_ceiling.png", + "celevator_car_wallpaper.png", + "celevator_cabinet_sides.png", + "celevator_cabinet_sides.png", + "celevator_dooroperator_left.png", + }, + _pi = true, + }, + { + _position = "021", + node_box = { + type = "fixed", + fixed = { + {-0.5,0.5,-0.5,0.5,0.6,0.5}, + {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, + }, + }, + tiles = { + "celevator_cabinet_sides.png^celevator_car_top_center_overlay.png", + "celevator_car_ceiling.png", + "celevator_car_wallpaper.png", + "celevator_cabinet_sides.png^celevator_car_side_center_overlay.png", + "celevator_cabinet_sides.png", + }, + _cartopbox = true, + }, + { + _position = "022", + node_box = { + type = "fixed", + fixed = { + {-0.5,0.5,-0.5,0.5,0.6,0.5}, + {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, + {-0.45,-0.5,0.45,0.5,0.5,0.5}, + }, + }, + use_texture_alpha = "clip", + tiles = { + "celevator_cabinet_sides.png^celevator_car_top_hatch.png", + "celevator_car_ceiling.png", + "celevator_car_wallpaper.png", + "celevator_cabinet_sides.png", + "celevator_car_glass.png", + "celevator_car_glass.png", + }, + }, + { + _position = "120", + node_box = { + type = "fixed", + fixed = { + {-0.5,0.5,-0.5,0.5,0.6,0.5}, + {0.45,-0.5,-0.5,0.5,0.5,0.5}, + {-0.5,0.6,-0.4,0.5,1,-0.1}, + }, + }, + tiles = { + "celevator_cabinet_sides.png", + "celevator_car_ceiling.png", + "celevator_cabinet_sides.png", + "celevator_car_wallpaper.png", + "celevator_cabinet_sides.png", + "celevator_dooroperator_right.png", + }, + }, + { + _position = "121", + node_box = { + type = "fixed", + fixed = { + {-0.5,0.5,-0.5,0.5,0.6,0.5}, + {0.45,-0.5,-0.5,0.5,0.5,0.5}, + }, + }, + tiles = { + "celevator_cabinet_sides.png^celevator_car_top_center_overlay.png^[transformFX", + "celevator_car_ceiling.png", + "celevator_cabinet_sides.png^celevator_car_side_center_overlay.png", + "celevator_car_wallpaper.png", + "celevator_cabinet_sides.png", + }, + }, + { + _position = "122", + node_box = { + type = "fixed", + fixed = { + {-0.5,0.5,-0.5,0.5,0.6,0.5}, + {0.45,-0.5,-0.5,0.5,0.5,0.5}, + {-0.5,-0.5,0.45,0.45,0.5,0.5}, + }, + }, + use_texture_alpha = "clip", + tiles = { + "celevator_cabinet_sides.png^celevator_car_top_misc.png", + "celevator_car_ceiling.png", + "celevator_cabinet_sides.png", + "celevator_car_wallpaper.png", + "celevator_car_glass.png", + "celevator_car_glass.png", + }, + _tapehead = true, + }, +} + +celevator.car.register("glassback",pieces,vector.new(2,3,3)) + + +minetest.register_node("celevator:car_glassback",{ + description = "Glass-Back Elevator Car", + paramtype2 = "4dir", + buildable_to = true, + inventory_image = "celevator_car_inventory.png", + wield_image = "celevator_car_wield.png", + wield_scale = vector.new(1,1,10), + tiles = {"celevator_transparent.png"}, + after_place_node = function(pos,player) + if not player:is_player() then + minetest.remove_node(pos) + return true + end + local name = player:get_player_name() + local newnode = minetest.get_node(pos) + local facedir = minetest.dir_to_yaw(minetest.fourdir_to_dir(newnode.param2)) + for x=0,1,1 do + for y=0,2,1 do + for z=0,2,1 do + local offsetdesc = string.format("%dm to the right, %dm up, and %dm back",x,y,z) + local placeoffset = vector.new(x,y,z) + local placepos = vector.add(pos,vector.rotate_around_axis(placeoffset,vector.new(0,1,0),facedir)) + local replaces = minetest.get_node(placepos).name + if not (minetest.registered_nodes[replaces] and minetest.registered_nodes[replaces].buildable_to) then + minetest.chat_send_player(name,string.format("Can't place car here - position %s is blocked!",offsetdesc)) + minetest.remove_node(pos) + return true + end + if minetest.is_protected(placepos,name) and not minetest.check_player_privs(name,{protection_bypass=true}) then + minetest.chat_send_player(name,string.format("Can't place car here - position %s is protected!",offsetdesc)) + minetest.record_protection_violation(placepos,name) + minetest.remove_node(pos) + return true + end + end + end + end + for x=0,1,1 do + for y=0,2,1 do + for z=0,2,1 do + local piecename = string.format("celevator:car_glassback_%d%d%d",x,y,z) + local placeoffset = vector.new(x,y,z) + local placepos = vector.add(pos,vector.rotate_around_axis(placeoffset,vector.new(0,1,0),facedir)) + minetest.set_node(placepos,{name=piecename,param2=newnode.param2}) + end + end + end + end, +}) + +celevator.car.types.glassback.remove = function(rootpos,rootdir) + local toberemoved = { + ["celevator:car_top_box"] = true, + ["celevator:incar_pi_entity"] = true, + ["celevator:car_door"] = true, + } + for x=0,1,1 do + for y=0,2,1 do + for z=0,2,1 do + local piecename = string.format("celevator:car_glassback_%d%d%d",x,y,z) + local pieceoffset = vector.new(x,y,z) + local piecepos = vector.add(rootpos,vector.rotate_around_axis(pieceoffset,vector.new(0,1,0),rootdir)) + if minetest.get_node(piecepos).name == piecename then + minetest.remove_node(piecepos) + local erefs = minetest.get_objects_inside_radius(piecepos,0.5) + for _,ref in pairs(erefs) do + if ref:get_luaentity() and toberemoved[ref:get_luaentity().name] then + ref:remove() + end + end + end + end + end + end + local cartopboxpos = vector.add(rootpos,vector.rotate_around_axis(vector.new(0,3,1),vector.new(0,1,0),rootdir)) + local erefs = minetest.get_objects_inside_radius(cartopboxpos,0.5) + for _,ref in pairs(erefs) do + if ref:get_luaentity() and toberemoved[ref:get_luaentity().name] then + ref:remove() + end + end +end diff --git a/car_standard.lua b/car_standard.lua new file mode 100644 index 0000000..70cb91f --- /dev/null +++ b/car_standard.lua @@ -0,0 +1,419 @@ +local pieces = { + { + _position = "000", + node_box = { + type = "fixed", + fixed = { + {-0.5,-0.6,-0.5,0.5,-0.5,0.5}, + {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, + {-0.5,-1.5,-0.5,0.5,-0.6,-0.45}, + }, + }, + tiles = { + "celevator_car_floor.png^celevator_door_sill_single.png", + "celevator_car_bottom.png", + "celevator_car_wallpaper.png^celevator_car_wall_bottom.png^celevator_car_switch_panel.png", + "celevator_cabinet_sides.png^celevator_car_side_overlay.png^[transformR90", + "celevator_cabinet_sides.png", + }, + _keyswitches = true, + }, + { + _position = "001", + node_box = { + type = "fixed", + fixed = { + {-0.5,-0.6,-0.5,0.5,-0.5,0.5}, + {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, + }, + }, + tiles = { + "celevator_car_floor.png", + "celevator_car_bottom_center.png", + "celevator_car_wallpaper.png^celevator_car_wall_bottom.png^celevator_car_wall_vent.png", + "celevator_cabinet_sides.png^celevator_car_side_center_overlay.png", + "celevator_cabinet_sides.png", + }, + }, + { + _position = "002", + node_box = { + type = "fixed", + fixed = { + {-0.5,-0.6,-0.5,0.5,-0.5,0.5}, + {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, + {-0.45,-0.5,0.45,0.5,0.5,0.5}, + }, + }, + tiles = { + "celevator_car_floor.png", + "celevator_car_bottom.png", + "celevator_car_wallpaper.png^celevator_car_wall_bottom.png", + "celevator_cabinet_sides.png^celevator_car_side_overlay.png", + "celevator_cabinet_sides.png", + "celevator_car_wallpaper.png^celevator_car_wall_bottom.png", + }, + }, + { + _position = "100", + node_box = { + type = "fixed", + fixed = { + {-0.5,-0.6,-0.5,0.5,-0.5,0.5}, + {0.45,-0.5,-0.5,0.5,0.5,0.5}, + {-0.5,-1.5,-0.5,0.5,-0.6,-0.45}, + }, + }, + tiles = { + "celevator_car_floor.png^celevator_door_sill_double.png", + "celevator_car_bottom.png", + "celevator_cabinet_sides.png^celevator_car_side_overlay.png", + "celevator_car_wallpaper.png^celevator_car_wall_bottom.png", + "celevator_cabinet_sides.png", + }, + }, + { + _position = "101", + node_box = { + type = "fixed", + fixed = { + {-0.5,-0.6,-0.5,0.5,-0.5,0.5}, + {0.45,-0.5,-0.5,0.5,0.5,0.5}, + }, + }, + tiles = { + "celevator_car_floor.png", + "celevator_car_bottom_center.png^[transformFX", + "celevator_cabinet_sides.png^celevator_car_side_center_overlay.png", + "celevator_car_wallpaper.png^celevator_car_wall_bottom.png^celevator_car_wall_vent.png", + "celevator_cabinet_sides.png", + }, + }, + { + _position = "102", + node_box = { + type = "fixed", + fixed = { + {-0.5,-0.6,-0.5,0.5,-0.5,0.5}, + {0.45,-0.5,-0.5,0.5,0.5,0.5}, + {-0.5,-0.5,0.45,0.45,0.5,0.5}, + }, + }, + tiles = { + "celevator_car_floor.png", + "celevator_car_bottom.png", + "celevator_cabinet_sides.png^celevator_car_side_overlay.png^[transformR90", + "celevator_car_wallpaper.png^celevator_car_wall_bottom.png", + "celevator_cabinet_sides.png", + "celevator_car_wallpaper.png^celevator_car_wall_bottom.png", + }, + }, + { + _position = "010", + node_box = { + type = "fixed", + fixed = { + {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, + }, + }, + tiles = { + "celevator_cabinet_sides.png", + "celevator_cabinet_sides.png", + "celevator_car_wallpaper_2x.png^celevator_cop.png", + "celevator_cabinet_sides.png", + }, + _cop = true, + }, + { + _position = "011", + node_box = { + type = "fixed", + fixed = { + {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, + }, + }, + tiles = { + "celevator_cabinet_sides.png", + "celevator_cabinet_sides.png", + "celevator_car_wallpaper.png^celevator_car_handrail_end.png", + "celevator_cabinet_sides.png^celevator_car_side_center2_overlay.png", + "celevator_cabinet_sides.png", + }, + }, + { + _position = "012", + node_box = { + type = "fixed", + fixed = { + {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, + {-0.45,-0.5,0.45,0.5,0.5,0.5}, + }, + }, + tiles = { + "celevator_cabinet_sides.png", + "celevator_cabinet_sides.png", + "celevator_car_wallpaper.png^(celevator_car_handrail_end.png^[transformFX)", + "celevator_cabinet_sides.png", + "celevator_cabinet_sides.png", + "celevator_car_wallpaper.png^celevator_car_handrail_end.png", + }, + }, + { + _position = "110", + node_box = { + type = "fixed", + fixed = { + {0.45,-0.5,-0.5,0.5,0.5,0.5}, + }, + }, + tiles = { + "celevator_cabinet_sides.png", + "celevator_cabinet_sides.png", + "celevator_cabinet_sides.png", + "celevator_car_wallpaper.png^(celevator_car_handrail_end.png^[transformFX)", + "celevator_cabinet_sides.png", + }, + }, + { + _position = "111", + node_box = { + type = "fixed", + fixed = { + {0.45,-0.5,-0.5,0.5,0.5,0.5}, + }, + }, + tiles = { + "celevator_cabinet_sides.png", + "celevator_cabinet_sides.png", + "celevator_cabinet_sides.png^celevator_car_side_center2_overlay.png", + "celevator_car_wallpaper.png^celevator_car_handrail_center.png", + "celevator_cabinet_sides.png", + }, + }, + { + _position = "112", + node_box = { + type = "fixed", + fixed = { + {0.45,-0.5,-0.5,0.5,0.5,0.5}, + {-0.5,-0.5,0.45,0.45,0.5,0.5}, + }, + }, + tiles = { + "celevator_cabinet_sides.png", + "celevator_cabinet_sides.png", + "celevator_cabinet_sides.png", + "celevator_car_wallpaper.png^celevator_car_handrail_end.png", + "celevator_cabinet_sides.png", + "celevator_car_wallpaper.png^(celevator_car_handrail_end.png^[transformFX)", + }, + }, + { + _position = "020", + node_box = { + type = "fixed", + fixed = { + {-0.5,0.5,-0.5,0.5,0.6,0.5}, + {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, + {-0.5,0.6,-0.4,0.5,1,-0.1}, + }, + }, + tiles = { + "celevator_cabinet_sides.png", + "celevator_car_ceiling.png", + "celevator_car_wallpaper.png", + "celevator_cabinet_sides.png", + "celevator_cabinet_sides.png", + "celevator_dooroperator_left.png", + }, + _pi = true, + }, + { + _position = "021", + node_box = { + type = "fixed", + fixed = { + {-0.5,0.5,-0.5,0.5,0.6,0.5}, + {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, + }, + }, + tiles = { + "celevator_cabinet_sides.png^celevator_car_top_center_overlay.png", + "celevator_car_ceiling.png", + "celevator_car_wallpaper.png", + "celevator_cabinet_sides.png^celevator_car_side_center_overlay.png", + "celevator_cabinet_sides.png", + }, + _cartopbox = true, + }, + { + _position = "022", + node_box = { + type = "fixed", + fixed = { + {-0.5,0.5,-0.5,0.5,0.6,0.5}, + {-0.5,-0.5,-0.5,-0.45,0.5,0.5}, + {-0.45,-0.5,0.45,0.5,0.5,0.5}, + }, + }, + tiles = { + "celevator_cabinet_sides.png^celevator_car_top_hatch.png", + "celevator_car_ceiling.png", + "celevator_car_wallpaper.png", + "celevator_cabinet_sides.png", + "celevator_cabinet_sides.png", + "celevator_car_wallpaper.png", + }, + }, + { + _position = "120", + node_box = { + type = "fixed", + fixed = { + {-0.5,0.5,-0.5,0.5,0.6,0.5}, + {0.45,-0.5,-0.5,0.5,0.5,0.5}, + {-0.5,0.6,-0.4,0.5,1,-0.1}, + }, + }, + tiles = { + "celevator_cabinet_sides.png", + "celevator_car_ceiling.png", + "celevator_cabinet_sides.png", + "celevator_car_wallpaper.png", + "celevator_cabinet_sides.png", + "celevator_dooroperator_right.png", + }, + }, + { + _position = "121", + node_box = { + type = "fixed", + fixed = { + {-0.5,0.5,-0.5,0.5,0.6,0.5}, + {0.45,-0.5,-0.5,0.5,0.5,0.5}, + }, + }, + tiles = { + "celevator_cabinet_sides.png^celevator_car_top_center_overlay.png^[transformFX", + "celevator_car_ceiling.png", + "celevator_cabinet_sides.png^celevator_car_side_center_overlay.png", + "celevator_car_wallpaper.png", + "celevator_cabinet_sides.png", + }, + }, + { + _position = "122", + node_box = { + type = "fixed", + fixed = { + {-0.5,0.5,-0.5,0.5,0.6,0.5}, + {0.45,-0.5,-0.5,0.5,0.5,0.5}, + {-0.5,-0.5,0.45,0.45,0.5,0.5}, + }, + }, + tiles = { + "celevator_cabinet_sides.png^celevator_car_top_misc.png", + "celevator_car_ceiling.png", + "celevator_cabinet_sides.png", + "celevator_car_wallpaper.png", + "celevator_cabinet_sides.png", + "celevator_car_wallpaper.png", + }, + _tapehead = true, + }, +} + +celevator.car.register("standard",pieces,vector.new(2,3,3)) + +for x=0,1,1 do + for y=0,2,1 do + for z=0,2,1 do + minetest.register_alias(string.format("celevator:car_%d%d%d",x,y,z),string.format("celevator:car_standard_%d%d%d",x,y,z)) + end + end +end + +minetest.register_node("celevator:car_standard",{ + description = "Basic Elevator Car", + paramtype2 = "4dir", + buildable_to = true, + inventory_image = "celevator_car_inventory.png", + wield_image = "celevator_car_wield.png", + wield_scale = vector.new(1,1,10), + tiles = {"celevator_transparent.png"}, + after_place_node = function(pos,player) + if not player:is_player() then + minetest.remove_node(pos) + return true + end + local name = player:get_player_name() + local newnode = minetest.get_node(pos) + local facedir = minetest.dir_to_yaw(minetest.fourdir_to_dir(newnode.param2)) + for x=0,1,1 do + for y=0,2,1 do + for z=0,2,1 do + local offsetdesc = string.format("%dm to the right, %dm up, and %dm back",x,y,z) + local placeoffset = vector.new(x,y,z) + local placepos = vector.add(pos,vector.rotate_around_axis(placeoffset,vector.new(0,1,0),facedir)) + local replaces = minetest.get_node(placepos).name + if not (minetest.registered_nodes[replaces] and minetest.registered_nodes[replaces].buildable_to) then + minetest.chat_send_player(name,string.format("Can't place car here - position %s is blocked!",offsetdesc)) + minetest.remove_node(pos) + return true + end + if minetest.is_protected(placepos,name) and not minetest.check_player_privs(name,{protection_bypass=true}) then + minetest.chat_send_player(name,string.format("Can't place car here - position %s is protected!",offsetdesc)) + minetest.record_protection_violation(placepos,name) + minetest.remove_node(pos) + return true + end + end + end + end + for x=0,1,1 do + for y=0,2,1 do + for z=0,2,1 do + local piecename = string.format("celevator:car_standard_%d%d%d",x,y,z) + local placeoffset = vector.new(x,y,z) + local placepos = vector.add(pos,vector.rotate_around_axis(placeoffset,vector.new(0,1,0),facedir)) + minetest.set_node(placepos,{name=piecename,param2=newnode.param2}) + end + end + end + end, +}) + +minetest.register_alias("celevator:car","celevator:car_standard") + +celevator.car.types.standard.remove = function(rootpos,rootdir) + local toberemoved = { + ["celevator:car_top_box"] = true, + ["celevator:incar_pi_entity"] = true, + ["celevator:car_door"] = true, + } + for x=0,1,1 do + for y=0,2,1 do + for z=0,2,1 do + local piecename = string.format("celevator:car_standard_%d%d%d",x,y,z) + local pieceoffset = vector.new(x,y,z) + local piecepos = vector.add(rootpos,vector.rotate_around_axis(pieceoffset,vector.new(0,1,0),rootdir)) + if minetest.get_node(piecepos).name == piecename then + minetest.remove_node(piecepos) + local erefs = minetest.get_objects_inside_radius(piecepos,0.5) + for _,ref in pairs(erefs) do + if ref:get_luaentity() and toberemoved[ref:get_luaentity().name] then + ref:remove() + end + end + end + end + end + end + local cartopboxpos = vector.add(rootpos,vector.rotate_around_axis(vector.new(0,3,1),vector.new(0,1,0),rootdir)) + local erefs = minetest.get_objects_inside_radius(cartopboxpos,0.5) + for _,ref in pairs(erefs) do + if ref:get_luaentity() and toberemoved[ref:get_luaentity().name] then + ref:remove() + end + end +end @@ -44,7 +44,7 @@ minetest.register_craft({ }) minetest.register_craft({ - output = "celevator:car", + output = "celevator:car_standard", recipe = { {"default:steel_ingot","default:steel_ingot","default:steel_ingot"}, {"mesecons_button:button_off","celevator:hwdoor_glass","default:steel_ingot"}, @@ -53,6 +53,15 @@ minetest.register_craft({ }) minetest.register_craft({ + output = "celevator:car_glassback", + recipe = { + {"default:steel_ingot","default:steel_ingot","default:steel_ingot"}, + {"mesecons_button:button_off","celevator:hwdoor_glass","default:glass"}, + {"mesecons_switch:mesecon_switch_off","default:steel_ingot","default:steel_ingot"}, + }, +}) + +minetest.register_craft({ output = "celevator:controller", recipe = { {"basic_materials:steel_strip","basic_materials:ic","basic_materials:steel_strip"}, @@ -271,7 +271,8 @@ function celevator.doors.hwopen(pos,drivepos) pmeta:set_string("data",minetest.serialize(hwdoors_moving[hash])) pmeta:set_string("state","opening") local carpos = vector.add(pos,fdir) - if celevator.get_node(carpos).name == "celevator:car_000" then + local carndef = minetest.registered_nodes[celevator.get_node(carpos).name] or {} + if carndef._root then celevator.doors.caropen(carpos) end elseif hwdoors_moving[hash].direction == "close" then @@ -280,7 +281,8 @@ function celevator.doors.hwopen(pos,drivepos) celevator.storage:set_string("hwdoors_moving",minetest.serialize(hwdoors_moving)) local fdir = minetest.fourdir_to_dir(hwdoors_moving[hash].param2) local carpos = vector.add(pos,fdir) - if celevator.get_node(carpos).name == "celevator:car_000" then + local carndef = minetest.registered_nodes[celevator.get_node(carpos).name] or {} + if carndef._root then celevator.doors.caropen(carpos) end minetest.set_node(pos,{name="celevator:hwdoor_placeholder",param2=hwdoors_moving[hash].param2}) @@ -301,7 +303,8 @@ function celevator.doors.hwclose(pos,drivepos,nudge) if state ~= "open" then return end local fdir = minetest.fourdir_to_dir(celevator.get_node(pos).param2) local carpos = vector.add(pos,fdir) - if celevator.get_node(carpos).name == "celevator:car_000" then + local carndef = minetest.registered_nodes[celevator.get_node(carpos).name] or {} + if carndef._root then celevator.doors.carclose(carpos,nudge) end local data = minetest.deserialize(pmeta:get_string("data")) @@ -619,7 +622,7 @@ end minetest.register_abm({ label = "Respawn car doors", - nodenames = {"celevator:car_000"}, + nodenames = {"group:_celevator_car_root"}, interval = 1, chance = 1, action = function(pos) diff --git a/drive_entity.lua b/drive_entity.lua index 5ac8fbb..fbafada 100644 --- a/drive_entity.lua +++ b/drive_entity.lua @@ -268,7 +268,8 @@ function celevator.drives.entity.nodestoentities(nodes,ename) }) eref:set_yaw(minetest.dir_to_yaw(minetest.fourdir_to_dir(node.param2))) table.insert(refs,eref) - if node.name == "celevator:car_021" or node.name == "celevator:car_122" then + local ndef = minetest.registered_nodes[node.name] or {} + if ndef._cartopbox or ndef._tapehead then local toppos = vector.add(pos,vector.new(0,1,0)) local topattach = minetest.get_objects_inside_radius(toppos,0.75) for _,ref in pairs(topattach) do @@ -402,7 +403,10 @@ function celevator.drives.entity.step(dtime) end end local carparam2 = celevator.get_node(nodes[1]).param2 + local cardef = minetest.registered_nodes[celevator.get_node(nodes[1]).name] or {} + local cartype = cardef._celevator_car_type or "standard" meta:set_int("carparam2",carparam2) + meta:set_string("cartype",cartype) local handles = celevator.drives.entity.nodestoentities(nodes) celevator.drives.entity.entityinfo[hash] = { handles = handles, @@ -440,7 +444,8 @@ function celevator.drives.entity.step(dtime) local ok = celevator.drives.entity.entitiestonodes(handles,carid) if not ok then local carparam2 = meta:get_int("carparam2") - celevator.car.spawncar(vector.round(vector.add(origin,vector.new(0,apos,0))),minetest.dir_to_yaw(minetest.fourdir_to_dir(carparam2)),carid) + local cartype = meta:get_string("cartype") + celevator.car.spawncar(vector.round(vector.add(origin,vector.new(0,apos,0))),minetest.dir_to_yaw(minetest.fourdir_to_dir(carparam2)),carid,cartype) end apos = math.floor(apos+0.5) minetest.after(0.25,celevator.drives.entity.updatecopformspec,pos) @@ -485,7 +490,8 @@ function celevator.drives.entity.step(dtime) motorsound(pos,"idle") celevator.drives.entity.sheavetonode(carid) local carparam2 = meta:get_int("carparam2") - celevator.car.spawncar(vector.round(vector.add(origin,vector.new(0,apos,0))),minetest.dir_to_yaw(minetest.fourdir_to_dir(carparam2)),carid) + local cartype = meta:get_string("cartype") + celevator.car.spawncar(vector.round(vector.add(origin,vector.new(0,apos,0))),minetest.dir_to_yaw(minetest.fourdir_to_dir(carparam2)),carid,cartype) apos = math.floor(apos+0.5) minetest.after(0.25,celevator.drives.entity.updatecopformspec,pos) table.remove(entitydrives_running,i) @@ -1027,9 +1033,10 @@ function celevator.drives.entity.updatecopformspec(drivepos) for hash in pairs(carnodes) do local piecepos = minetest.get_position_from_hash(hash) local piece = celevator.get_node(piecepos) - if piece.name == "celevator:car_010" then + local ndef = minetest.registered_nodes[piece.name] or {} + if ndef._cop then celevator.get_meta(piecepos):set_string("formspec",copformspec) - elseif piece.name == "celevator:car_000" then + elseif ndef._keyswitches then celevator.get_meta(piecepos):set_string("formspec",switchformspec) end end @@ -1,6 +1,8 @@ local components = { "framework", "car", + "car_standard", + "car_glassback", "doors", "drive_null", "drive_entity", diff --git a/textures/celevator_car_glass.png b/textures/celevator_car_glass.png Binary files differnew file mode 100644 index 0000000..025c1ec --- /dev/null +++ b/textures/celevator_car_glass.png |