More changes to the vents mod.

This commit is contained in:
Nathan Salapat 2022-05-23 20:51:28 -05:00
parent 89c7571db4
commit 96eae6f6da
13 changed files with 93 additions and 150 deletions

View File

@ -44,12 +44,8 @@ Tube:register_on_tube_update(function(node, pos, out_dir, peer_pos, peer_in_dir)
end) end)
minetest.register_node("vents:junction", { minetest.register_node("vents:junction", {
description = S("Hyperloop Junction Block"), description = S("Vent Junction"),
tiles = { tiles = {"vents_station_connection.png"},
"hyperloop_junction_top.png",
"hyperloop_junction_top.png",
"hyperloop_station_connection.png",
},
after_place_node = function(pos, placer, itemstack, pointed_thing) after_place_node = function(pos, placer, itemstack, pointed_thing)
vents.check_network_level(pos, placer) vents.check_network_level(pos, placer)
@ -67,27 +63,7 @@ minetest.register_node("vents:junction", {
paramtype2 = "facedir", paramtype2 = "facedir",
on_rotate = screwdriver.disallow, on_rotate = screwdriver.disallow,
paramtype = "light", paramtype = "light",
sunlight_propagates = true,
groups = {breakable=1}, groups = {breakable=1},
is_ground_content = false, is_ground_content = false,
sounds = {footstep = {name = 'metal', gain = 1}}, sounds = {footstep = {name = 'metal', gain = 1}},
}) })
-- for tube viaducts
minetest.register_node("vents:pillar", {
description = S("Hyperloop Pillar"),
tiles = {"hyperloop_tube_locked.png^[transformR90]"},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{ -3/8, -4/8, -3/8, 3/8, 4/8, 3/8},
},
},
on_rotate = screwdriver.disallow,
paramtype = "light",
sunlight_propagates = true,
is_ground_content = false,
groups = {breakable=1, stone = 2},
sounds = {footstep = {name = 'metal', gain = 1}},
})

View File

