1 Commits

Author SHA1 Message Date
745250cf2a add plastcrete 2025-02-02 13:28:28 +01:00
14 changed files with 41 additions and 394 deletions

View File

@ -46,12 +46,10 @@ CC BY 3.0
* scifi_nodes_grass_top.png https://github.com/minetest/minetest_game
* scifi_nodes_grass_side.png https://github.com/minetest/minetest_game
* scifi_nodes_wood.png https://github.com/minetest/minetest_game
* scifi_nodes_plastcrete.png https://github.com/mt-mods/basic_materials
CC0
* scifi_nodes_digicode.ogg https://freesound.org/people/benjaminharveydesign/sounds/315921/
* scifi_nodes_ambience_fan.ogg https://freesound.org/people/itinerantmonk108/sounds/554430/
* scifi_nodes_ambience_vent.ogg https://freesound.org/people/kentspublicdomain/sounds/324665/
* scifi_nodes_ambience_engine.ogg https://freesound.org/people/firestorm185/sounds/423221/
# Contributors:

View File

@ -1,259 +0,0 @@
local FORMSPEC_NAME = "scifi_nodes:access_card_configure"
local function create_id()
local template = "xxxxxx"
return string.gsub(template, '[x]', function ()
return string.format('%x', math.random(0, 0xf))
end)
end
local function get_door_access_table(meta)
local str = meta:get_string("access")
if str == "" then
-- no config
return {}
else
return minetest.deserialize(str) or {}
end
end
local function set_door_access_table(meta, at)
if next(at) then
meta:set_string("access", minetest.serialize(at))
else
meta:set_string("access", "")
end
end
function scifi_nodes.door_check_access_card(node_pos, itemstack, player)
local node_meta = minetest.get_meta(node_pos)
local access_table = get_door_access_table(node_meta)
if not next(access_table) then
-- access not restricted
return true
end
if not minetest.is_player(player) then
-- not a player, restrict access
return false
end
local playername = player:get_player_name()
if itemstack:get_name() ~= "scifi_nodes:access_card" then
minetest.chat_send_player(playername, minetest.colorize("#ff0000", "Access denied: no access card detected!"))
minetest.sound_play("scifi_nodes_scanner_refused", { pos = node_pos, max_hear_distance = 10 })
return false
end
local item_meta = itemstack:get_meta()
local id = item_meta:get_string("id")
if id == "" then
minetest.chat_send_player(playername, minetest.colorize("#ff0000", "Access denied: unconfigured access card"))
minetest.sound_play("scifi_nodes_scanner_refused", { pos = node_pos, max_hear_distance = 10 })
return false
end
if not access_table[id] then
minetest.chat_send_player(playername, minetest.colorize("#ff0000", "Access denied: invalid access card"))
minetest.sound_play("scifi_nodes_scanner_refused", { pos = node_pos, max_hear_distance = 10 })
return false
end
minetest.sound_play("scifi_nodes_scanner_granted", { pos = node_pos, max_hear_distance = 10 })
return true
end
-- using a card against a door toggles the access to it
local function on_use(itemstack, player, pointed_thing)
local playername = player:get_player_name()
local pos = pointed_thing.under
if not pos then
-- nothing selected
return
end
if minetest.is_protected(pos, playername) then
-- protected
return
end
local node = minetest.get_node(pos)
local node_def = minetest.registered_nodes[node.name]
if not node_def.groups or not node_def.groups.scifi_nodes_door then
-- incompatible node
return
end
local item_meta = itemstack:get_meta()
local card_id = item_meta:get_string("id")
if card_id == "" then
minetest.chat_send_player(playername, "Access card is unconfigured")
return
end
local card_name = item_meta:get_string("name")
local node_meta = minetest.get_meta(pos)
local access_table = get_door_access_table(node_meta)
if access_table[card_id] then
-- remove access
access_table[card_id] = nil
minetest.chat_send_player(playername, "Revoked access to card-id '" .. card_id .. "'")
minetest.sound_play("scifi_nodes_scanner_refused", { pos = pos, max_hear_distance = 10 })
else
-- grant access
access_table[card_id] = card_name
minetest.chat_send_player(playername, "Granted access to card-id '" .. card_id .. "'")
minetest.sound_play("scifi_nodes_scanner_granted", { pos = pos, max_hear_distance = 10 })
end
local msg = ""
if next(access_table) then
msg = msg .. "Current registered cards: "
for id, name in pairs(access_table) do
msg = msg .. "Name: '" .. name .. "' ID: '" .. id .. "' / "
end
else
-- access table is empty
msg = "No access-card left in access-table, door is free to use"
end
minetest.chat_send_player(playername, msg)
-- set new access table
set_door_access_table(node_meta, access_table)
end
local function configure_access_card(meta, name)
local id = meta:get_string("id")
if id == "" then
-- set new id
id = create_id()
meta:set_string("id", id)
end
meta:set_string("name", name)
meta:set_string("description", "Access card '" .. name .. "' (id: '" .. id .. "')")
end
-- right-click with a card for rename/configuration
local function on_secondary_use(itemstack, player, pointed_thing)
local meta = itemstack:get_meta()
if meta:get_string("id") == "" then
-- initial configuration
configure_access_card(meta, "")
end
local name = meta:get_string("name")
minetest.show_formspec(player:get_player_name(), FORMSPEC_NAME, [[
size[10,1.4]
real_coordinates[true]
field[0.1,0.4;7,0.8;name;Name;]] .. minetest.formspec_escape(name) .. [[]
button_exit[7.3,0.4;2.5,0.8;save;Save]
]])
return itemstack
end
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= FORMSPEC_NAME then
-- wrong formspec
return false
end
if not fields.save and not fields.key_enter_field then
-- quit
return true
end
local itemstack = player:get_wielded_item()
if itemstack:get_name() ~= "scifi_nodes:access_card" then
-- invalid item
return true
end
local meta = itemstack:get_meta()
configure_access_card(meta, fields.name or "")
player:set_wielded_item(itemstack)
end)
minetest.register_craftitem("scifi_nodes:access_card", {
description = "Access card (unconfigured)",
inventory_image = "scifi_nodes_access_card.png",
palette = "unifieddyes_palette_extended.png",
stack_max = 1,
paramtype2 = "color",
on_use = on_use,
on_secondary_use = on_secondary_use,
groups = {
ud_param2_colorable = 1
}
})
-- initial recipe
minetest.register_craft({
output = "scifi_nodes:access_card",
recipe = {
{"scifi_nodes:white2", "", ""},
{"scifi_nodes:white_pad", "", ""},
{"scifi_nodes:white2", "", ""}
}
})
-- copy recipe
minetest.register_craft({
output = "scifi_nodes:access_card",
recipe = {
{"scifi_nodes:access_card", "scifi_nodes:white_pad", ""},
{"", "", ""},
{"", "", ""}
}
})
minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv)
if itemstack:get_name() ~= "scifi_nodes:access_card" then
return
end
local original
local index
for i = 1, #old_craft_grid do
if old_craft_grid[i]:get_name() == "scifi_nodes:access_card" then
original = old_craft_grid[i]
index = i
break
end
end
if not original then
return
end
-- copy metadata
local src_meta = original:get_meta()
local dst_meta = itemstack:get_meta()
local copy_fields = {"id", "name", "description"}
for _, fieldname in ipairs(copy_fields) do
dst_meta:set_string(fieldname, src_meta:get_string(fieldname))
end
if old_craft_grid[2]:get_name() == "scifi_nodes:white_pad" then
-- keep original item if the copy-recipe is used
craft_inv:set_stack("craft", index, original)
end
end)
if minetest.get_modpath("unifieddyes") then
-- add colored crafts
unifieddyes.register_color_craft({
output = "scifi_nodes:access_card",
palette = "extended",
neutral_node = "scifi_nodes:access_card",
recipe = {
"NEUTRAL_NODE",
"MAIN_DYE"
},
type = "shapeless"
})
end

