More changes to the vents mod.

master
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)
minetest.register_node("vents:junction", {
description = S("Hyperloop Junction Block"),
tiles = {
"hyperloop_junction_top.png",
"hyperloop_junction_top.png",
"hyperloop_station_connection.png",
},
description = S("Vent Junction"),
tiles = {"vents_station_connection.png"},
after_place_node = function(pos, placer, itemstack, pointed_thing)
vents.check_network_level(pos, placer)
@ -67,27 +63,7 @@ minetest.register_node("vents:junction", {
paramtype2 = "facedir",
on_rotate = screwdriver.disallow,
paramtype = "light",
sunlight_propagates = true,
groups = {breakable=1},
is_ground_content = false,
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)
-- do a facedir correction
facedir = (facedir + 3) % 4 -- face to LCD
Stations:set(pos, "Station", {
Stations:set(pos, 'Station', {
owner = placer:get_player_name(),
facedir = facedir,
time_blocked = 0})
end
local function naming_formspec(pos)
local data = Stations:get(pos)
local vent = data.name or 'vent'
local info = data.booking_info or ''
local formspec =
"size[7,4.4]"..
"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,2.7;7.1,1;info;"..S("Additional vent information")..";]" ..
"button_exit[2.5,3.7;2,1;exit;Save]"
'size[7,4.4]'..
'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,2.7;7.1,1;info;'..S('Additional vent information')..';'..info..']' ..
'button_exit[2.5,3.7;2,1;exit;Save]'
return formspec
end
-- Form spec for the station list
local function generate_string(sortedList)
local tRes = {"size[12,8]"..
"label[4,0; "..S("Select your destination").."]"}
tRes[2] = "tablecolumns[text,width=20;text,width=6,align=right;text]"
local tRes = {'size[12,8]'..
'label[4,0; '..S('Select your destination')..']'}
tRes[2] = 'tablecolumns[text,width=20;text,width=6,align=right;text]'
local stations = {}
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 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] = distance.."m"
stations[#stations+1] = distance..'m'
stations[#stations+1] = minetest.formspec_escape(info)
end
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
tRes[#tRes+1] = "button_exit[4,4;3,1;button;Update]"
tRes[#tRes+1] = 'button_exit[4,4;3,1;button;Update]'
end
return table.concat(tRes)
@ -92,7 +95,7 @@ end
local function filter_subnet(sortedList, subnet)
if vents.subnet_enabled then
if subnet == "" then
if subnet == '' then
subnet = nil
end
@ -112,7 +115,7 @@ end
local function station_list_as_string(pos, subnet)
local meta = M(pos)
-- 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
sortedList = remove_junctions(sortedList)
-- 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.name ~= nil then
local station_name = string.trim(fields.name)
if station_name == "" then
if station_name == '' then
return
end
if Stations:get(pos).booking_pos then
minetest.chat_send_player(name, S("Remove and replace to change name."))
--if Stations:get(pos).booking_pos then
-- minetest.chat_send_player(name, S('Remove and replace to change name.'))
--Figure out how to allow a builder to update station.
return
end
-- return
--end
-- store meta and generate station formspec
Stations:update(pos, {
name = station_name,
@ -146,16 +149,16 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
})
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')
else
vents.chat(player, S("Invalid station name!"))
vents.chat(player, S('Invalid station name!'))
end
end
elseif formname == 'vents:station_list' then
local te = minetest.explode_table_event(fields.button)
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 dest_pos = tStationList[SP(pos)] and tStationList[SP(pos)][idx]
if dest_pos and tStation then
@ -174,24 +177,20 @@ end)
local function on_destruct(pos)
Stations:update((pos), {
booking_pos = "nil",
booking_info = "nil",
name = "Station",
booking_pos = 'nil',
booking_info = 'nil',
name = 'Station',
})
end
minetest.register_node("vents:station", {
description = S("Vent Access"),
drawtype = "nodebox",
tiles = {
"hyperloop_station.png",
"hyperloop_station_connection.png",
"hyperloop_station_connection.png",
},
minetest.register_node('vents:station', {
description = S('Vent Access'),
drawtype = 'nodebox',
tiles = {'vents_station.png'},
after_place_node = function(pos, placer, itemstack, pointed_thing)
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)
Tube:after_place_node(pos)
end,
@ -201,7 +200,7 @@ minetest.register_node("vents:station", {
local player_attributes = clicker:get_meta()
local mode = player_attributes:get_string('mode')
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))
elseif mode == 'builder' then
minetest.show_formspec(name, 'vents:setup', naming_formspec(pos))
@ -217,7 +216,8 @@ minetest.register_node("vents:station", {
on_destruct = on_destruct,
on_rotate = screwdriver.disallow,
paramtype2 = "facedir",
paramtype = 'light',
paramtype2 = 'facedir',
groups = {breakable=1},
is_ground_content = false,
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)
if dataSet then
if dataSet.junction == true then
return S("Junction at ")..SP(pos)
return S('Junction at ')..SP(pos)
elseif dataSet.name ~= nil then
return S("Station '")..dataSet.name.."' at "..SP(pos)
return S('Station \'')..dataSet.name..'\' at '..SP(pos)
else
return S("Station at ")..SP(pos)
return S('Station at ')..SP(pos)
end
end
return S("Open end at ")..minetest.pos_to_string(pos)
return S('Open end at ')..minetest.pos_to_string(pos)
end
function vents.check_network_level(pos, player)
@ -42,8 +42,8 @@ function vents.check_network_level(pos, player)
return
end
end
vents.chat(player, S("There is no station/junction on this level. ")..
S("Do you really want to start a new network?!"))
vents.chat(player, S('There is no station/junction on this level. ')..
S('Do you really want to start a new network?!'))
end
-- North, East, South, West, Down, Up
@ -56,43 +56,43 @@ local Tube = tubelib2.Tube:new({
dirs_to_check = dirs_to_check,
max_tube_length = 1000,
show_infotext = true,
primary_node_names = {"vents:tubeS", "vents:tubeS2", "vents:tubeA", "vents:tubeA2"},
secondary_node_names = {"vents:junction", "vents:station", "vents:tube_wifi1"},
primary_node_names = {'vents:tubeS', 'vents:tubeS2', 'vents:tubeA', 'vents:tubeA2'},
secondary_node_names = {'vents:junction', 'vents:station', 'vents:tube_wifi1'},
after_place_tube = function(pos, param2, tube_type, num_tubes)
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
minetest.set_node(pos, {name = "vents:tube"..tube_type, param2 = param2})
minetest.set_node(pos, {name = 'vents:tube'..tube_type, param2 = param2})
end
end,
})
vents.Tube = Tube
minetest.register_node("vents:tubeS", {
description = S("Vent"),
inventory_image = minetest.inventorycube("hyperloop_tube_locked.png",
'hyperloop_tube_open.png', "hyperloop_tube_locked.png"),
minetest.register_node('vents:tubeS', {
description = S('Vent'),
inventory_image = minetest.inventorycube('vents_tube.png',
'hyperloop_tube_open.png', 'vents_tube.png'),
tiles = {
-- 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',
{
image = 'hyperloop_tube_open_active.png',
backface_culling = false,
animation = {
type = "vertical_frames",
type = 'vertical_frames',
aspect_w = 32,
aspect_h = 32,
length = 0.5,
},
},
},
drawtype = "nodebox",
drawtype = 'nodebox',
node_box = {
type = "fixed",
type = 'fixed',
fixed = {
{-8/16, -8/16, -8/16, -7/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 = {
type = "fixed",
type = 'fixed',
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)
end,
paramtype2 = "facedir", -- important!
paramtype2 = 'facedir', -- important!
on_rotate = screwdriver.disallow, -- important!
paramtype = "light",
light_source = 2,
sunlight_propagates = true,
paramtype = 'light',
is_ground_content = false,
groups = {breakable=1},
sounds = {footstep = {name = 'metal', gain = 1}},
})
minetest.register_node("vents:tubeS2", {
description = "Vent",
minetest.register_node('vents:tubeS2', {
description = 'Vent',
tiles = {
-- 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',
'vents_tube.png',
'vents_tube.png',
'vents_tube.png',
'vents_tube.png',
{
image = 'hyperloop_tube_open_active.png',
backface_culling = false,
animation = {
type = "vertical_frames",
type = 'vertical_frames',
aspect_w = 32,
aspect_h = 32,
length = 0.5,
},
},
},
drawtype = "nodebox",
drawtype = 'nodebox',
node_box = {
type = "fixed",
type = 'fixed',
fixed = {
{-8/16, -8/16, -8/16, -7/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 = {
type = "fixed",
type = 'fixed',
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)
end,
paramtype2 = "facedir", -- important!
paramtype2 = 'facedir', -- important!
on_rotate = screwdriver.disallow, -- important!
paramtype = "light",
light_source = 2,
sunlight_propagates = true,
paramtype = 'light',
is_ground_content = false,
diggable = false,
groups = {not_in_creative_inventory=1},
sounds = {footstep = {name = 'metal', gain = 1}},
})
minetest.register_node("vents:tubeA", {
description = S("Vent"),
inventory_image = minetest.inventorycube("hyperloop_tube_locked.png",
'hyperloop_tube_open.png', "hyperloop_tube_locked.png"),
minetest.register_node('vents:tubeA', {
description = S('Vent'),
inventory_image = minetest.inventorycube('vents_tube.png',
'hyperloop_tube_open.png', 'vents_tube.png'),
tiles = {
-- up, down, right, left, back, front
"hyperloop_tube_closed.png^[transformR90]",
'hyperloop_tube_closed.png^[transformR90]',
{
image = 'hyperloop_tube_open_active.png',
backface_culling = false,
animation = {
type = "vertical_frames",
type = 'vertical_frames',
aspect_w = 32,
aspect_h = 32,
length = 0.5,
@ -197,21 +193,21 @@ minetest.register_node("vents:tubeA", {
},
'hyperloop_tube_closed.png',
'hyperloop_tube_closed.png',
"hyperloop_tube_closed.png^[transformR90]",
'hyperloop_tube_closed.png^[transformR90]',
{
image = 'hyperloop_tube_open_active.png',
backface_culling = false,
animation = {
type = "vertical_frames",
type = 'vertical_frames',
aspect_w = 32,
aspect_h = 32,
length = 0.5,
},
},
},
drawtype = "nodebox",
drawtype = 'nodebox',
node_box = {
type = "fixed",
type = 'fixed',
fixed = {
{-8/16, -8/16, -8/16, -7/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 = {
type = "fixed",
type = 'fixed',
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)
end,
paramtype2 = "facedir", -- important!
paramtype2 = 'facedir', -- important!
on_rotate = screwdriver.disallow, -- important!
paramtype = "light",
light_source = 2,
sunlight_propagates = true,
paramtype = 'light',
is_ground_content = false,
groups = {breakable=1, not_in_creative_inventory=1},
drop = "vents:tubeS",
drop = 'vents:tubeS',
sounds = {footstep = {name = 'metal', gain = 1}},
})
minetest.register_node("vents:tubeA2", {
description = "Hyperloop Tube",
tiles = {
-- 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",
},
minetest.register_node('vents:tubeA2', {
description = 'Hyperloop Tube',
tiles = {'vents_tube.png',},
after_dig_node = function(pos, oldnode, oldmetadata, digger)
Tube:after_dig_tube(pos, oldnode, oldmetadata)
end,
paramtype2 = "facedir", -- important!
paramtype2 = 'facedir', -- important!
on_rotate = screwdriver.disallow, -- important!
paramtype = "light",
light_source = 2,
sunlight_propagates = true,
paramtype = 'light',
is_ground_content = false,
diggable = false,
groups = {breakable=1, not_in_creative_inventory=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}},
})