mirror of
https://github.com/Sokomine/travelnet.git
synced 2024-08-20 05:24:18 +02:00
several improvements for elevator; fixed bug with elevator_top
This commit is contained in:
parent
e8544e75e4
commit
6dbd41a67e
25
elevator.lua
25
elevator.lua
@ -1,6 +1,6 @@
|
||||
|
||||
minetest.register_node("travelnet:elevator", {
|
||||
description = "Travelnet Elevator Bottom",
|
||||
description = "Elevator",
|
||||
|
||||
drawtype = "nodebox",
|
||||
sunlight_propagates = true,
|
||||
@ -44,7 +44,7 @@ minetest.register_node("travelnet:elevator", {
|
||||
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
meta:set_string("infotext", "Travelnet Elevator (unconfigured)");
|
||||
meta:set_string("infotext", "Elevator (unconfigured)");
|
||||
meta:set_string("station_name", "");
|
||||
meta:set_string("station_network","");
|
||||
meta:set_string("owner", placer:get_player_name() );
|
||||
@ -55,6 +55,10 @@ minetest.register_node("travelnet:elevator", {
|
||||
-- "field[0.3,6.6;6,0.7;station_network;Assign to Network:;]"..
|
||||
-- "field[0.3,7.6;6,0.7;owner_name;(optional) owned by:;]"..
|
||||
"button_exit[6.3,6.2;1.7,0.7;station_set;Store]" );
|
||||
|
||||
local p = {x=pos.x, y=pos.y+1, z=pos.z}
|
||||
local p2 = minetest.dir_to_facedir(placer:get_look_dir())
|
||||
minetest.env:add_node(p, {name="travelnet:elevator_top", paramtype2="facedir", param2=p2})
|
||||
end,
|
||||
|
||||
on_receive_fields = travelnet.on_receive_fields,
|
||||
@ -72,14 +76,13 @@ minetest.register_node("travelnet:elevator", {
|
||||
|
||||
-- taken from VanessaEs homedecor fridge
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local pos = pointed_thing.above;
|
||||
if( minetest.env:get_node({x=pos.x, y=pos.y+1, z=pos.z}).name ~= "air" ) then
|
||||
local pos = pointed_thing.above;
|
||||
local node = minetest.env:get_node({x=pos.x, y=pos.y+1, z=pos.z});
|
||||
-- leftover elevator_top nodes can be removed by placing a new elevator underneath
|
||||
if( node ~= nil and node.name ~= "air" and node.name ~= 'travelnet:elevator_top') then
|
||||
minetest.chat_send_player( placer:get_player_name(), 'Not enough vertical space to place the travelnet box!' )
|
||||
return;
|
||||
end
|
||||
local p = {x=pos.x, y=pos.y+1, z=pos.z}
|
||||
local p2 = minetest.dir_to_facedir(placer:get_look_dir())
|
||||
minetest.env:add_node(p, {name="travelnet:elevator_top", paramtype2="facedir", param2=p2})
|
||||
return minetest.item_place(itemstack, placer, pointed_thing);
|
||||
end,
|
||||
|
||||
@ -90,7 +93,7 @@ minetest.register_node("travelnet:elevator", {
|
||||
})
|
||||
|
||||
minetest.register_node("travelnet:elevator_top", {
|
||||
description = "Travelnet Elevator Top",
|
||||
description = "Elevator Top",
|
||||
|
||||
drawtype = "nodebox",
|
||||
sunlight_propagates = true,
|
||||
@ -130,7 +133,7 @@ minetest.register_node("travelnet:elevator_top", {
|
||||
|
||||
light_source = 10,
|
||||
|
||||
groups = {cracky=1,choppy=1,snappy=1},
|
||||
groups = {cracky=1,choppy=1,snappy=1,not_in_creative_inventory=1},
|
||||
})
|
||||
|
||||
if( minetest.get_modpath("technic") ~= nil ) then
|
||||
@ -162,7 +165,7 @@ minetest.register_node("travelnet:elevator_door_steel_open", {
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = true,
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
|
||||
-- larger than one node but slightly smaller than a half node so that wallmounted torches pose no problem
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
@ -221,7 +224,7 @@ minetest.register_node("travelnet:elevator_door_glass_open", {
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = true,
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
|
||||
-- larger than one node but slightly smaller than a half node so that wallmounted torches pose no problem
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
|
37
init.lua
37
init.lua
@ -19,6 +19,11 @@
|
||||
|
||||
|
||||
Changelog:
|
||||
21.06.13 - bugfix: wielding an elevator while digging a door caused the elevator_top to be placed
|
||||
- leftover floating elevator_top nodes can be removed by placing a new travelnet:elevator underneath them and removing that afterwards
|
||||
- homedecor-doors are now opened and closed correctly as well
|
||||
- removed nodes that are not intended for manual use from creative inventory
|
||||
- improved naming of station levels for the elevator
|
||||
21.06.13 - elevator stations are sorted by height instead of date of creation as is the case with travelnet boxes
|
||||
- elevator stations are named automaticly
|
||||
20.06.13 - doors can be opened and closed from inside the travelnet box/elevator
|
||||
@ -237,17 +242,19 @@ travelnet.update_formspec = function( pos, puncher_name )
|
||||
end
|
||||
|
||||
if( open_door_cmd ) then
|
||||
formspec = formspec .."button_exit["..(x)..","..(y+2.5)..";4,0.5;open_door;Open/Close door"
|
||||
formspec = formspec .."label["..(x)..","..(y+2.5)..";"..tostring( k )..":]"..
|
||||
"button_exit["..(x+3)..","..(y+2.5)..";1,0.5;open_door;<>]";
|
||||
elseif( is_elevator ) then
|
||||
formspec = formspec .."button_exit["..(x)..","..(y+2.5)..";4,0.5;target;"..tostring( travelnet.targets[ owner_name ][ station_network ][ k ].nr )
|
||||
formspec = formspec .."label["..(x)..","..(y+2.5)..";"..tostring( k )..":]"..
|
||||
"button_exit["..(x+3)..","..(y+2.5)..";1,0.5;target;"..tostring( travelnet.targets[ owner_name ][ station_network ][ k ].nr ).."]";
|
||||
else
|
||||
formspec = formspec .."button_exit["..(x)..","..(y+2.5)..";4,0.5;target;"..k
|
||||
formspec = formspec .."button_exit["..(x)..","..(y+2.5)..";4,0.5;target;"..k.."]";
|
||||
end
|
||||
|
||||
if( is_elevator ) then
|
||||
formspec = formspec ..' ('..tostring( travelnet.targets[ owner_name ][ station_network ][ k ].pos.y )..'m)';
|
||||
end
|
||||
formspec = formspec .. ']';
|
||||
-- if( is_elevator ) then
|
||||
-- formspec = formspec ..' ('..tostring( travelnet.targets[ owner_name ][ station_network ][ k ].pos.y )..'m)';
|
||||
-- end
|
||||
-- formspec = formspec .. ']';
|
||||
|
||||
y = y+1;
|
||||
--x = x+4;
|
||||
@ -381,14 +388,24 @@ travelnet.open_close_door = function( pos, player, mode )
|
||||
local door_node = minetest.env:get_node( pos2 );
|
||||
if( door_node ~= nil and door_node.name ~= 'ignore' and door_node.name ~= 'air' and minetest.registered_nodes[ door_node.name ].on_rightclick ~= nil) then
|
||||
|
||||
-- at least for homedecor, same facedir would mean "door closed"
|
||||
|
||||
-- do not close the elevator door if it is already closed
|
||||
if( mode==1 and ( door_node.name == 'travelnet:elevator_door_glass_closed'
|
||||
or door_node.name == 'travelnet:elevator_door_steel_closed')) then
|
||||
or door_node.name == 'travelnet:elevator_door_steel_closed'
|
||||
-- handle doors that change their facedir
|
||||
or ( door_node.param2 == this_node.param2
|
||||
and door_node.name ~= 'travelnet:elevator_door_glass_open'
|
||||
and door_node.name ~= 'travelnet:elevator_door_steel_open'))) then
|
||||
return;
|
||||
end
|
||||
-- do not open the doors if they are already open (works only on elevator-doors; not on doors in general)
|
||||
if( mode==2 and ( door_node.name == 'travelnet:elevator_door_glass_open'
|
||||
or door_node.name == 'travelnet:elevator_door_steel_open')) then
|
||||
or door_node.name == 'travelnet:elevator_door_steel_open'
|
||||
-- handle doors that change their facedir
|
||||
or ( door_node.param2 ~= this_node.param2
|
||||
and door_node.name ~= 'travelnet:elevator_door_glass_closed'
|
||||
and door_node.name ~= 'travelnet:elevator_door_steel_closed'))) then
|
||||
return;
|
||||
end
|
||||
|
||||
@ -447,7 +464,7 @@ travelnet.on_receive_fields = function(pos, formname, fields, player)
|
||||
local this_node = minetest.env:get_node( pos );
|
||||
if( this_node ~= nil and this_node.name == 'travelnet:elevator' ) then
|
||||
for k,v in pairs( travelnet.targets[ owner_name ][ station_network ] ) do
|
||||
if( travelnet.targets[ owner_name ][ station_network ][ k ].nr..' ('..tostring( travelnet.targets[ owner_name ][ station_network ][ k ].pos.y )..'m)'
|
||||
if( travelnet.targets[ owner_name ][ station_network ][ k ].nr --..' ('..tostring( travelnet.targets[ owner_name ][ station_network ][ k ].pos.y )..'m)'
|
||||
== fields.target) then
|
||||
fields.target = k;
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user