View File

@ -1,73 +0,0 @@
-- currently playing sounds per mapblock
-- mapblock_pos[number]
local currently_playing = {}
-- clear the currently playing tracker every few seconds
local function clear_currently_playing()
currently_playing = {}
minetest.after(5, clear_currently_playing)
end
minetest.after(5, clear_currently_playing)
-- mapblock resolution
local function get_key(pos)
return minetest.pos_to_string(vector.round(vector.divide(pos, 16)))
end
local function add_currently_playing(pos, value)
local key = get_key(pos)
local count = currently_playing[key]
if not count then
-- new entry
count = value
else
-- update entry
count = count + value
end
currently_playing[key] = count
end
-- limit plaing sounds per mapblock
local function can_play(pos)
local count = currently_playing[get_key(pos)]
return not count or count < 25
end
-- register ambience sounds with node-timer
function scifi_nodes.register_ambience(nodename, soundname, opts)
assert(opts)
opts.interval = opts.interval or 60
local function play(pos)
minetest.sound_play(soundname ,{
max_hear_distance = opts.max_hear_distance or 16,
pos = pos,
gain = opts.gain or 0.7
})
end
minetest.override_item(nodename, {
on_timer = function(pos)
local timer = minetest.get_node_timer(pos)
if not can_play(pos) then
-- too many sounds playing, recheck again soon
timer:start(1)
return
end
-- increment usage count
add_currently_playing(pos, 1)
play(pos)
-- restart timer
timer:start(opts.interval)
end,
on_construct = function(pos)
play(pos)
local timer = minetest.get_node_timer(pos)
timer:start(opts.interval)
end
})
end