@ -30,43 +30,46 @@ local function store_station(pos, placer)
local facedir = vents.get_facedir(placer) local facedir = vents.get_facedir(placer)
-- do a facedir correction -- do a facedir correction
facedir = (facedir + 3) % 4 -- face to LCD facedir = (facedir + 3) % 4 -- face to LCD
Stations:set(pos, "Station", { Stations:set(pos, 'Station', {
owner = placer:get_player_name(), owner = placer:get_player_name(),
facedir = facedir, facedir = facedir,
time_blocked = 0}) time_blocked = 0})
end end
local function naming_formspec(pos) local function naming_formspec(pos)
local data = Stations:get(pos)
local vent = data.name or 'vent'
local info = data.booking_info or ''
local formspec = local formspec =
"size[7,4.4]".. 'size[7,4.4]'..
"label[0,0;"..S("Please enter the vent name.").."]" .. 'label[0,0;'..S('Please enter the vent name.')..']' ..
"field[0.2,1.5;7.1,1;name;"..S("Vent name")..";Vent]" .. 'field[0.2,1.5;7.1,1;name;'..S('Vent name')..';'..vent..']' ..
"field[0.2,2.7;7.1,1;info;"..S("Additional vent information")..";]" .. 'field[0.2,2.7;7.1,1;info;'..S('Additional vent information')..';'..info..']' ..
"button_exit[2.5,3.7;2,1;exit;Save]" 'button_exit[2.5,3.7;2,1;exit;Save]'
return formspec return formspec
end end
-- Form spec for the station list -- Form spec for the station list
local function generate_string(sortedList) local function generate_string(sortedList)
local tRes = {"size[12,8]".. local tRes = {'size[12,8]'..
"label[4,0; "..S("Select your destination").."]"} 'label[4,0; '..S('Select your destination')..']'}
tRes[2] = "tablecolumns[text,width=20;text,width=6,align=right;text]" tRes[2] = 'tablecolumns[text,width=20;text,width=6,align=right;text]'
local stations = {} local stations = {}
for idx,tDest in ipairs(sortedList) do for idx,tDest in ipairs(sortedList) do
local name = tDest.name or S("<unknown>") local name = tDest.name or S('<unknown>')
local distance = tDest.distance or 0 local distance = tDest.distance or 0
local info = tDest.booking_info or "" local info = tDest.booking_info or ''
stations[#stations+1] = minetest.formspec_escape(string.sub(name, 1, 28)) stations[#stations+1] = minetest.formspec_escape(string.sub(name, 1, 28))
stations[#stations+1] = distance.."m" stations[#stations+1] = distance..'m'
stations[#stations+1] = minetest.formspec_escape(info) stations[#stations+1] = minetest.formspec_escape(info)
end end
if #stations>0 then if #stations>0 then
tRes[#tRes+1] = "table[0,1;11.8,7.2;button;"..table.concat(stations, ",").."]" tRes[#tRes+1] = 'table[0,1;11.8,7.2;button;'..table.concat(stations, ',')..']'
else else
tRes[#tRes+1] = "button_exit[4,4;3,1;button;Update]" tRes[#tRes+1] = 'button_exit[4,4;3,1;button;Update]'
end end
return table.concat(tRes) return table.concat(tRes)
@ -92,7 +95,7 @@ end
local function filter_subnet(sortedList, subnet) local function filter_subnet(sortedList, subnet)
if vents.subnet_enabled then if vents.subnet_enabled then
if subnet == "" then if subnet == '' then
subnet = nil subnet = nil
end end
@ -112,7 +115,7 @@ end
local function station_list_as_string(pos, subnet) local function station_list_as_string(pos, subnet)
local meta = M(pos) local meta = M(pos)
-- Generate a name sorted list of all connected stations -- Generate a name sorted list of all connected stations
local sortedList = Stations:station_list(pos, pos, "name") local sortedList = Stations:station_list(pos, pos, 'name')
-- remove all junctions from the list -- remove all junctions from the list
sortedList = remove_junctions(sortedList) sortedList = remove_junctions(sortedList)
-- use subnet pattern to reduce the list -- use subnet pattern to reduce the list
@ -130,14 +133,14 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if fields.exit then if fields.exit then
if fields.name ~= nil then if fields.name ~= nil then
local station_name = string.trim(fields.name) local station_name = string.trim(fields.name)
if station_name == "" then if station_name == '' then
return return
end end
if Stations:get(pos).booking_pos then --if Stations:get(pos).booking_pos then
minetest.chat_send_player(name, S("Remove and replace to change name.")) -- minetest.chat_send_player(name, S('Remove and replace to change name.'))
--Figure out how to allow a builder to update station. --Figure out how to allow a builder to update station.
return -- return
end --end
-- store meta and generate station formspec -- store meta and generate station formspec
Stations:update(pos, { Stations:update(pos, {
name = station_name, name = station_name,
@ -146,16 +149,16 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
}) })
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Station: "..station_name) meta:set_string('infotext', 'Station: '..station_name)
minetest.chat_send_player(name, 'Saving data') minetest.chat_send_player(name, 'Saving data')
else else
vents.chat(player, S("Invalid station name!")) vents.chat(player, S('Invalid station name!'))
end end
end end
elseif formname == 'vents:station_list' then elseif formname == 'vents:station_list' then
local te = minetest.explode_table_event(fields.button) local te = minetest.explode_table_event(fields.button)
local idx = tonumber(te.row) local idx = tonumber(te.row)
if idx and te.type=="CHG" then if idx and te.type=='CHG' then
local tStation, src_pos = vents.get_base_station(pos) local tStation, src_pos = vents.get_base_station(pos)
local dest_pos = tStationList[SP(pos)] and tStationList[SP(pos)][idx] local dest_pos = tStationList[SP(pos)] and tStationList[SP(pos)][idx]
if dest_pos and tStation then if dest_pos and tStation then
@ -174,24 +177,20 @@ end)
local function on_destruct(pos) local function on_destruct(pos)
Stations:update((pos), { Stations:update((pos), {
booking_pos = "nil", booking_pos = 'nil',
booking_info = "nil", booking_info = 'nil',
name = "Station", name = 'Station',
}) })
end end
minetest.register_node("vents:station", { minetest.register_node('vents:station', {
description = S("Vent Access"), description = S('Vent Access'),
drawtype = "nodebox", drawtype = 'nodebox',
tiles = { tiles = {'vents_station.png'},
"hyperloop_station.png",
"hyperloop_station_connection.png",
"hyperloop_station_connection.png",
},
after_place_node = function(pos, placer, itemstack, pointed_thing) after_place_node = function(pos, placer, itemstack, pointed_thing)
vents.check_network_level(pos, placer) vents.check_network_level(pos, placer)
M(pos):set_string("infotext", S("Access Point")) M(pos):set_string('infotext', S('Access Point'))
store_station(pos, placer) store_station(pos, placer)
Tube:after_place_node(pos) Tube:after_place_node(pos)
end, end,
@ -201,7 +200,7 @@ minetest.register_node("vents:station", {
local player_attributes = clicker:get_meta() local player_attributes = clicker:get_meta()
local mode = player_attributes:get_string('mode') local mode = player_attributes:get_string('mode')
vents.player_pos[name] = pos vents.player_pos[name] = pos
if mode == 'traitor' then if mode == 'traitor' or mode == 'solo' or mode == 'ghost' then --allow everybody but crew mambers to use.
minetest.show_formspec(name, 'vents:station_list', station_list_as_string(pos)) minetest.show_formspec(name, 'vents:station_list', station_list_as_string(pos))
elseif mode == 'builder' then elseif mode == 'builder' then
minetest.show_formspec(name, 'vents:setup', naming_formspec(pos)) minetest.show_formspec(name, 'vents:setup', naming_formspec(pos))
@ -217,7 +216,8 @@ minetest.register_node("vents:station", {
on_destruct = on_destruct, on_destruct = on_destruct,
on_rotate = screwdriver.disallow, on_rotate = screwdriver.disallow,
paramtype2 = "facedir", paramtype = 'light',
paramtype2 = 'facedir',
groups = {breakable=1}, groups = {breakable=1},
is_ground_content = false, is_ground_content = false,
sounds = {footstep = {name = 'metal', gain = 1}}, sounds = {footstep = {name = 'metal', gain = 1}},

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 194 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -23,14 +23,14 @@ local function station_name(pos)
local dataSet = vents.get_station(pos) local dataSet = vents.get_station(pos)
if dataSet then if dataSet then
if dataSet.junction == true then if dataSet.junction == true then
return S("Junction at ")..SP(pos) return S('Junction at ')..SP(pos)
elseif dataSet.name ~= nil then elseif dataSet.name ~= nil then
return S("Station '")..dataSet.name.."' at "..SP(pos) return S('Station \'')..dataSet.name..'\' at '..SP(pos)
else else
return S("Station at ")..SP(pos) return S('Station at ')..SP(pos)
end end
end end
return S("Open end at ")..minetest.pos_to_string(pos) return S('Open end at ')..minetest.pos_to_string(pos)
end end
function vents.check_network_level(pos, player) function vents.check_network_level(pos, player)
@ -42,8 +42,8 @@ function vents.check_network_level(pos, player)
return return
end end
end end
vents.chat(player, S("There is no station/junction on this level. ").. vents.chat(player, S('There is no station/junction on this level. ')..
S("Do you really want to start a new network?!")) S('Do you really want to start a new network?!'))
end end
-- North, East, South, West, Down, Up -- North, East, South, West, Down, Up
@ -56,43 +56,43 @@ local Tube = tubelib2.Tube:new({
dirs_to_check = dirs_to_check, dirs_to_check = dirs_to_check,
max_tube_length = 1000, max_tube_length = 1000,
show_infotext = true, show_infotext = true,
primary_node_names = {"vents:tubeS", "vents:tubeS2", "vents:tubeA", "vents:tubeA2"}, primary_node_names = {'vents:tubeS', 'vents:tubeS2', 'vents:tubeA', 'vents:tubeA2'},
secondary_node_names = {"vents:junction", "vents:station", "vents:tube_wifi1"}, secondary_node_names = {'vents:junction', 'vents:station', 'vents:tube_wifi1'},
after_place_tube = function(pos, param2, tube_type, num_tubes) after_place_tube = function(pos, param2, tube_type, num_tubes)
if num_tubes == 2 then if num_tubes == 2 then
minetest.set_node(pos, {name = "vents:tube"..tube_type.."2", param2 = param2}) minetest.set_node(pos, {name = 'vents:tube'..tube_type..'2', param2 = param2})
else else
minetest.set_node(pos, {name = "vents:tube"..tube_type, param2 = param2}) minetest.set_node(pos, {name = 'vents:tube'..tube_type, param2 = param2})
end end
end, end,
}) })
vents.Tube = Tube vents.Tube = Tube
minetest.register_node("vents:tubeS", { minetest.register_node('vents:tubeS', {
description = S("Vent"), description = S('Vent'),
inventory_image = minetest.inventorycube("hyperloop_tube_locked.png", inventory_image = minetest.inventorycube('vents_tube.png',
'hyperloop_tube_open.png', "hyperloop_tube_locked.png"), 'hyperloop_tube_open.png', 'vents_tube.png'),
tiles = { tiles = {
-- up, down, right, left, back, front -- up, down, right, left, back, front
"hyperloop_tube_closed.png^[transformR90]", 'hyperloop_tube_closed.png^[transformR90]',
"hyperloop_tube_closed.png^[transformR90]", 'hyperloop_tube_closed.png^[transformR90]',
'hyperloop_tube_closed.png', 'hyperloop_tube_closed.png',
'hyperloop_tube_closed.png', 'hyperloop_tube_closed.png',
{ {
image = 'hyperloop_tube_open_active.png', image = 'hyperloop_tube_open_active.png',
backface_culling = false, backface_culling = false,
animation = { animation = {
type = "vertical_frames", type = 'vertical_frames',
aspect_w = 32, aspect_w = 32,
aspect_h = 32, aspect_h = 32,
length = 0.5, length = 0.5,
}, },
}, },
}, },
drawtype = "nodebox", drawtype = 'nodebox',
node_box = { node_box = {
type = "fixed", type = 'fixed',
fixed = { fixed = {
{-8/16, -8/16, -8/16, -7/16, 8/16, 8/16}, {-8/16, -8/16, -8/16, -7/16, 8/16, 8/16},
{ 7/16, -8/16, -8/16, 8/16, 8/16, 8/16}, { 7/16, -8/16, -8/16, 8/16, 8/16, 8/16},
@ -102,7 +102,7 @@ minetest.register_node("vents:tubeS", {
}, },
}, },
selection_box = { selection_box = {
type = "fixed", type = 'fixed',
fixed = {-8/16, -8/16, -8/16, 8/16, 8/16, 8/16}, fixed = {-8/16, -8/16, -8/16, 8/16, 8/16, 8/16},
}, },
@ -118,38 +118,36 @@ minetest.register_node("vents:tubeS", {
Tube:after_dig_tube(pos, oldnode, oldmetadata) Tube:after_dig_tube(pos, oldnode, oldmetadata)
end, end,
paramtype2 = "facedir", -- important! paramtype2 = 'facedir', -- important!
on_rotate = screwdriver.disallow, -- important! on_rotate = screwdriver.disallow, -- important!
paramtype = "light", paramtype = 'light',
light_source = 2,
sunlight_propagates = true,
is_ground_content = false, is_ground_content = false,
groups = {breakable=1}, groups = {breakable=1},
sounds = {footstep = {name = 'metal', gain = 1}}, sounds = {footstep = {name = 'metal', gain = 1}},
}) })
minetest.register_node("vents:tubeS2", { minetest.register_node('vents:tubeS2', {
description = "Vent", description = 'Vent',
tiles = { tiles = {
-- up, down, right, left, back, front -- up, down, right, left, back, front
"hyperloop_tube_locked.png^hyperloop_logo.png^[transformR90]", 'vents_tube.png',
"hyperloop_tube_locked.png^hyperloop_logo.png^[transformR90]", 'vents_tube.png',
'hyperloop_tube_locked.png^hyperloop_logo.png', 'vents_tube.png',
'hyperloop_tube_locked.png^hyperloop_logo.png', 'vents_tube.png',
{ {
image = 'hyperloop_tube_open_active.png', image = 'hyperloop_tube_open_active.png',
backface_culling = false, backface_culling = false,
animation = { animation = {
type = "vertical_frames", type = 'vertical_frames',
aspect_w = 32, aspect_w = 32,
aspect_h = 32, aspect_h = 32,
length = 0.5, length = 0.5,
}, },
}, },
}, },
drawtype = "nodebox", drawtype = 'nodebox',
node_box = { node_box = {
type = "fixed", type = 'fixed',
fixed = { fixed = {
{-8/16, -8/16, -8/16, -7/16, 8/16, 8/16}, {-8/16, -8/16, -8/16, -7/16, 8/16, 8/16},
{ 7/16, -8/16, -8/16, 8/16, 8/16, 8/16}, { 7/16, -8/16, -8/16, 8/16, 8/16, 8/16},
@ -159,7 +157,7 @@ minetest.register_node("vents:tubeS2", {
}, },
}, },
selection_box = { selection_box = {
type = "fixed", type = 'fixed',
fixed = {-8/16, -8/16, -8/16, 8/16, 8/16, 8/16}, fixed = {-8/16, -8/16, -8/16, 8/16, 8/16, 8/16},
}, },
@ -167,29 +165,27 @@ minetest.register_node("vents:tubeS2", {
Tube:after_dig_tube(pos, oldnode, oldmetadata) Tube:after_dig_tube(pos, oldnode, oldmetadata)
end, end,
paramtype2 = "facedir", -- important! paramtype2 = 'facedir', -- important!
on_rotate = screwdriver.disallow, -- important! on_rotate = screwdriver.disallow, -- important!
paramtype = "light", paramtype = 'light',
light_source = 2,
sunlight_propagates = true,
is_ground_content = false, is_ground_content = false,
diggable = false, diggable = false,
groups = {not_in_creative_inventory=1}, groups = {not_in_creative_inventory=1},
sounds = {footstep = {name = 'metal', gain = 1}}, sounds = {footstep = {name = 'metal', gain = 1}},
}) })
minetest.register_node("vents:tubeA", { minetest.register_node('vents:tubeA', {
description = S("Vent"), description = S('Vent'),
inventory_image = minetest.inventorycube("hyperloop_tube_locked.png", inventory_image = minetest.inventorycube('vents_tube.png',
'hyperloop_tube_open.png', "hyperloop_tube_locked.png"), 'hyperloop_tube_open.png', 'vents_tube.png'),
tiles = { tiles = {
-- up, down, right, left, back, front -- up, down, right, left, back, front
"hyperloop_tube_closed.png^[transformR90]", 'hyperloop_tube_closed.png^[transformR90]',
{ {
image = 'hyperloop_tube_open_active.png', image = 'hyperloop_tube_open_active.png',
backface_culling = false, backface_culling = false,
animation = { animation = {
type = "vertical_frames", type = 'vertical_frames',
aspect_w = 32, aspect_w = 32,
aspect_h = 32, aspect_h = 32,
length = 0.5, length = 0.5,
@ -197,21 +193,21 @@ minetest.register_node("vents:tubeA", {
}, },
'hyperloop_tube_closed.png', 'hyperloop_tube_closed.png',
'hyperloop_tube_closed.png', 'hyperloop_tube_closed.png',
"hyperloop_tube_closed.png^[transformR90]", 'hyperloop_tube_closed.png^[transformR90]',
{ {
image = 'hyperloop_tube_open_active.png', image = 'hyperloop_tube_open_active.png',
backface_culling = false, backface_culling = false,
animation = { animation = {
type = "vertical_frames", type = 'vertical_frames',
aspect_w = 32, aspect_w = 32,
aspect_h = 32, aspect_h = 32,
length = 0.5, length = 0.5,
}, },
}, },
}, },
drawtype = "nodebox", drawtype = 'nodebox',
node_box = { node_box = {
type = "fixed", type = 'fixed',
fixed = { fixed = {
{-8/16, -8/16, -8/16, -7/16, 8/16, 8/16}, {-8/16, -8/16, -8/16, -7/16, 8/16, 8/16},
{ 7/16, -8/16, -8/16, 8/16, 8/16, 8/16}, { 7/16, -8/16, -8/16, 8/16, 8/16, 8/16},
@ -222,7 +218,7 @@ minetest.register_node("vents:tubeA", {
}, },
}, },
selection_box = { selection_box = {
type = "fixed", type = 'fixed',
fixed = {-8/16, -8/16, -8/16, 8/16, 8/16, 8/16}, fixed = {-8/16, -8/16, -8/16, 8/16, 8/16, 8/16},
}, },
@ -230,57 +226,28 @@ minetest.register_node("vents:tubeA", {
Tube:after_dig_tube(pos, oldnode, oldmetadata) Tube:after_dig_tube(pos, oldnode, oldmetadata)
end, end,
paramtype2 = "facedir", -- important! paramtype2 = 'facedir', -- important!
on_rotate = screwdriver.disallow, -- important! on_rotate = screwdriver.disallow, -- important!
paramtype = "light", paramtype = 'light',
light_source = 2,
sunlight_propagates = true,
is_ground_content = false, is_ground_content = false,
groups = {breakable=1, not_in_creative_inventory=1}, groups = {breakable=1, not_in_creative_inventory=1},
drop = "vents:tubeS", drop = 'vents:tubeS',
sounds = {footstep = {name = 'metal', gain = 1}}, sounds = {footstep = {name = 'metal', gain = 1}},
}) })
minetest.register_node("vents:tubeA2", { minetest.register_node('vents:tubeA2', {
description = "Hyperloop Tube", description = 'Hyperloop Tube',
tiles = { tiles = {'vents_tube.png',},
-- up, down, right, left, back, front
"hyperloop_tube_locked.png^hyperloop_logo.png^[transformR90]",
"hyperloop_tube_locked.png^hyperloop_logo.png^[transformR90]",
"hyperloop_tube_locked.png^hyperloop_logo.png",
"hyperloop_tube_locked.png^hyperloop_logo.png",
"hyperloop_tube_locked.png^hyperloop_logo.png",
"hyperloop_tube_locked.png^hyperloop_logo.png",
},
after_dig_node = function(pos, oldnode, oldmetadata, digger) after_dig_node = function(pos, oldnode, oldmetadata, digger)
Tube:after_dig_tube(pos, oldnode, oldmetadata) Tube:after_dig_tube(pos, oldnode, oldmetadata)
end, end,
paramtype2 = "facedir", -- important! paramtype2 = 'facedir', -- important!
on_rotate = screwdriver.disallow, -- important! on_rotate = screwdriver.disallow, -- important!
paramtype = "light", paramtype = 'light',
light_source = 2,
sunlight_propagates = true,
is_ground_content = false, is_ground_content = false,
diggable = false, diggable = false,
groups = {breakable=1, not_in_creative_inventory=1}, groups = {breakable=1, not_in_creative_inventory=1},
sounds = {footstep = {name = 'metal', gain = 1}}, sounds = {footstep = {name = 'metal', gain = 1}},
}) })
-- for tube viaducts
minetest.register_node("vents:pillar", {
description = "Vent",
tiles = {"hyperloop_tube_locked.png^[transformR90]"},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{ -3/8, -4/8, -3/8, 3/8, 4/8, 3/8},
},
},
is_ground_content = false,
groups = {breakable=1, stone = 2},
sounds = {footstep = {name = 'metal', gain = 1}},
})