View File

@ -1,17 +1,16 @@
local has_default = minetest.get_modpath("default")
--chest code from default(Copyright (C) 2012 celeron55, Perttu Ahola <celeron55@gmail.com>)
local chest_formspec =
"size[8,9]" ..
(has_default and default.gui_bg or "") ..
(has_default and default.gui_bg_img or "") ..
(has_default and default.gui_slots or "") ..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
"list[current_name;main;0,0.3;8,4;]" ..
"list[current_player;main;0,4.85;8,1;]" ..
"list[current_player;main;0,6.08;8,3;8]" ..
"listring[current_name;main]" ..
"listring[current_player;main]" ..
(has_default and default.get_hotbar_bg(0,4.85) or "")
default.get_hotbar_bg(0,4.85)
-- Helper functions
local function drop_chest_stuff()

View File

@ -34,6 +34,15 @@ if not minetest.get_modpath("default") or not minetest.get_modpath("dye") then
return
end
minetest.register_craft({
output = "scifi_nodes:plastcrete 6",
recipe = {
{"scifi_nodes:white2", "default:gravel", "scifi_nodes:white2"},
{"default:gravel", "scifi_nodes:white2", "default:gravel"},
{"scifi_nodes:white2", "default:gravel", "scifi_nodes:white2"}
}
})
minetest.register_craft({
output = "scifi_nodes:super_white",
recipe = {

View File

@ -148,18 +148,14 @@ for _, current_door in ipairs(doors) do
local adjacent = minetest.get_node({x=x, y=y, z=z})
if adjacent.name == target_opposite then
minetest.swap_node({x=x, y=y, z=z}, {name=target, param2 = adjacent.param2})
minetest.swap_node({x=x, y=y+1, z=z}, {name=target_top, param2 = adjacent.param2})
minetest.set_node({x=x, y=y, z=z}, {name=target, param2 = adjacent.param2})
minetest.set_node({x=x, y=y+1, z=z}, {name=target_top, param2 = adjacent.param2})
end
end
end
local function open_door(pos, node, player, itemstack)
if not scifi_nodes.door_check_access_card(pos, itemstack, player) then
return
end
local function open_door(pos, node)
-- play sound
minetest.sound_play(sound,{
max_hear_distance = 16,
@ -169,8 +165,8 @@ for _, current_door in ipairs(doors) do
local timer = minetest.get_node_timer(pos)
minetest.swap_node(pos, {name=opened, param2=node.param2})
minetest.swap_node({x=pos.x,y=pos.y+1,z=pos.z}, {name=opened_top, param2=node.param2})
minetest.set_node(pos, {name=opened, param2=node.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, {name=opened_top, param2=node.param2})
change_adjacent(opened, pos, node)
@ -192,8 +188,8 @@ for _, current_door in ipairs(doors) do
local node = minetest.get_node(pos)
minetest.swap_node(pos, {name=closed, param2=node.param2})
minetest.swap_node({x=pos.x,y=pos.y+1,z=pos.z}, {name=closed_top, param2=node.param2})
minetest.set_node(pos, {name=closed, param2=node.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, {name=closed_top, param2=node.param2})
change_adjacent(closed, pos, node)
end
@ -246,7 +242,7 @@ for _, current_door in ipairs(doors) do
paramtype2 = "facedir",
groups = {
cracky = 3,
dig_generic = 3,
oddly_breakable_by_hand = 1,
scifi_nodes_door = 1,
door = 1
},

View File

@ -14,17 +14,15 @@ end
dofile(MP.."/common.lua")
if minetest.get_modpath("default") then
-- only load builder if the default mod is available
-- only load builder and chest if the default mod is available
-- the formspecs depend on it
dofile(MP.."/builder.lua")
dofile(MP.."/chest.lua")
end
dofile(MP.."/ambience.lua")
dofile(MP.."/chest.lua")
dofile(MP.."/plants.lua")
dofile(MP.."/models.lua")
dofile(MP.."/nodes.lua")
dofile(MP.."/access_card.lua")
dofile(MP.."/doors.lua")
dofile(MP.."/switch.lua")
dofile(MP.."/protected_switch.lua")
@ -48,6 +46,4 @@ end
if minetest.get_modpath("mtt") and mtt.enabled then
dofile(MP .. "/mtt.lua")
end
minetest.log("action", "[scifi_nodes] loaded.")
end

View File

@ -31,8 +31,8 @@ end
-- register some blocks in stairsplus if available (part of moreblocks)
scifi_nodes.register_slope("white2", "Plastic", {"scifi_nodes_white2.png",}, 0, "stone")
scifi_nodes.register_slope("super_white", "Super Plastic", {"scifi_nodes_white2.png",}, 11, "stone")
scifi_nodes.register_slope("ultra_white", "Super Plastic", {"scifi_nodes_white2.png",},minetest.LIGHT_MAX, "stone")
scifi_nodes.register_slope("super_white", "Super Plastic", {"scifi_nodes_super_white.png",}, 11, "stone")
scifi_nodes.register_slope("ultra_white", "Super Plastic", {"scifi_nodes_ultra_white.png",},minetest.LIGHT_MAX, "stone")
scifi_nodes.register_slope("black", "Black", {"scifi_nodes_black.png",}, 0)
scifi_nodes.register_slope("white", "White", {"scifi_nodes_white.png",}, 0)
scifi_nodes.register_slope("grey", "Grey", {"scifi_nodes_grey.png",}, 0)

View File

@ -25,12 +25,7 @@
"texture_name": "white2"
},
"engine": {
"description": "Engine",
"ambience": {
"scifi_nodes_ambience_engine": {
"interval": 16.1
}
}
"description": "Engine"
},
"wall": {
"description": "metal wall"
@ -63,12 +58,7 @@
"description": "transparent vent",
"texture_name": "vent2",
"texture_modifier": "^[makealpha:33,33,33",
"drawtype": "glasslike",
"ambience": {
"scifi_nodes_ambience_vent": {
"interval": 4.2
}
}
"drawtype": "glasslike"
},
"stripes": {
"description": "hazard stripes",
@ -95,8 +85,7 @@
"description": "black tile"
},
"blacktile2": {
"description": "black tile 2",
"paramtype2": "none"
"description": "black tile 2"
},
"blackvent": {
"description": "black vent"
@ -152,8 +141,7 @@
"description": "red metal block"
},
"grey_square": {
"description": "grey metal block",
"paramtype2": "none"
"description": "grey metal block"
},
"blue_square": {
"description": "blue metal block"
@ -246,8 +234,7 @@
},
"blackdmg": {
"description": "Damaged black wall",
"slat": true,
"paramtype2": "none"
"slat": true
},
"blackdmgstripe": {
"description": "Damaged black wall(stripes)"
@ -274,12 +261,7 @@
"light": 5
},
"fan": {
"description": "Fan",
"ambience": {
"scifi_nodes_ambience_fan": {
"interval": 7
}
}
"description": "Fan"
},
"ppllght": {
"description": "Purple wall light",
@ -319,7 +301,13 @@
"description": "Black vent"
},
"blackplate": {
"description": "Black plate",
"description": "Black plate"
},
"plastcrete": {
"description": "Plastcrete",
"sounds": "stone",
"colorable": true,
"moreblocks": false,
"paramtype2": "none"
}
}

View File

@ -537,8 +537,7 @@ for name, def in pairs(nodes) do
end
-- register node
local nodename = "scifi_nodes:" .. name
minetest.register_node(nodename , node_def)
minetest.register_node("scifi_nodes:"..name, node_def)
-- unified dyes registration
if def.colorable and has_unifieddyes_mod then
@ -575,12 +574,6 @@ for name, def in pairs(nodes) do
})
end
if def.ambience then
for soundname, opts in pairs(def.ambience) do
scifi_nodes.register_ambience(nodename, soundname, opts)
end
end
-- advtrains platform registration
if has_advtrains_mod and def.advtrains_platform then
advtrains.register_platform("scifi_nodes", "scifi_nodes:" .. name)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB